diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index fca7b83..fc27b2c 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -27,7 +27,7 @@ jobs: make release-linux - name: Push artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: libgo_owasm.so path: api/libgo_owasm.so @@ -44,7 +44,7 @@ jobs: make release-osx - name: Push artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: libgo_owasm.dylib path: api/libgo_owasm.dylib @@ -60,13 +60,13 @@ jobs: uses: actions/checkout@v3 - name: Download libgo_owasm.so - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: libgo_owasm.so path: api - name: Download libgo_owasm.dylib - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: libgo_owasm.dylib path: api diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9367659..bdaea82 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -11,7 +11,7 @@ jobs: - name: Install Rust and rust toolchain uses: actions-rs/toolchain@v1 with: - toolchain: stable + toolchain: 1.76 override: true - name: Install Go diff --git a/api/libgo_owasm.dylib b/api/libgo_owasm.dylib index 6013e1a..65c3d0c 100644 Binary files a/api/libgo_owasm.dylib and b/api/libgo_owasm.dylib differ diff --git a/api/libgo_owasm.so b/api/libgo_owasm.so index 47650bb..596c53a 100644 Binary files a/api/libgo_owasm.so and b/api/libgo_owasm.so differ diff --git a/go.mod b/go.mod index a114df1..5b26407 100644 --- a/go.mod +++ b/go.mod @@ -7,5 +7,5 @@ require github.com/stretchr/testify v1.6.1 require ( github.com/davecgh/go-spew v1.1.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index afe7890..b624904 100644 --- a/go.sum +++ b/go.sum @@ -7,5 +7,6 @@ github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/libgo_owasm/Cargo.lock b/libgo_owasm/Cargo.lock index c2c208a..c8a7fe4 100644 --- a/libgo_owasm/Cargo.lock +++ b/libgo_owasm/Cargo.lock @@ -8,7 +8,12 @@ version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" dependencies = [ + "cpp_demangle", + "fallible-iterator", "gimli", + "object 0.27.1", + "rustc-demangle", + "smallvec", ] [[package]] @@ -17,6 +22,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "adler2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" + [[package]] name = "ahash" version = "0.7.6" @@ -70,7 +81,7 @@ dependencies = [ "cc", "cfg-if", "libc", - "miniz_oxide", + "miniz_oxide 0.5.3", "object 0.29.0", "rustc-demangle", ] @@ -185,7 +196,16 @@ dependencies = [ "cfg-if", "libc", "scopeguard", - "windows-sys", + "windows-sys 0.33.0", +] + +[[package]] +name = "cpp_demangle" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eeaa953eaad386a53111e47172c2fedba671e5684c8dd601a5f474f4f118710f" +dependencies = [ + "cfg-if", ] [[package]] @@ -404,6 +424,16 @@ dependencies = [ "instant", ] +[[package]] +name = "flate2" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843fba2746e448b37e26a819579957415c8cef339bf08564fe8b7ddbd959573c" +dependencies = [ + "crc32fast", + "miniz_oxide 0.8.9", +] + [[package]] name = "fnv" version = "1.0.7" @@ -444,7 +474,7 @@ dependencies = [ [[package]] name = "go-owasm" -version = "0.2.2" +version = "0.3.2" dependencies = [ "cbindgen", "failure", @@ -493,6 +523,15 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "home" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" +dependencies = [ + "windows-sys 0.48.0", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -634,6 +673,16 @@ dependencies = [ "adler", ] +[[package]] +name = "miniz_oxide" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" +dependencies = [ + "adler2", + "simd-adler32", +] + [[package]] name = "more-asserts" version = "0.2.2" @@ -668,6 +717,16 @@ dependencies = [ "libc", ] +[[package]] +name = "object" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9" +dependencies = [ + "flate2", + "memchr", +] + [[package]] name = "object" version = "0.28.4" @@ -703,9 +762,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "owasm-crypto" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaf6981f8e30eb028bd0c1eeb72d63a9d80b2da5624f1fe03783a10bc985fa50" +checksum = "54e0449a6a19910fe5b719df3f23027c830e93a08eafd81fec043c751974a922" dependencies = [ "hex", "lazy_static", @@ -716,14 +775,19 @@ dependencies = [ [[package]] name = "owasm-vm" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47b8c495d216e034cfae5abb0f797cf88ddf6fac0b01490d1cd124304cf81501" +checksum = "44dfb5cfd04f082ae2cfee2e3db65228f767aaec8d1b71cb76c8c802ddd0d64a" dependencies = [ + "addr2line", "assert_matches", + "backtrace", "clru", "hex", + "home", "owasm-crypto", + "rayon", + "rayon-core", "sha2", "tempfile", "wasm-instrument", @@ -986,6 +1050,12 @@ dependencies = [ "opaque-debug", ] +[[package]] +name = "simd-adler32" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "703d5c7ef118737c72f1af64ad2f6f8c5e1921f818cdcb97b8fe6fc69bf66214" + [[package]] name = "smallvec" version = "1.9.0" @@ -1515,39 +1585,105 @@ version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43dbb096663629518eb1dfa72d80243ca5a6aca764cae62a2df70af760a9be75" dependencies = [ - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_msvc", + "windows_aarch64_msvc 0.33.0", + "windows_i686_gnu 0.33.0", + "windows_i686_msvc 0.33.0", + "windows_x86_64_gnu 0.33.0", + "windows_x86_64_msvc 0.33.0", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets", ] +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + [[package]] name = "windows_aarch64_msvc" version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd761fd3eb9ab8cc1ed81e56e567f02dd82c4c837e48ac3b2181b9ffc5060807" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + [[package]] name = "windows_i686_gnu" version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cab0cf703a96bab2dc0c02c0fa748491294bf9b7feb27e1f4f96340f208ada0e" +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + [[package]] name = "windows_i686_msvc" version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8cfdbe89cc9ad7ce618ba34abc34bbb6c36d99e96cae2245b7943cd75ee773d0" +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + [[package]] name = "windows_x86_64_gnu" version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4dd9b0c0e9ece7bb22e84d70d01b71c6d6248b81a3c60d11869451b4cb24784" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + [[package]] name = "windows_x86_64_msvc" version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff1e4aa646495048ec7f3ffddc411e1d829c026a2ec62b39da15c1055e406eaa" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" diff --git a/libgo_owasm/Cargo.toml b/libgo_owasm/Cargo.toml index cda0515..38a19dc 100644 --- a/libgo_owasm/Cargo.toml +++ b/libgo_owasm/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "go-owasm" -version = "0.2.2" +version = "0.3.2" authors = ["Sorawit Suriyakarn "] edition = "2021" @@ -14,7 +14,7 @@ path = "src/lib.rs" crate-type = ["staticlib"] [dependencies] -owasm-vm = "0.3.1" +owasm-vm = "0.3.2" failure = "0.1.6" [build-dependencies] diff --git a/libgo_owasm/src/lib.rs b/libgo_owasm/src/lib.rs index 2a53d45..55609d7 100644 --- a/libgo_owasm/src/lib.rs +++ b/libgo_owasm/src/lib.rs @@ -7,7 +7,7 @@ use env::{Env, RunOutput}; use span::Span; use failure::{bail, Error as FailureError}; -use std::panic::catch_unwind; +use std::panic::{catch_unwind, AssertUnwindSafe}; use owasm_vm; use owasm_vm::cache::{Cache, CacheOptions}; @@ -73,12 +73,16 @@ pub extern "C" fn do_run( ) -> Error { if !cache.is_null() { let vm_querier = vm::VMQuerier::new(env); - match owasm_vm::run(to_cache(cache).unwrap(), code.read(), gas_limit, is_prepare, vm_querier) { - Ok(gas_used) => { + let result = catch_unwind(AssertUnwindSafe(|| { + owasm_vm::run(to_cache(cache).unwrap(), code.read(), gas_limit, is_prepare, vm_querier) + })); + match result { + Ok(Ok(gas_used)) => { output.gas_used = gas_used; Error::NoError } - Err(e) => e, + Ok(Err(e)) => e, + Err(_) => Error::RuntimeError, // panic → safe error } } else { Error::UnknownError