-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Use debug version of malloc when ASSERTIONS=1. NFC #23330
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, but please add a changelog mention. some people may be using ASSERTIONS builds in production, and would like to know about this.
Changelog updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
94ef6a9
to
c0bf5c9
Compare
79f1dd0
to
f940575
Compare
For some reason emscrpiten was overriding MALLINFO_FIELD_TYPE to be int even though this defaults size_t and size_t is the document type in the man page, and size_t allows for correct reporting of numbers larger than 2^32. What is worse the `MALLINFO_FIELD_TYPE` override was only place when `DLMALLOC_DEBUG` was defined which meant that `MALLINFO_FIELD_TYPE` varied between `-sASSERTIONS=1` and `-sASSERTIONS=2` builds of dlmalloc. This means that `-sMEMORY64 + -sASSERTIONS=2` builds of dlmalloc were simply broken WRT `mallinfo` since the public definition of mallinfo disagreed with the dlmalloc-internal version. I verified that the follow tests fails without this change: EMCC_CFLAGS=-sASSERTIONS=2 ./test/runner wasm64.test_mallinfo I'm not updating the actual test code here since test coverage will be coming in emscripten-core#23330. This change was spit out from emscripten-core#23330.
For some reason emscrpiten was overriding MALLINFO_FIELD_TYPE to be int even though this defaults size_t and size_t is the document type in the man page, and size_t allows for correct reporting of numbers larger than 2^32. What is worse the `MALLINFO_FIELD_TYPE` override was only place when `DLMALLOC_DEBUG` was defined which meant that `MALLINFO_FIELD_TYPE` varied between `-sASSERTIONS=1` and `-sASSERTIONS=2` builds of dlmalloc. This means that `-sMEMORY64 + -sASSERTIONS=2` builds of dlmalloc were simply broken WRT `mallinfo` since the public definition of mallinfo disagreed with the dlmalloc-internal version. I verified that the follow tests fails without this change: EMCC_CFLAGS=-sASSERTIONS=2 ./test/runner wasm64.test_mallinfo I'm not updating the actual test code here since test coverage will be coming in emscripten-core#23330. This change was spit out from emscripten-core#23330.
For some reason emscrpiten was overriding MALLINFO_FIELD_TYPE to be int even though this defaults size_t and size_t is the document type in the man page, and size_t allows for correct reporting of numbers larger than 2^32. What is worse the `MALLINFO_FIELD_TYPE` override was only place when `DLMALLOC_DEBUG` was defined which meant that `MALLINFO_FIELD_TYPE` varied between `-sASSERTIONS=1` and `-sASSERTIONS=2` builds of dlmalloc. This means that `-sMEMORY64 + -sASSERTIONS=2` builds of dlmalloc were simply broken WRT `mallinfo` since the public definition of mallinfo disagreed with the dlmalloc-internal version. I verified that the follow tests fails without this change: EMCC_CFLAGS=-sASSERTIONS=2 ./test/runner wasm64.test_mallinfo I'm not updating the actual test code here since test coverage will be coming in emscripten-core#23330. This change was spit out from emscripten-core#23330.
For some reason emscrpiten was overriding MALLINFO_FIELD_TYPE to be int even though this defaults size_t and size_t is the document type in the man page, and size_t allows for correct reporting of numbers larger than 2^32. What is worse the `MALLINFO_FIELD_TYPE` override was only place when `DLMALLOC_DEBUG` was defined which meant that `MALLINFO_FIELD_TYPE` varied between `-sASSERTIONS=1` and `-sASSERTIONS=2` builds of dlmalloc. This means that `-sMEMORY64 + -sASSERTIONS=2` builds of dlmalloc were simply broken WRT `mallinfo` since the public definition of mallinfo disagreed with the dlmalloc-internal version. I verified that the follow tests fails without this change: EMCC_CFLAGS=-sASSERTIONS=2 ./test/runner wasm64.test_mallinfo I'm not updating the actual test code here since test coverage will be coming in emscripten-core#23330. This change was spit out from emscripten-core#23330.
For some reason emscripten was overriding `MALLINFO_FIELD_TYPE` to be `int` even though this defaults `size_t` and `size_t` is what linux uses, and `size_t` allows for correct reporting of numbers larger than 2^32. What is worse, the `MALLINFO_FIELD_TYPE` override was only applied when `DLMALLOC_DEBUG` was defined which meant that `MALLINFO_FIELD_TYPE` varied between `-sASSERTIONS=1` and `-sASSERTIONS=2` builds of dlmalloc! This means that `-sMEMORY64 + -sASSERTIONS=2` builds of dlmalloc were simply broken WRT `mallinfo` since the public definition of mallinfo disagreed with the dlmalloc-internal version. I verified that the follow tests fails without this change: `EMCC_CFLAGS=-sASSERTIONS=2 ./test/runner wasm64.test_mallinfo` I'm not updating the actual test code here since test coverage will be coming in #23330. This change was spit out from #23330.
Previously we were only using it with `ASSERTIONS=2`. The debug version dlmalloc has a lot very useful checks. Enabling this found a few real issues in our test code. Fixes: emscripten-core#23360
Previously we were only using it with
ASSERTIONS=2
.The debug version dlmalloc has many very useful checks, including checking for double-free. This is something that is done by glibc malloc even in release builds. It seems reasonable that we should do this basic checking in our debug builds at least.
Required fixing two genuine bugs: One double-free in test code and one invalid free in embind.
Fixes: #23360