-
Notifications
You must be signed in to change notification settings - Fork 3.4k
trigger setjmp on negative values #1195
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -1488,7 +1488,7 @@ function JSify(data, functionsOnly, givenFunctions) { | |||
if (ASM_JS && funcData.setjmpTable) { | |||
// check if a longjmp was done. If a setjmp happened, check if ours. If ours, go to -111 to handle it. | |||
// otherwise, just return - the call to us must also have been an invoke, so the setjmp propagates that way | |||
ret += '; if (((__THREW__|0) != 0) & ((threwValue|0) > 0)) { setjmpLabel = ' + asmCoercion('_testSetjmp(' + makeGetValue('__THREW__', 0, 'i32') + ', setjmpTable)', 'i32') + '; if ((setjmpLabel|0) > 0) { label = -1111; break } else return ' + (funcData.returnType != 'void' ? asmCoercion('0', funcData.returnType) : '') + ' } __THREW__ = threwValue = 0;\n'; | |||
ret += '; if (((__THREW__|0) != 0) & (threwValue|0)) { setjmpLabel = ' + asmCoercion('_testSetjmp(' + makeGetValue('__THREW__', 0, 'i32') + ', setjmpTable)', 'i32') + '; if ((setjmpLabel|0) > 0) { label = -1111; break } else return ' + (funcData.returnType != 'void' ? asmCoercion('0', funcData.returnType) : '') + ' } __THREW__ = threwValue = 0;\n'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is potentially wrong. The left side is a boolean, so 0 or 1 in effect, and we do &
with threwValue. If threwValue is even, and the left side is 1, then 2 & 1 will give 0. (this is bitwise &, not logical)
Converted the check back to a boolean expression and pushed. |
kripken
added a commit
that referenced
this pull request
May 21, 2013
trigger setjmp on negative values
sbc100
added a commit
that referenced
this pull request
Mar 6, 2023
impact-maker
pushed a commit
to impact-maker/emscripten
that referenced
this pull request
Mar 17, 2023
This is needed as of emscripten-core#18638 since dynlink.c is not longer included in the build when MAIN_MODULE is not set. Fixes: emscripten-core#1195
impact-maker
pushed a commit
to impact-maker/emscripten
that referenced
this pull request
Mar 17, 2023
This is needed as of emscripten-core#18638 since dynlink.c is not longer included in the build when MAIN_MODULE is not set. Fixes: emscripten-core#1195
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As the title says, this makes it so that setjmp is properly triggered when longjmp is called with a negative value.
Are there any other places in the code that may also assume that the value is unsigned?