Skip to content
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

Handle bytecode without IC state #617

Merged
merged 3 commits into from
Oct 24, 2024
Merged

Conversation

bnoordhuis
Copy link
Contributor

I split this into three commits. The second one segfaults, the third one fixes that.

Interestingly, starting qjs in REPL mode segfaulted but the other bytecode tests we have don't. Not quite sure what's up with that but bc->ic not pointing to anything was definitely the issue though.

I added two (for now undocumented) options to std.evalScript that may be useful in their own right.

@bnoordhuis
Copy link
Contributor Author

Interesting...

/Users/runner/work/quickjs/quickjs/quickjs.c:35019:21: runtime error: applying non-zero offset 27 to null pointer

I do believe ubsan is unearthing a (pre-existing) bug here.

Copy link
Contributor

@saghul saghul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I also like you added those flags, I was planning on adding them myself to implement standalone executables in JS :-P

@bnoordhuis
Copy link
Contributor Author

I'll squash the 2nd and 3rd commit (don't want to break git bisect) and land this as three commits.

UBSan is right to complain that `s->ptr_last == NULL` when tracing is
disabled.
Don't raise a "invalid tag 12" exception when encountering bytecode
and JS_READ_OBJ_BYTECODE is not set, because no one knows what "tag 12"
means without looking it up, not even quickjs maintainers.
Deserialized bytecode does not have IC state, i.e., `bc->ic == NULL`.
That may or may not be bug (IMO, it is and we should rebuild the
IC state during deserialization) but, either way, don't segfault.

DRY add_ic_slot() and its call sites in a hopefully NFC manner.
@bnoordhuis bnoordhuis merged commit caa1bf5 into quickjs-ng:master Oct 24, 2024
16 checks passed
@bnoordhuis bnoordhuis deleted the fix-ic-bug branch October 24, 2024 07:11
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants