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

MALLOCX_ARENA is ignored, leading to incorrect behaviour in JSC. #1969

Open
jacobbramley opened this issue Dec 14, 2023 · 2 comments
Open

MALLOCX_ARENA is ignored, leading to incorrect behaviour in JSC. #1969

jacobbramley opened this issue Dec 14, 2023 · 2 comments

Comments

@jacobbramley
Copy link

Originally posted by @brooksdavis in #1964 (comment):

With mrs we're just ignoring the TCACHE and ARENA flags. We could probably pass them through, but I'm not convinced they would be particularly meaningful given the effects to having a single, arbitrarily selected thread insert everything into the free list on easy cycle. There's defiantly more work to do here on micro optimization in a quarantined environment.

Sadly, MALLOCX_ARENA isn't just used as an optimisation here. JavaScriptCore defines an arena, sets DDC to cover it, then uses MALLOCX_ARENA to allocate pointers that can be used with that DDC (e.g. in generated code).

The JSC Morello port supports a compressed-pointer mode, and this mechanism is likely to be important there, but this bug actually occurs on a standard purecap build. I'm not sure why we're using plain pointers in such a build, but it does mean that we'll see a regression until we can investigate.

For now, we'll disable revocation when we test JSC, but I thought it'd be useful to report the issue anyway.

jacobbramley added a commit to jacobbramley/webkit that referenced this issue Dec 14, 2023
@jrtc27
Copy link
Member

jrtc27 commented Dec 14, 2023

At that point you really just need your own allocator. Other allocators will never support that, and I hope we can remove the jemalloc interfaces entirely from FreeBSD in future.

I guess we should make mrs reject allocations with some of those flags set, but that won’t be in our 23.11 release.

@brooksdavis
Copy link
Member

The easiest answer here is likely to link a private copy of jemalloc with suitable renaming (supported in the codebase already) and use that for these allocations. They shouldn't really be subject to revocation in the normal way, probably just when the arena is destroyed and the OS takes care of it by revoking all capabilities to the now quarantined reservation.

jacobbramley added a commit to jacobbramley/webkit that referenced this issue Jan 15, 2024
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

No branches or pull requests

3 participants