Repository navigation
Default to EXIT_RUNTIME=1 when building with ASan - #15083
Conversation
19a5f12 to
1e5568d
Compare
7dfafca to
745e1bb
Compare
Good question. I'd say that if we know an allocation is ok to leak, then just calling |
| if settings.HAS_MAIN: | ||
| code = shared.do_replace(code, '<<< ATMAINS >>>', str(forwarded_json['ATMAINS'])) | ||
| if settings.EXIT_RUNTIME: | ||
| if settings.EXIT_RUNTIME and (not settings.MINIMAL_RUNTIME or settings.HAS_MAIN): |
There was a problem hiding this comment.
I don't follow this part of the change?
There was a problem hiding this comment.
This is need for asan.test_fs_no_main_minimal_runtime. Prior to this change this test (and many others) were not run with EXIT_RUNTIME enabled.
Without this part of the change the above test fails like:
$ ./tests/runner asan.test_fs_no_main_minimal_runtime --skip-slow
Test suites:
['test_core']
Running test_core: (1 tests)
(checking sanity from test runner)
shared:INFO: (Emscripten: Running sanity checks)
test_fs_no_main_minimal_runtime (test_core.asan) ... emcc: error: expected to find pattern in input JS: <<< ATEXITS >>>
e723c57 to
03f6a48
Compare
27800c7 to
bc805da
Compare
bc805da to
60a5050
Compare
| ccall('floatf', 'number', null, null, { async: true }).then(console.log); | ||
| ccall('floatf', 'number', null, null, { async: true }).then(function(arg) { | ||
| console.log(arg); | ||
| maybeExit(); |
There was a problem hiding this comment.
Is this still needed? I think it's part of the stuff you said you'd revert.
There was a problem hiding this comment.
I still see maybeExit() here, weird. Is the github UI confusing me maybe?
There was a problem hiding this comment.
Oops, actually reverted this now.
4b45323 to
62d31dc
Compare
f70f505 to
561d036
Compare
| #ifdef __EMSCRIPTEN__ | ||
| #include <stdlib.h> | ||
| #include <wasi/api.h> | ||
| #include <emscripten/emmalloc.h> |
There was a problem hiding this comment.
why does this include emmalloc?
There was a problem hiding this comment.
That is where emscripten_builtin_malloc is defined.
There was a problem hiding this comment.
Oh, really? That's quite odd, as that header is for the emmalloc replacement for dlmalloc, which we don't even use by default.
It looks like the function is declared also in dlmalloc.c, but not in a header. We should probably create a new header just for that method, I think? For now to not block you, how about a comment here with a TODO to fix this?
There was a problem hiding this comment.
Yes it does seem a little odd. I think maybe the idea was that emmalloc.h contains all the malloc-related functions? emmalloc.h also defines malloc and free as well BTW... i think it made sense maybe to define all 3 variants in the same place?
I didn't originally put them there .. maybe there is a better place? emscripten/heap.h? For now I think its fine. Certainly unrelated to this PR. We already include emmalloc.h in pthread _create.c for this same purpose:
| ccall('floatf', 'number', null, null, { async: true }).then(console.log); | ||
| ccall('floatf', 'number', null, null, { async: true }).then(function(arg) { | ||
| console.log(arg); | ||
| maybeExit(); |
There was a problem hiding this comment.
I still see maybeExit() here, weird. Is the github UI confusing me maybe?
561d036 to
c0866bc
Compare
| #ifdef __EMSCRIPTEN__ | ||
| #include <stdlib.h> | ||
| #include <wasi/api.h> | ||
| #include <emscripten/emmalloc.h> |
There was a problem hiding this comment.
Oh, really? That's quite odd, as that header is for the emmalloc replacement for dlmalloc, which we don't even use by default.
It looks like the function is declared also in dlmalloc.c, but not in a header. We should probably create a new header just for that method, I think? For now to not block you, how about a comment here with a TODO to fix this?
c0866bc to
c51e8d6
Compare
c51e8d6 to
0e247e8
Compare
d9167a1 to
c951f1d
Compare
We were already setting `EXIT_RUNTIME=1` under LSan because without this leaks are not reported. Since ASan includes LSan by default it makes sense to do that same for ASan. Because this change also effectivly enables leak detection in the `asan` test suite it also includes a bunch of fixes for memory leaks. The code in `emcc.py` that has been moved depend on `EXIT_RUNTIME` and so must be run only after this setting has been finalized. As part of this change I found a couple of issues related to `EXIT_RUNTIME` when combined with other flags: #15080 #15081 Regarding memory that leaked from JS and/or system libraries there in some cases we want to ignore the leaks rather then adding code to free the memory and in this case I've used `emscripten_builtin_malloc`.
c951f1d to
61ebb86
Compare
Not sure how I missed adding these.
We were already setting
EXIT_RUNTIME=1under LSan because without thisleaks are not reported. Since ASan includes LSan by default it makes
sense to do that same for ASan.
Because this change also effectivly enables leak detection in the
asantest suite it also includes a bunch of fixes for memory leaks.
The code in
emcc.pythat has been moved depend onEXIT_RUNTIMEandso must be run only after this setting has been finalized.
As part of this change I found a couple of issues related to
EXIT_RUNTIMEwhen combined with other flags:#15080
#15081
Regarding memory that leaked from JS and/or system libraries there in
some cases we want to ignore the leaks rather then adding code to free
the memory and in this case I've used
emscripten_builtin_malloc.