Draft: start to implement emscripten_return_address for UBSan support #420
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.
This isn't really a pull request in the traditional sense, but I figure it will be easier to ask my question this way.
My goal is to compile a WASM executable with emscripten+UBSan (https://emscripten.org/docs/debugging/Sanitizers.html) and then run it in wasm3, showing a backtrace if anything is triggered.
I took the
null-assign.c
from the page:Built it with the minimal UBSan runtime:
And I get null-assign.wasm.
I figured out that I need to set some preprocessor definitions to enable the call stack and trace output:
-Dd_m3EnableStrace=2 -Dd_m3RecordBacktraces
. Additionally I added my own-Dd_m3HasUBSan
and implemented a stubemscripten_return_address
(the function that the UBSan runtime needs).Everything looks 'fine' from the trace (except obviously the
1234
value for the return address which triggers another check):The issue is at the end, it looks like it is not able to match the PC register back to an offset in the file. Any ideas why? I tried messing with the
emscripten_return_address
function signature but it doesn't appear to make a difference...