Skip to content

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 3 commits into from
May 21, 2013

Conversation

inolen
Copy link
Collaborator

@inolen inolen commented May 20, 2013

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?

@@ -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';
Copy link
Member

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)

@inolen
Copy link
Collaborator Author

inolen commented May 21, 2013

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
@kripken kripken merged commit bf07641 into emscripten-core:incoming May 21, 2013
@inolen inolen deleted the longjmp_signed branch May 21, 2013 22:45
sbc100 added a commit that referenced this pull request Mar 4, 2023
This is needed as of #18638 since dynlink.c is not longer included
in the build when MAIN_MODULE is not set.

Fixes: #1195
sbc100 added a commit that referenced this pull request Mar 4, 2023
This is needed as of #18638 since dynlink.c is not longer included
in the build when MAIN_MODULE is not set.

Fixes: #1195
sbc100 added a commit that referenced this pull request Mar 6, 2023
This is needed as of #18638 since dynlink.c is not longer included
in the build when MAIN_MODULE is not set.

Fixes: #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
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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants