Skip to content
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

Always use size_t in dlmalloc's mallinfo #23368

Merged
merged 1 commit into from
Jan 10, 2025

Conversation

sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Jan 10, 2025

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.

@sbc100 sbc100 requested review from kripken and dschuff January 10, 2025 18:55
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.

Is it worth a changelog notice? I guess wasm64 users will get an error if they use the mallinfo struct, but it's clear how to fix it?

@sbc100
Copy link
Collaborator Author

sbc100 commented Jan 10, 2025

Added ChangeLog entry.

ChangeLog.md Outdated Show resolved Hide resolved
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.
@sbc100 sbc100 merged commit 5627123 into emscripten-core:main Jan 10, 2025
24 of 29 checks passed
@sbc100 sbc100 deleted the fix_mallinfo branch January 10, 2025 20:51
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.

2 participants