From 65e3177def2fa2b637d791cd3441f9ad5ad98e8b Mon Sep 17 00:00:00 2001 From: neodiX42 Date: Fri, 3 Jun 2022 15:01:55 +0200 Subject: [PATCH] Fix windows validator-engine.exe runtime access violation error (#387) * Fix runtime access violation error on Windows --- .github/workflows/docker-ubuntu-image.yml | 22 +++--- .github/workflows/macos-10.15-compile.yml | 8 ++- .github/workflows/macos-10.15-tonlib-java.yml | 60 ++++++++++++++++ .github/workflows/ubuntu-18.04-compile.yml | 31 ++++---- .../workflows/ubuntu-18.04-ton-ccpcheck.yml | 31 ++++++++ .../workflows/ubuntu-18.04-tonlib-java.yml | 50 +++++++++++++ .github/workflows/windows2019x64-compile.yml | 11 ++- .../workflows/windows2019x64-tonlib-java.yml | 71 +++++++++++++++++++ doc/tblkch.tex | 2 +- doc/tvm.tex | 2 +- validator/impl/collator.cpp | 10 +-- validator/impl/validate-query.cpp | 18 ++--- 12 files changed, 262 insertions(+), 54 deletions(-) create mode 100644 .github/workflows/macos-10.15-tonlib-java.yml create mode 100644 .github/workflows/ubuntu-18.04-ton-ccpcheck.yml create mode 100644 .github/workflows/ubuntu-18.04-tonlib-java.yml create mode 100644 .github/workflows/windows2019x64-tonlib-java.yml diff --git a/.github/workflows/docker-ubuntu-image.yml b/.github/workflows/docker-ubuntu-image.yml index 4fd9d1da..2f0d49ee 100644 --- a/.github/workflows/docker-ubuntu-image.yml +++ b/.github/workflows/docker-ubuntu-image.yml @@ -1,4 +1,4 @@ -name: Build Docker Ubuntu Image +name: Docker Ubuntu 18.04 image on: workflow_dispatch: @@ -12,34 +12,28 @@ env: jobs: build-and-push: - runs-on: ubuntu-latest + runs-on: ubuntu-18.04 steps: - - - name: Checkout + - name: Checkout uses: actions/checkout@v2 - - - name: Set up QEMU + - name: Set up QEMU uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - - - name: Login to GitHub Container Registry + - name: Login to GitHub Container Registry uses: docker/login-action@v1 with: registry: ${{ env.REGISTRY }} username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push + - name: Build and push id: docker_build uses: docker/build-push-action@v2 with: push: true context: ./docker - tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest - + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \ No newline at end of file diff --git a/.github/workflows/macos-10.15-compile.yml b/.github/workflows/macos-10.15-compile.yml index 1aa36a9f..351b3ea0 100644 --- a/.github/workflows/macos-10.15-compile.yml +++ b/.github/workflows/macos-10.15-compile.yml @@ -1,6 +1,10 @@ name: C/C++ CI macOS-10.15 Compile -on: [push,workflow_dispatch] +on: + workflow_dispatch: + push: + branches: + - 'master' jobs: build: @@ -36,4 +40,4 @@ jobs: uses: actions/upload-artifact@master with: name: ton-macos-binaries - path: artifacts + path: artifacts \ No newline at end of file diff --git a/.github/workflows/macos-10.15-tonlib-java.yml b/.github/workflows/macos-10.15-tonlib-java.yml new file mode 100644 index 00000000..e5199f58 --- /dev/null +++ b/.github/workflows/macos-10.15-tonlib-java.yml @@ -0,0 +1,60 @@ +name: macOS-10.15 tonlib-java + + +on: + workflow_dispatch: + push: + branches: + - 'wallets' +jobs: + build: + + runs-on: macos-10.15 + + steps: + - name: Check out repository + uses: actions/checkout@v2 + with: + submodules: 'recursive' + + - name: Compile OpenSSL + run: | + git clone https://github.com/openssl/openssl openssl_1_1_1 + cd openssl_1_1_1 + git checkout OpenSSL_1_1_1-stable + ./Configure --prefix=/usr/local/macos darwin64-x86_64-cc -static -mmacosx-version-min=10.15 + make build_libs -j4 + + - name: Configure & Build + run: | + rootPath=`pwd` + + export CC=$(which clang) + export CXX=$(which clang++) + export CCACHE_DISABLE=1 + + export JAVA_AWT_LIBRARY=NotNeeded + export JAVA_JVM_LIBRARY=NotNeeded + export JAVA_INCLUDE_PATH=${JAVA_HOME}/include + export JAVA_AWT_INCLUDE_PATH=${JAVA_HOME}/include + export JAVA_INCLUDE_PATH2=${JAVA_HOME}/include/darwin + + cd example/android/ + mkdir build + cd build + + cmake -DOPENSSL_FOUND=1 -DOPENSSL_INCLUDE_DIR=$rootPath/openssl_1_1_1/include -DOPENSSL_CRYPTO_LIBRARY=$rootPath/openssl_1_1_1/libcrypto.a -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.15 -DCMAKE_CXX_FLAGS="-stdlib=libc++" -DTON_ONLY_TONLIB=ON .. + cmake --build . --target prepare_cross_compiling + cmake --build . --target native-lib --config Release + + - name: find & copy binaries + run: | + mkdir -p artifacts/tonlib-java + cp example/android/src/drinkless/org/ton/TonApi.java artifacts/tonlib-java/ + cp example/android/build/libnative-lib.dylib artifacts/tonlib-java/ + + - name: Upload artifacts + uses: actions/upload-artifact@master + with: + name: tonlib-macos-java + path: artifacts diff --git a/.github/workflows/ubuntu-18.04-compile.yml b/.github/workflows/ubuntu-18.04-compile.yml index f27185bb..e215c7bd 100644 --- a/.github/workflows/ubuntu-18.04-compile.yml +++ b/.github/workflows/ubuntu-18.04-compile.yml @@ -12,28 +12,21 @@ jobs: uses: actions/checkout@v2 with: submodules: 'recursive' - - name: Run Cppcheck - uses: Bedzior/run-cppcheck@master - with: - enabled checks: all - enable inconclusive: true - generate report: true - - name: Upload report - uses: actions/upload-artifact@v1 - with: - name: report - path: output - - name: mkdir + + - name: Install libraries run: | + sudo apt update + sudo apt install -y build-essential git make cmake clang libgflags-dev zlib1g-dev libssl-dev libreadline-dev libmicrohttpd-dev pkg-config libgsl-dev python3 python3-dev ninja-build + + - name: Configure & Build + run: | + export CC=$(which clang) + export CXX=$(which clang++) + export CCACHE_DISABLE=1 mkdir build - - name: cmake all - run: | cd build - cmake -DCMAKE_BUILD_TYPE=Release .. - - name: make all - run: | - cd build - make -j4 fift func tonlib tonlibjson tonlib-cli validator-engine lite-client pow-miner validator-engine-console generate-random-id json2tlo dht-server http-proxy rldp-http-proxy adnl-proxy create-state create-hardfork + cmake -GNinja -DCMAKE_BUILD_TYPE=Release .. + ninja fift func tonlib tonlibjson tonlib-cli validator-engine lite-client pow-miner validator-engine-console generate-random-id json2tlo dht-server http-proxy rldp-http-proxy adnl-proxy create-state create-hardfork - name: find & copy binaries run: | diff --git a/.github/workflows/ubuntu-18.04-ton-ccpcheck.yml b/.github/workflows/ubuntu-18.04-ton-ccpcheck.yml new file mode 100644 index 00000000..97c46efb --- /dev/null +++ b/.github/workflows/ubuntu-18.04-ton-ccpcheck.yml @@ -0,0 +1,31 @@ +name: Ubuntu 18.04 TON ccpcheck + +on: + workflow_dispatch: + push: + branches: + - 'master' + +jobs: + build: + + runs-on: ubuntu-18.04 + + steps: + - name: Check out repository + uses: actions/checkout@v2 + with: + submodules: 'recursive' + + - name: Run Cppcheck + uses: Bedzior/run-cppcheck@master + with: + enabled checks: all + enable inconclusive: true + generate report: true + + - name: Upload report + uses: actions/upload-artifact@v1 + with: + name: ton-ccpcheck-report + path: output \ No newline at end of file diff --git a/.github/workflows/ubuntu-18.04-tonlib-java.yml b/.github/workflows/ubuntu-18.04-tonlib-java.yml new file mode 100644 index 00000000..8c746b26 --- /dev/null +++ b/.github/workflows/ubuntu-18.04-tonlib-java.yml @@ -0,0 +1,50 @@ +name: Ubuntu 18.04 tonlib-java + +on: + workflow_dispatch: + push: + branches: + - 'wallets' + +jobs: + build: + + runs-on: ubuntu-18.04 + + steps: + - name: Check out repository + uses: actions/checkout@v2 + with: + submodules: 'recursive' + + - name: Install libraries + run: | + sudo apt update + sudo apt install -y build-essential git make cmake clang libgflags-dev zlib1g-dev libssl-dev libreadline-dev libmicrohttpd-dev pkg-config libgsl-dev python3 python3-dev ninja-build + + - name: Configure & Build + run: | + export JAVA_AWT_LIBRARY=NotNeeded + export JAVA_JVM_LIBRARY=NotNeeded + export JAVA_INCLUDE_PATH=${JAVA_HOME}/include + export JAVA_AWT_INCLUDE_PATH=${JAVA_HOME}/include + export JAVA_INCLUDE_PATH2=${JAVA_HOME}/include/linux + + cd example/android/ + mkdir build + cd build + cmake -DTON_ONLY_TONLIB=ON .. + cmake --build . --target prepare_cross_compiling + cmake --build . --target native-lib + + - name: find & copy binaries + run: | + mkdir -p artifacts/tonlib-java + cp example/android/src/drinkless/org/ton/TonApi.java artifacts/tonlib-java/ + cp example/android/build/libnative-lib.so artifacts/tonlib-java/ + + - name: Upload artifacts + uses: actions/upload-artifact@master + with: + name: tonlib-ubuntu-java + path: artifacts \ No newline at end of file diff --git a/.github/workflows/windows2019x64-compile.yml b/.github/workflows/windows2019x64-compile.yml index 65c9a929..43303e65 100644 --- a/.github/workflows/windows2019x64-compile.yml +++ b/.github/workflows/windows2019x64-compile.yml @@ -1,6 +1,10 @@ name: C/C++ CI Windows Server 2019 x64 Compile -on: [push,workflow_dispatch] +on: + workflow_dispatch: + push: + branches: + - 'master' defaults: run: @@ -49,8 +53,8 @@ jobs: cmake -DZLIB_FOUND=1 -DZLIB_INCLUDE_DIR=%root%\zlib -DZLIB_LIBRARY=%root%\zlib\contrib\vstudio\vc14\x64\ZlibStatReleaseWithoutAsm\zlibstat.lib -DOPENSSL_FOUND=1 -DOPENSSL_INCLUDE_DIR=%root%/openssl-1.1/x64/include -DOPENSSL_CRYPTO_LIBRARY=%root%/openssl-1.1/x64/lib/libcrypto.lib -DCMAKE_CXX_FLAGS="/DTD_WINDOWS=1 /EHsc /bigobj /W0" .. - name: Build - run: | - cd build + run: | + cd build cmake --build . --target fift func tonlib tonlibjson tonlib-cli validator-engine lite-client pow-miner validator-engine-console generate-random-id json2tlo dht-server http-proxy rldp-http-proxy adnl-proxy create-state create-hardfork --config Release - name: Show executables @@ -69,6 +73,7 @@ jobs: run: | mkdir artifacts for /f %%a in ('dir *.exe /b /a /s') do copy /Y %%a artifacts + copy build\tonlib\Release\tonlibjson.dll artifacts - name: Upload artifacts uses: actions/upload-artifact@master diff --git a/.github/workflows/windows2019x64-tonlib-java.yml b/.github/workflows/windows2019x64-tonlib-java.yml new file mode 100644 index 00000000..f03212b8 --- /dev/null +++ b/.github/workflows/windows2019x64-tonlib-java.yml @@ -0,0 +1,71 @@ +name: Windows 2019 tonlib-java + +on: + workflow_dispatch: + push: + branches: + - 'wallets' + +defaults: + run: + shell: cmd + +jobs: + build: + + runs-on: windows-2019 + + steps: + - name: Get Current OS version + run: | + systeminfo | findstr /B /C:"OS Name" /C:"OS Version" + - name: Check out current repository + uses: actions/checkout@v2 + with: + submodules: 'recursive' + + - name: Check out zlib repository + uses: actions/checkout@v2 + with: + repository: desktop-app/zlib + path: zlib + + - name: Setup msbuild.exe + uses: microsoft/setup-msbuild@v1.0.2 + + - name: Compile zlib Win64 + run: | + cd zlib\contrib\vstudio\vc14 + msbuild zlibstat.vcxproj /p:Configuration=ReleaseWithoutAsm /p:platform=x64 -p:PlatformToolset=v142 + + - name: Install precompiled OpenSSL Win64 + run: | + curl -Lo openssl-1.1.1o.zip https://github.com/neodiX42/precompiled-openssl-win64/raw/main/openssl-1.1.1o.zip + jar xf openssl-1.1.1o.zip + + - name: Configure & Build + run: | + set JAVA_AWT_LIBRARY=NotNeeded + set JAVA_JVM_LIBRARY=NotNeeded + set JAVA_INCLUDE_PATH=${JAVA_HOME}/include + set JAVA_AWT_INCLUDE_PATH=${JAVA_HOME}/include + set JAVA_INCLUDE_PATH2=${JAVA_HOME}/include/win32 + + set root=%cd% + echo %root% + cd example/android + mkdir build + cd build + cmake -DZLIB_FOUND=1 -DZLIB_INCLUDE_DIR=%root%\zlib -DZLIB_LIBRARY=%root%\zlib\contrib\vstudio\vc14\x64\ZlibStatReleaseWithoutAsm\zlibstat.lib -DOPENSSL_FOUND=1 -DOPENSSL_INCLUDE_DIR=%root%/openssl-1.1/x64/include -DOPENSSL_CRYPTO_LIBRARY=%root%/openssl-1.1/x64/lib/libcrypto.lib -DTON_ONLY_TONLIB=ON -DCMAKE_CXX_FLAGS="/DTD_WINDOWS=1 /EHsc /bigobj /W0" .. + cmake --build . --target native-lib --config Release + + - name: Find & copy binaries + run: | + mkdir tonlib-java + cp example/android/build/Release/native-lib.dll tonlib-java/ + + - name: Upload artifacts + uses: actions/upload-artifact@master + with: + name: tonlib-win64-java + path: tonlib-java diff --git a/doc/tblkch.tex b/doc/tblkch.tex index e8d7f44f..e7b3b195 100644 --- a/doc/tblkch.tex +++ b/doc/tblkch.tex @@ -865,7 +865,7 @@ bit$_ _:(## 1) = Bit; The serialization of source and destination addresses is defined by the following TL-B scheme: \begin{verbatim} addr_none$00 = MsgAddressExt; -addr_extern$01 len:(## 8) external_address:(len * Bit) +addr_extern$01 len:(## 9) external_address:(len * Bit) = MsgAddressExt; anycast_info$_ depth:(## 5) rewrite_pfx:(depth * Bit) = Anycast; addr_std$10 anycast:(Maybe Anycast) diff --git a/doc/tvm.tex b/doc/tvm.tex index 71aa7abc..f5067cc8 100644 --- a/doc/tvm.tex +++ b/doc/tvm.tex @@ -2277,7 +2277,7 @@ The ``global variables'' may be helpful in implementing some high-level smart-co The message and address manipulation primitives listed below serialize and deserialize values according to the following TL-B scheme (cf.~\ptref{sp:tlb.brief}): \begin{verbatim} addr_none$00 = MsgAddressExt; -addr_extern$01 len:(## 8) external_address:(bits len) +addr_extern$01 len:(## 9) external_address:(bits len) = MsgAddressExt; anycast_info$_ depth:(#<= 30) { depth >= 1 } rewrite_pfx:(bits depth) = Anycast; diff --git a/validator/impl/collator.cpp b/validator/impl/collator.cpp index 798e6564..6aedcc21 100644 --- a/validator/impl/collator.cpp +++ b/validator/impl/collator.cpp @@ -3031,9 +3031,9 @@ void Collator::register_new_msgs(block::Transaction& trans) { } /* - * + * * Generate (parts of) new state and block - * + * */ bool store_ext_blk_ref_to(vm::CellBuilder& cb, const ton::BlockIdExt& id_ext, ton::LogicalTime end_lt) { @@ -3166,7 +3166,7 @@ bool Collator::create_mc_state_extra() { " contains an invalid configuration in its data, IGNORING CHANGES"; ignore_cfg_changes = true; } else { - cfg0 = cfg_dict.lookup_ref(td::BitArray<32>(1 - 1)); + cfg0 = cfg_dict.lookup_ref(td::BitArray<32>{(long long) 0}); } bool changed_cfg = false; if (cfg0.not_null()) { @@ -4041,9 +4041,9 @@ void Collator::return_block_candidate(td::Result saved) { } /* - * + * * Collator register methods - * + * */ td::Result Collator::register_external_message_cell(Ref ext_msg, const ExtMessage::Hash& ext_hash) { diff --git a/validator/impl/validate-query.cpp b/validator/impl/validate-query.cpp index 02a16f83..97a4bab9 100644 --- a/validator/impl/validate-query.cpp +++ b/validator/impl/validate-query.cpp @@ -150,9 +150,9 @@ void ValidateQuery::finish_query() { } /* - * + * * INITIAL PARSE & LOAD REQUIRED DATA - * + * */ void ValidateQuery::start_up() { @@ -982,9 +982,9 @@ bool ValidateQuery::check_this_shard_mc_info() { } /* - * + * * METHODS CALLED FROM try_validate() stage 0 - * + * */ bool ValidateQuery::compute_prev_state() { @@ -1844,9 +1844,9 @@ bool ValidateQuery::check_utime_lt() { } /* - * + * * METHODS CALLED FROM try_validate() stage 1 - * + * */ // almost the same as in Collator @@ -4956,7 +4956,7 @@ bool ValidateQuery::check_config_update(Ref old_conf_params, Ref< return reject_query("no important parameters have been changed, but the block is marked as a key block"); } vm::Dictionary dict1{ocfg_root, 32}; - auto param0 = dict1.lookup_ref(td::BitArray<32>{1 - 1}); + auto param0 = dict1.lookup_ref(td::BitArray<32>{(long long) 0}); if (param0.is_null()) { if (cfg_acc_changed) { return reject_query("new state of old configuration smart contract "s + old_cfg_addr.to_hex() + @@ -5431,10 +5431,10 @@ bool ValidateQuery::check_mc_block_extra() { } /* - * + * * MAIN VALIDATOR FUNCTION * (invokes other methods in a suitable order) - * + * */ bool ValidateQuery::try_validate() {