Skip to content
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

Fatal error when calling v8::Script::compile with Linux #519

Closed
vmosone opened this issue Nov 6, 2020 · 2 comments
Closed

Fatal error when calling v8::Script::compile with Linux #519

vmosone opened this issue Nov 6, 2020 · 2 comments

Comments

@vmosone
Copy link

vmosone commented Nov 6, 2020

Env:
centOs v8.2 / Linux iZj6cj1nogjvovnnassc7zZ 4.18.0-193.14.2.el8_2.x86_64 #1 SMP Sun Jul 26 03:54:29 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

nightly-x86_64-unknown-linux-gnu (default)
rustc 1.49.0-nightly (9d78d1d02 2020-11-05)

Build from source of rusty_v8 v0.12.0

Crash info:
Fatal error when calling v8::Script::compile. But, The same code runs successfully under Windows10.

#
# Fatal error in ../../../v8/src/codegen/compiler.cc, line 1266
# Debug check failed: ThreadId::Current() == isolate->thread_id() (<unprintable> vs. <unprintable>).
#
#
#
#FailureMessage Object: 0x7f07ccda7f00
==== C stack trace ===============================

    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x186f493) [0x557e9af8a493]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x817f9d) [0x557e99f32f9d]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x813bb3) [0x557e99f2ebb3]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x8134a5) [0x557e99f2e4a5]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x90968d) [0x557e9a02468d]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x90bce5) [0x557e9a026ce5]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x90afa6) [0x557e9a025fa6]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x88de70) [0x557e99fa8e70]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x88e7f0) [0x557e99fa97f0]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x80363f) [0x557e99f1e63f]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x7fa690) [0x557e99f15690]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x7cd5da) [0x557e99ee85da]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x7cb27f) [0x557e99ee627f]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x439b0a) [0x557e99b54b0a]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x3cddea) [0x557e99ae8dea]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x4723c6) [0x557e99b8d3c6]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x465665) [0x557e99b80665]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x3dcbe9) [0x557e99af7be9]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x1c1a63) [0x557e998dca63]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x1b9fe8) [0x557e998d4fe8]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x344b95) [0x557e99a5fb95]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x2278a8) [0x557e999428a8]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x22dc52) [0x557e99948c52]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x2302ed) [0x557e9994b2ed]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x22b47d) [0x557e9994647d]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x228798) [0x557e99943798]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x341ddc) [0x557e99a5cddc]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x27d11e) [0x557e9999811e]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x22a318a) [0x557e9b9be18a]
    /lib64/libpthread.so.0(+0x82de) [0x7f07cdef92de]
    /lib64/libc.so.6(clone+0x43) [0x7f07cd8a8e83]
error: test failed, to rerun pass '-p vm_core --test test_v8'

Caused by:
  process didn't exit successfully: `/opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d test_vm_run --exact --nocapture` (signal: 4, SIGILL: illegal instruction)

Similar error,fails at similar assertions:
Code slice:

...
let platform = v8::new_default_platform().unwrap();
    v8::V8::initialize_platform(platform);
    v8::V8::initialize();
    v8::V8::set_flags_from_command_line(vec![
        "".to_string(),
        "--no-wasm-async-compilation".to_string(),
        "--harmony-top-level-await".to_string(),
        "--expose-gc".to_string(),
    ]);

    let mut creator = v8::SnapshotCreator::new(Some(&EXTERNAL_REFERENCES));
    let mut template_isolate = unsafe { creator.get_owned_isolate() };
    {
        let scope = &mut v8::HandleScope::new(&mut template_isolate);

        let context = v8::Context::new(scope);
        let scope = &mut v8::ContextScope::new(scope, context);

        let global = context.global(scope);
        let function = v8::FunctionTemplate::new(scope, print);
        let key = v8::String::new(scope, "print").unwrap();
        let value = function.get_function(scope).unwrap();
        global.set(scope, key.into(), value.into());

        creator.set_default_context(context);

        let code = v8::String::new(scope, r#"
                    var func = function(len) {
                            var buf = new ArrayBuffer(len);
                            this.gc(); func;
                        };
                "#).unwrap();

        let mut script = v8::Script::compile(scope, code, None).unwrap();
        let result = script.run(scope).unwrap();
        let result = result.to_string(scope).unwrap();
    }

    thread::spawn(move || {
        let startup_data = creator.create_blob(v8::FunctionCodeHandling::Keep).unwrap();

        let mut params = v8::Isolate::create_params().external_references(&**EXTERNAL_REFERENCES);
        params = params.snapshot_blob(startup_data);
        let mut isolate = v8::Isolate::new(params);

        let scope = &mut v8::HandleScope::new(&mut isolate);

        let context = v8::Context::new(scope);
        let global = context.global(scope);

        let scope = &mut v8::ContextScope::new(scope, context);

        let key = v8::String::new(scope, "x").unwrap();
        let value = v8::String::new(scope, "Hello World").unwrap();
        global.set(scope, key.into(), value.into());

        let code = v8::String::new(scope, r#"
                func(10);
                this.gc();
                func;
            "#).unwrap();

        let mut script = v8::Script::compile(scope, code, None).unwrap();
        let result = script.run(scope).unwrap();
        let result = result.to_string(scope).unwrap();
    });
...

Crash info:

#
# Fatal error in ../../../v8/src/execution/isolate.cc, line 3732
# Debug check failed: (CurrentPerIsolateThreadData()) != nullptr.
#
#
#
#FailureMessage Object: 0x7f508bffdb70
==== C stack trace ===============================

    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x186f493) [0x55d7e0648493]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x817f9d) [0x55d7df5f0f9d]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x813bb3) [0x55d7df5ecbb3]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x8134a5) [0x55d7df5ec4a5]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0xa0bf2d) [0x55d7df7e4f2d]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x87f1b4) [0x55d7df6581b4]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x804515) [0x55d7df5dd515]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x7eb99b) [0x55d7df5c499b]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x3f210f) [0x55d7df1cb10f]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x28222f) [0x55d7df05b22f]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x1c1895) [0x55d7def9a895]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x1b9f97) [0x55d7def92f97]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x344565) [0x55d7df11d565]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x2278d5) [0x55d7df0008d5]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x22d92b) [0x55d7df00692b]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x2302ed) [0x55d7df0092ed]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x22b358) [0x55d7df004358]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x228837) [0x55d7df001837]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x342a16) [0x55d7df11ba16]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x27cf7e) [0x55d7df055f7e]
    /opt/pi_v8_dev/target/debug/deps/test_v8-c8c647757502fb8d(+0x22a318a) [0x55d7e107c18a]
    /lib64/libpthread.so.0(+0x82de) [0x7f50912c42de]
    /lib64/libc.so.6(clone+0x43) [0x7f5090c73e83]
error: test failed, to rerun pass '-p vm_core --test test_v8'
@vmosone vmosone changed the title Fatal error when calling v8::Script::compile Fatal error when calling v8::Script::compile with Linux Nov 6, 2020
@bnoordhuis
Copy link
Contributor

That's probably the same issue as #486 (comment). Summary: rusty_v8 doesn't currently expose v8::Locker to ensure proper thread state management.

As a workaround try removing the thread::spawn().

@vmosone
Copy link
Author

vmosone commented Nov 13, 2020

To verify that this problem is caused by multiple threads, thank you for your help

@vmosone vmosone closed this as completed Nov 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants