Skip to content

Fix a dependency between libc++ and malloc/free #12259

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

Closed
wants to merge 3 commits into from
Closed

Conversation

kripken
Copy link
Member

@kripken kripken commented Sep 17, 2020

Using any locale stuff (std::__2::ios_base::getloc() const is what is used
in practice) ends up including a lot of various code, including mmap/munmap
which indirectly call malloc/free from JS. This broke when we stopped
including malloc/free by default in #12213. It broke closure, which errors on
this - I'm not sure it's possible to actually get mmap/munmap to actually be
used in that code path.

Adds a test that breaks without the fix.

Sadly this shows the fragility of this approach - we have lots of malloc/free
uses in our JS, and quite a lot of code paths from system libs to there,
which is how this one was missed. OTOH, in practice any non-trivial
program tends to include malloc/free anyhow, which is why we haven't
gotten bug reports I think (I noticed this particular issue by chance when
looking at random_device).

@sbc100
Copy link
Collaborator

sbc100 commented Sep 17, 2020

LGTM.

I the long run I think we should just move mmap/munmap into native code. I looked at doing it while ago by just using the same code that wasi-libc uses... but the simple approach there don't honor the page alignment requirement.

@kripken
Copy link
Member Author

kripken commented Sep 17, 2020

#12260 landed so we don't need this.

@kripken kripken closed this Sep 17, 2020
@kripken kripken deleted the fixdep branch September 17, 2020 23:00
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