diff options
author | Heejin Ahn <aheejin@gmail.com> | 2021-08-08 21:16:55 -0700 |
---|---|---|
committer | Heejin Ahn <aheejin@gmail.com> | 2021-08-12 16:32:46 -0700 |
commit | adb96d2e76ce0c9b9e5a51a4e3dfd2c4efa4c3c3 (patch) | |
tree | 0d743ab2ee9976cc108bf6ca3578c1383049b990 /llvm/lib/CodeGen/SplitKit.cpp | |
parent | aca198cf748e32205a835fba2d6d68f95ba1dfdd (diff) | |
download | llvm-adb96d2e76ce0c9b9e5a51a4e3dfd2c4efa4c3c3.zip llvm-adb96d2e76ce0c9b9e5a51a4e3dfd2c4efa4c3c3.tar.gz llvm-adb96d2e76ce0c9b9e5a51a4e3dfd2c4efa4c3c3.tar.bz2 |
[WebAssembly] Fix leak in Emscripten SjLj
For SjLj, we allocate a table to record setjmp buffer info in the entry
of each setjmp-calling function by inserting a `malloc` call, and insert
a `free` call to free the buffer before each `ret` instruction.
But this is not sufficient; we have to free the buffer before we throw.
In SjLj handling, normal functions that can possibly throw or longjmp
are wrapped with an invoke and caught within the function so they don't
end up escaping the function. But three functions throw and escape the
function:
- `__resumeException` (Emscripten library function used for Emscripten
EH)
- `emscripten_longjmp` (Emscripten library function used for Emscripten
SjLj)
- `__cxa_throw` (libc++abi function called when for C++ `throw` keyword)
The first two functions are used to rethrow the current
exception/longjmp when the caught exception/longjmp is not for the
current function. `__cxa_throw` is used for exception, and because we
consider that a function that cannot longjmp, it escapes the function
right away, before which we should free the buffer.
Currently `lsan.test_longjmp3` and `lsan.test_exceptions_longjmp3` fail
in Emscripten; this CL fixes these.
Reviewed By: dschuff
Differential Revision: https://reviews.llvm.org/D107852
Diffstat (limited to 'llvm/lib/CodeGen/SplitKit.cpp')
0 files changed, 0 insertions, 0 deletions