Skip to content

Fix Error.stackTraceLimit = Infinity#861

Merged
saghul merged 7 commits intoquickjs-ng:masterfrom
ammarahm-ed:fix-stacktracelimit
Jan 31, 2025
Merged

Fix Error.stackTraceLimit = Infinity#861
saghul merged 7 commits intoquickjs-ng:masterfrom
ammarahm-ed:fix-stacktracelimit

Conversation

@ammarahm-ed
Copy link
Copy Markdown
Contributor

Closes #858

Comment thread quickjs.c Outdated
@ammarahm-ed
Copy link
Copy Markdown
Contributor Author

ammarahm-ed commented Jan 29, 2025

It seems that this works on mac but fails on Linux and Windows.

@saghul
Copy link
Copy Markdown
Contributor

saghul commented Jan 29, 2025

Yes it seems like you'll have to go back to explicitly testing for infinity.

@ammarahm-ed
Copy link
Copy Markdown
Contributor Author

@saghul can you start the tests again

Comment thread quickjs.c Outdated
Comment thread quickjs.c Outdated
Comment thread tests/bug858.js Outdated
@ammarahm-ed
Copy link
Copy Markdown
Contributor Author

Hey @saghul I didn't look closely at your diff in review, fixed now and all tests now pass.

@saghul
Copy link
Copy Markdown
Contributor

saghul commented Jan 31, 2025

On a second thought, if we want to 100% mimic how v8 behaves we should store the JSValue and extract it when necessary.

Right now if you set it to -Infinity you'll get back 0, whereas Chrome gets you back the same value you set.

Thoughts @bnoordhuis ?

@bnoordhuis
Copy link
Copy Markdown
Contributor

That means calling JS_ToFloat64, which can throw an exception, when we're already in an exception state. What is the expected behavior of this?

Error.stackTraceLimit = {valueOf(){ throw "evil" }}
try{ throw new Error("fail") }
catch(e){ console.log(e) } // "fail" or "evil"?

@saghul
Copy link
Copy Markdown
Contributor

saghul commented Jan 31, 2025

I Node one gets "fail". We do save the previous exception not to clobber it, so it seems like we should be good to do that?

@bnoordhuis
Copy link
Copy Markdown
Contributor

Yeah, that seems reasonable. Let's follow what node/chrome do then.

FWIW, I'm okay with landing this PR as-is and then one of us doing a follow-up fix-up.

@saghul saghul merged commit eab8251 into quickjs-ng:master Jan 31, 2025
@saghul
Copy link
Copy Markdown
Contributor

saghul commented Jan 31, 2025

Sounds good! I can work on it.

@ammarahm-ed ammarahm-ed deleted the fix-stacktracelimit branch February 8, 2025 05:00
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

Successfully merging this pull request may close these issues.

Error.stackTraceLimit = Infinity results in empty stacktrace in errors.

3 participants