-
Notifications
You must be signed in to change notification settings - Fork 119
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
[Question] Incorrect line when throwing string #799
Comments
What engine/commit is that? bellard/quickjs@...? And what API did you use to obtain that stack trace? |
Yes, Bellard's one. |
You're patching quickjs.c so I suspect it's something on your side. I don't think bellard/master and quickjs-ng have diverged in that respect. |
I tried applying the patch on top of vanilla master and then run git bisect with those changes. |
Can you demonstrate the issue with an unmodified copy of quickjs? Because I'd be happy to take a look in that case. |
That lead us to the second issue - QuickJS does not record stack trace when throwing primitive types. |
Consider this script that throws an uncaught exception: function f() { throw "fail" } f() Running with `qjs --script t.js` used to print merely: fail But now prints: fail at f (t.js:2:11) at f (t.js:4:1) qjs has been updated but no public API yet because I still need to think through the corner cases. Refs: quickjs-ng#799
I'm aware - I wrote that code for node circa 2010, 2011 :-) Recording the stack trace for primitives: I opened #805. It's not perfect yet but it's 80% there. |
Looks promising! I'll try updating out code to extract backtrace from the new variable and see it it works in our tests. |
That works, thanks! And the lines are correct now, as they were. |
The reason I added it to node back then is because people sometimes throw what they think is an exception object but isn't, and that's very hard to debug when you don't get a stack trace. It's a quality-of-life improvement. |
Ah I can see how that makes sense! How did you do that? |
In node? Honestly, I don't remember, too long ago. It's possible V8 already had an API for it but maybe I added one. |
Consider this script that throws an uncaught exception: function f() { throw "fail" } f() Running with `qjs --script t.js` used to print merely: fail But now prints: fail at f (t.js:2:11) at f (t.js:4:1) qjs has been updated but no public API yet because I still need to think through the corner cases. Refs: quickjs-ng#799
Let's say I have a file test.js
Now I call JS_EvalThis on this piece of code and get a backtrace
When changing the line to
new throw Error("fail1");
, I get test.js:4:19, as expected.In order to catch strings as errors, we added a wrapper to turn them into Errors like this https://github.com/qbs/quickjs-ng/blob/qbs/quickjs.c#L17483-L17489
This used to be working with the old engine. From what I debugged, find_line_num can't guess the line anymore.
Am I doing this wrong?
The text was updated successfully, but these errors were encountered: