-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Adding multiple callbacks causes Err(Exception(String("SyntaxError: stack overflow")))
#66
Comments
Somehow I misdiagnosed the issue:
To:
It works. I am not sure why, but calling unwrap fixes the issue. |
Can you post a full reproduction of the error? Using your |
I don't have the offending code anymore, sorry. Perhaps it was an environmental issue. I did code it late at night, so it's not out of the question that I missed something. |
Let's hope so. Feel free to reopen if you stumble over it again. |
I have ran into the same issue. fn main() {
let ctx = make_context().unwrap();
ctx.eval("").unwrap();
}
fn make_context() -> anyhow::Result<quick_js::Context> {
let ctx = quick_js::Context::new()?;
ctx.add_callback("f", |_: i32| quick_js::JsValue::Undefined)?;
ctx.add_callback("g", |_: i32| quick_js::JsValue::Undefined)?;
Ok(ctx)
}
After some debugging, this is actually a solved issue. diff -urN quickjs-2019-07-28/quickjs.c quickjs-2019-07-28-stack-overflow-signed/quickjs.c
--- quickjs-2019-07-28/quickjs.c 2019-07-28 15:03:03.000000000 +0000
+++ quickjs-2019-07-28-stack-overflow-signed/quickjs.c 2019-08-09 20:00:03.666846091 +0000
@@ -1732,9 +1732,9 @@
static inline BOOL js_check_stack_overflow(JSContext *rt, size_t alloca_size)
{
- size_t size;
+ ptrdiff_t size;
size = rt->stack_top - js_get_stack_pointer();
- return unlikely((size + alloca_size) > rt->stack_size);
+ return unlikely((size + (ptrdiff_t)alloca_size) > (ptrdiff_t)rt->stack_size);
}
#endif The issue is that this patch is not applied by default. After enabling the |
@SirJosh3917 In order to ignore the check entirely you could just call JS_SetMaxStackSize with u64::MAX (which is what i did before i used JS_UpdateStackTop) I stumbled upon this in #92 and fixed it here HiRoFa/quickjs_es_runtime#50 |
If I add multiple callbacks and then call
ctx.eval(...)
, no matter what I put in theeval
statement, it causes a fatal error:Err(Exception(String("SyntaxError: stack overflow")))
. See the following example to reproduce.Causes the following error:
This error shows up no matter what I put in
ctx.eval("...")
, unless I limit the calls toadd_callback(...)
to 1. Is there a limit of one callback?The text was updated successfully, but these errors were encountered: