WebAssembly / WebAssembly/wasi-libc
`PAGESIZE` macro set to garbage value in shared libraries
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 1k
- Forks
- 251
- Avg merge
- 7h 15m
- Merged PRs (30d)
- 3
Description
While experimenting with C++ exception handling support for shared libraries, I discovered that the support for custom page sizes in __macro__PAGESIZE.h (which is only enabled for LLVM v22 and later) is broken for shared libraries, leading to an alignment-related abort() in sbrk when dlmalloc asks for more memory.
I was able to work around this by adding a && !defined __pic__ clause to the preprocessor guard, causing PAGESIZE to be hard-coded to the traditional 0x10000 value when compiling with -fPIC. I'm not sure what the proper way to handle custom page sizes in shared libraries is, but perhaps rather than rely on wasm-ld to define __wasm_first_page_end, it could be imported from env similar to e.g. __heap_end and friends.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in __macro__PAGESIZE.h and inspect the preprocessor guard used for LLVM v22 and later, then trace how wasm-ld defines __wasm_first_page_end for shared libraries. Compare that path with the imported __heap_end and related symbols mentioned in the issue. Done means shared-library builds use a valid PAGESIZE and dlmalloc no longer reaches the alignment-related sbrk abort.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cpp, wasm
- Domain
- build-system, compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100