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

Mac doesn't support MMAP_MAP_32BIT so this condition ends up asserting. #3755

Merged
merged 1 commit into from
Aug 29, 2024

Conversation

Andersbakken
Copy link
Contributor

Mac on aarch64 uses posix_memmap.c which doesn't do anything with the flag MMAP_MAP_32BIT for that build so this condition ends up asserting unless the mapping ends up in the first 4 gigs worth of addressable space. Not entirely what problems not guaranteeing the mapping to be in that range will cause but as of now it asserts for me every time. It appears the usage of MAP_32BIT isn't functional after MacOS 13 (if I understand this thread correctly #3009)

@@ -302,7 +302,7 @@ loader_mmap(uint32 size, bool prot_exec, char *error_buf, uint32 error_buf_size)
int map_flags;
void *mem;

#if UINTPTR_MAX == UINT64_MAX
#if UINTPTR_MAX == UINT64_MAX && (!defined(__APPLE__) || !defined(__arm64__))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MMAP_MAP_32BIT is only handled when the target is x86-64 or riscv64, and __APPLE__ isn't defined. See posix os_mmap:
https://github.com/bytecodealliance/wasm-micro-runtime/blob/main/core/shared/platform/common/posix/posix_memmap.c#L83-L98

How about changing to:

#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_AMD_64) \
    || defined(BUILD_TARGET_RISCV64_LP64D)                       \
    || defined(BUILD_TARGET_RISCV64_LP64)
#ifndef __APPLE__
...
#endif
#endif

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me. Updated now.

condition will end up asserting on the ones where it isn't supported.
Copy link
Collaborator

@yamt yamt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@wenyongh wenyongh merged commit eab409a into bytecodealliance:main Aug 29, 2024
387 checks passed
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.

3 participants