-
Notifications
You must be signed in to change notification settings - Fork 316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue: SIGSEGV on sequential unit tests #1381
Comments
If your CPU has PKU feature you might need to use |
Hi, Changing to use the unprotected platform seems to work around the issue (i.e. setting up platform using running with RUST_BACKTRACE=1 doesn't seem to do anything, am I doing something wrong here?... $ RUST_BACKTRACE=1 cargo test -F individual -- --nocapture
Finished test [unoptimized + debuginfo] target(s) in 0.00s
Running unittests src/lib.rs (target/debug/deps/v8_demo-baa9331bf38bd06c)
running 2 tests
e20f1b29-d86f-4350-8cb9-788511bd0403 Before V8 call_once: false
e20f1b29-d86f-4350-8cb9-788511bd0403 Beginning V8 init
18dbb773-778f-4b0c-a163-c9a977fa60ed Before V8 call_once: false
e20f1b29-d86f-4350-8cb9-788511bd0403 Completed V8 init
e20f1b29-d86f-4350-8cb9-788511bd0403 After V8 call_once: true
18dbb773-778f-4b0c-a163-c9a977fa60ed After V8 call_once: true
error: test failed, to rerun pass `--lib`
Caused by:
process didn't exit successfully: `/mnt/data/projects/Personal/apicize/rust/@apicize/v8-demo/target/debug/deps/v8_demo-baa9331bf38bd06c --nocapture` (signal: 11, SIGSEGV: invalid memory reference) lscpu
|
Thanks for the update. Unfortunately this is as much as I can provide right now - this is what we're using in Deno itself. For the actual program (not tests) we're making sure to initialize V8 platform on the main thread to not hit this problem. |
Thanks for the info. Just wanted to make sure there wasn't something I was messing up on. It seems like this comes down to that V8 expects to be running on the main thread, and if it isn't, we should use new_unprotected_default_platform. Since cargo's test creates a new thread for testing (even with --thread-count set to 1), then this will always be an issue. Also, for anybody coming across this thread, there apparently isn't a straightforward way to figure out if you are running in the primary thread or not. There's a crate that supposedly does this, but it's three years' old. I think the only solution, for now, available to libraries like mine is to document that the application should limit calling the library from the main thread, or provide a fallback option to use new_unprotected_default_platform. This may be worth documenting on the rusty_v8's README |
See: denoland/rusty_v8#1381 and use null pointers when deallocating the context
Hi, I'm encountering an issue running rusty v8, version 0.82.0, on Linux (x86 64 bit). I'm writing a crate library that integrates v8 to implement a scripting feature. I've created a function to execute V8 scripts. In the function, I'm using sync::Once to ensure the platform is initialized only once. After that, I create an isolate, scope, compile code, etc. and it's fine. I can call the function more than once and it all works perfectly.
However, if I have two unit tests that call that function, I get a
SIGSEGV: invalid memory reference
. My first thought was there was some sort of threading issue, but running with--test-threads=1
doesn't help. Below I've included a sample file demonstrating the issue.I don't think I'm doing anything wrong, but I'm a Rust and V8 newbie, so any advice is appreciated. Obviously, writing unit tests to call V8 is a fringe case, but I want to make sure I'm not doing something else that is causing the SIGSEGV's once I release my library.
You can exercise by running the following:
cargo test
# executes two calls to v8 in the same functioncargo test -F individual
# executes two unit tests each calling V8, crashes with SIGSEGVcargo test -F individual -- --test-threads=1
# executes two unit tests each calling V8 with one thread, crashes with SIGSEGVlib.rs
Cargo.toml
Output (two V8 calls in same test function)
Output (two test functions calling V8 once)
Output (two unit test functions calling V8 once)
Output (two unit test functions calling V8 once, single thread)
The text was updated successfully, but these errors were encountered: