-
Notifications
You must be signed in to change notification settings - Fork 49
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
Stack overflow weirdness #92
Comments
Ok so the problem has to do with the stack_size checking of quickjs, this happens in quickjs.c in the js_check_stack_overflow method it used the js_get_stack_pointer method to check the current stack pointer and compares that to the pointer stored in JSRuntime which also uses the js_get_stack_pointer method when it is initialized. at a certain moment the js_get_stack_pointer method returns a number lower then what is was when the runtime was initialized and because it's a unsigned int i've added a printf to do some debugging
this outputs the following
and now.. .to figure out how to fix it.. :) |
figured it out after reading up on some basic stack vs heap knowledge (https://doc.rust-lang.org/1.22.0/book/first-edition/the-stack-and-the-heap.html) it seems initializing a runtime in a function is a bad idea because in the init method, and certainly after doing a pintln!("sdgf") the current stack frame is higher then what it's going to be when calling a method later.. so initializing a JSRuntime should be the first thing to do when starting a thread which acts as your event queue... |
So i've been busy lately wrapping quickjs-rs in my own project and every now and then i got unexpected stack-overflows which seemed to appear and disappear quite randomly.
Now i've finally reproduced that behaviour in a small program and stuff just got weirder...
my cargo.toml, with a ref to my own quickjs-rs branch which has the latest quickjs version (please note that the 0.8.0 release had the same issues)
main.rs
In this case i'm throwing an error from a function, please note that i've had the same issue when Promises we're dropped
When running this with
cargo run
i get the following outputSo the JS_Call throws a Exception as expected bu the message of the exception is
stack overflow
Now for the weird, if i run the same code with
cargo run --release
i get the error and output i expectedAnd now for the really weird, if i remove the
println!("creating new QuickJsRuntime");
line before creating the runtime i also get the output i expectedAnyone out there having similar issues or have any idea what's going on here?
The text was updated successfully, but these errors were encountered: