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

Unhandled fatal error causes stack overflow #9

Closed
tcosprojects opened this issue Mar 27, 2020 · 1 comment
Closed

Unhandled fatal error causes stack overflow #9

tcosprojects opened this issue Mar 27, 2020 · 1 comment

Comments

@tcosprojects
Copy link

When testing JS errors I found that there is not a clear way to handle this error without the program crashing.

Rust code:

use ducc::{Ducc, ExecSettings};

fn main() {
    let ducc = Ducc::new();
    ducc.exec("throw 'test'", None, ExecSettings::default()).unwrap()
}

Running this code on rust 1.42.0 stable-i686-pc-windows-msvc results in:

     Running `target\debug\ducctest.exe`
fatal error from duktape: uncaught: 'cannot write property [Symbol hidden \x27?error\x27] of \x27test\x27'
error: process didn't exit successfully: `target\debug\ducctest.exe` (exit code: 0xc0000409, STATUS_STACK_BUFFER_OVERRUN)

Is there another way to wrap exec so that these errors can be handled? Thank you.

@SkylerLipthay
Copy link
Owner

SkylerLipthay commented Mar 27, 2020

Oh nice catch! The error handling logic was not accounting for cases where the thrown error was a non-object. This has been fixed in 9c1beda and published on crates.io @ version 0.1.4.

Hopefully this fix is good enough for your current purposes. Unfortunately the Error that you'll get from ducc.exec("throw 'test'", ...) is just a generic one, with no visibility into 'test'. While writing mini-v8 (this crate except with V8 instead of Duktape) I discovered it was ergonomic to have an Error::Value variant so the exec caller could see—in your case—Value::String("test"). This sort of error handling should probably be ported back into ducc.

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