Skip to content

Conversation

@sbc100
Copy link
Member

@sbc100 sbc100 commented Dec 6, 2019

This fixes emscripten-core/emscripten#9950.
The issue only shows up when debug names are not present so most of
the changes in CL come from disabling debug names in the lld tests.
We want to make sure that wasm-emscripten-finalize runs fine without
debug names so I think it makes most sense to test in this mode.

The actual bugfix is in wasm-emscripten.cpp as part of the
FixInvokeFunctionNamesWalker. The problem was the name of the function
rather than is import name was being added to importRenames. This means
that when debug names were present (and the two names were the same)
we didn't see the bug.

'-z', '-stack-size=1048576',
obj_path, '-o', wasm_path,
'--allow-undefined',
'--strip-debug',
Copy link
Member

Choose a reason for hiding this comment

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

why strip debug info? I think that's why function names are lost in the new outputs, making it harder to read them (and to compare to before, to understand the patch)

Copy link
Member Author

Choose a reason for hiding this comment

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

Because this bug occurred because we were inadvertently relying on debug names in this pass.

None of the stuff we do in wasm-emscripten-finalize should depend on the debug name section (I think).

Copy link
Member Author

@sbc100 sbc100 Dec 6, 2019

Choose a reason for hiding this comment

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

Hopefully they should become more readable again if we implement #2504... but that might lead to the same kind of sematic bugs I guess... e.g. using a functions name when you meant to refer to its import name

Copy link
Member

Choose a reason for hiding this comment

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

I don't know wasm-emscripten-finalize well enough to know if it depends on function names from the name section or not. cc @jgravelle-google

Copy link
Member Author

Choose a reason for hiding this comment

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

In emscripten -O2 and above we pass --strip-debug to lld which means the binary that wasm-emscripten-finalize sees in those cases doesn't contain any debug name section. This is why this particular bug only shows up at -O2.

What is more I think its important that continue to not depend on debug names so I think both part of this change are warranted.

@sbc100 sbc100 force-pushed the fix_longjump_renameing branch from 9b77469 to 217dc35 Compare December 9, 2019 21:50
Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

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

Makes sense, I agree we should focus on testing the non-debug case.

However it would be nice to not lose coverage for the case where we do have debug names, so that we keep those names around. Maybe adding a little single test in unit/ for that?

@sbc100
Copy link
Member Author

sbc100 commented Dec 10, 2019

Makes sense, I agree we should focus on testing the non-debug case.

However it would be nice to not lose coverage for the case where we do have debug names, so that we keep those names around. Maybe adding a little single test in unit/ for that?

I'm not sure what you mean by loosing coverage? Its seems to me we are increasing coverage by covering modules without debug info. Do you mean that the output is less readable and we are loosing readability of the test output?

@kripken
Copy link
Member

kripken commented Dec 10, 2019

Yes, I mean that in the case that we do build with debug info in emscripten, it would be good if we verified the wasm-emscripten-finalize output has proper names. I guess that ends up tested in emscripten somehow though, e.g. in the stack trace tests.

@sbc100 sbc100 force-pushed the fix_longjump_renameing branch from 217dc35 to 06ad51e Compare December 10, 2019 22:28
@sbc100
Copy link
Member Author

sbc100 commented Dec 10, 2019

OK, I'll limited to use of --strip-debug to just this one test where is required to catch this regression. So now all the other tests still have debug info in them.

This fixes emscripten-core/emscripten#9950.
The issue only shows up when debug names are not present so most of
the changes in CL come from disabling debug names in the lld tests.
We want to make sure that wasm-emscripten-finalize runs fine without
debug names so I think it makes most sense to test in this mode.

The actual bugfix is in wasm-emscripten.cpp as part of the
FixInvokeFunctionNamesWalker.  The problem was the name of the function
rather than is import name was being added to importRenames.  This means
that when debug names were present (and the two names were the same)
we didn't see the bug.
@sbc100 sbc100 force-pushed the fix_longjump_renameing branch from 06ad51e to 9a645a9 Compare December 16, 2019 22:12
@sbc100 sbc100 merged commit f0a2e2c into master Dec 17, 2019
@sbc100 sbc100 deleted the fix_longjump_renameing branch December 17, 2019 18:18
@kripken
Copy link
Member

kripken commented Dec 17, 2019

@sbc100 This breaks emscripten tests on the roller. Disabled autoroll on binaryen for now.

@sbc100
Copy link
Member Author

sbc100 commented Dec 19, 2019

I'm going to revert this and try to re-land once fixed.

sbc100 added a commit that referenced this pull request Dec 19, 2019
sbc100 added a commit that referenced this pull request Dec 19, 2019
sbc100 added a commit that referenced this pull request Dec 19, 2019
In the previous iteration of this change we were not calling
`renameFunctions` for each of the functions we removed.

The problem manifested itself when we rename the imported function to
`emscripten_longjmp_jmpbuf` to `emscripten_longjmp`.  In this case the
import of `emscripten_longjmp` already exists so we remove the import of
`emscripten_longjmp_jmpbuf` but we were not correclty calling
renameFunctions to handle the rename of all the uses.

Add an additional test case to cover the failures that we saw on the
emscripten tree.
sbc100 added a commit that referenced this pull request Dec 19, 2019
In the previous iteration of this change we were not calling
`renameFunctions` for each of the functions we removed.

The problem manifested itself when we rename the imported function to
`emscripten_longjmp_jmpbuf` to `emscripten_longjmp`.  In this case the
import of `emscripten_longjmp` already exists so we remove the import of
`emscripten_longjmp_jmpbuf` but we were not correclty calling
renameFunctions to handle the rename of all the uses.

Add an additional test case to cover the failures that we saw on the
emscripten tree.
kripken pushed a commit that referenced this pull request Dec 19, 2019
sbc100 added a commit that referenced this pull request Dec 21, 2019
* Reland "Fix renaming in FixInvokeFunctionNamesWalker (#2513)"

In the previous iteration of this change we were not calling
`renameFunctions` for each of the functions we removed.

The problem manifested itself when we rename the imported function to
`emscripten_longjmp_jmpbuf` to `emscripten_longjmp`.  In this case the
import of `emscripten_longjmp` already exists so we remove the import of
`emscripten_longjmp_jmpbuf` but we were not correclty calling
renameFunctions to handle the rename of all the uses.

Add an additional test case to cover the failures that we saw on the
emscripten tree.
sbc100 added a commit that referenced this pull request Jan 7, 2020
sbc100 added a commit that referenced this pull request Jan 8, 2020
sbc100 added a commit to emscripten-core/emscripten that referenced this pull request Jan 14, 2020
This is a partial revert of #9750.

The binaryen change that was designed to allow this to work was
reverted: WebAssembly/binaryen#2513
sbc100 added a commit to emscripten-core/emscripten that referenced this pull request Jan 14, 2020
This is a partial revert of #9750.

The binaryen change that was designed to allow this to work was
reverted: WebAssembly/binaryen#2513
sbc100 added a commit to emscripten-core/emscripten that referenced this pull request Jan 15, 2020
This is a partial revert of #9750.

The binaryen change that was designed to allow this to work was
reverted: WebAssembly/binaryen#2513
sbc100 added a commit that referenced this pull request Jan 24, 2020
sbc100 added a commit that referenced this pull request Jan 24, 2020
sbc100 added a commit that referenced this pull request Jan 24, 2020
This reverts commit 132daae.

This change is the same as before but the fix in #2619 should now make it safe.
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.

GOT.func entry with no import/export: $emscripten_longjmp_jmpbuf

2 participants