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

Fix on-heap aux stack allocation #1865

Conversation

loganek
Copy link
Collaborator

@loganek loganek commented Jan 5, 2023

Because stack grows from high address towards low address, the value returned by malloc is the end of the stack, not top of the stack. The top of the stack is the end of the allocated space (i.e. address returned by malloc + cluster size).

#1790

@eloparco
Copy link
Contributor

eloparco commented Jan 5, 2023

We need to remove these two lines https://github.com/bytecodealliance/wasm-micro-runtime/blob/dev/wasi_threads/samples/wasi-threads/wasm-apps/CMakeLists.txt#L32. I had to put them in this PR #1819 since there was a heap corruption problem that was making the pipeline fail.

@loganek loganek force-pushed the loganek/fix-heap-aux-stack-alloc branch from fadeb11 to 9e0c440 Compare January 5, 2023 15:00
@loganek
Copy link
Collaborator Author

loganek commented Jan 5, 2023

We need to remove these two lines https://github.com/bytecodealliance/wasm-micro-runtime/blob/dev/wasi_threads/samples/wasi-threads/wasm-apps/CMakeLists.txt#L32. I had to put them in this PR #1819 since there was a heap corruption problem that was making the pipeline fail.

As discussed offline, it's ok to export free/malloc and not use app heap as long as the malloc is thread safe.

Because stack grows from high address towards low address, the value
returned by malloc is the end of the stack, not top of the stack. The top
of the stack is the end of the allocated space (i.e. address returned by
malloc + cluster size).
@loganek loganek force-pushed the loganek/fix-heap-aux-stack-alloc branch from 9e0c440 to caae01c Compare January 6, 2023 09:15
@wenyongh wenyongh merged commit 2615646 into bytecodealliance:dev/wasi_threads Jan 6, 2023
victoryang00 pushed a commit to victoryang00/wamr-aot-gc-checkpoint-restore that referenced this pull request May 27, 2024
Because stack grows from high address towards low address, the value
returned by malloc is the end of the stack, not top of the stack. The top
of the stack is the end of the allocated space (i.e. address returned by
malloc + cluster size).

Refer to bytecodealliance#1790.
@loganek loganek deleted the loganek/fix-heap-aux-stack-alloc branch June 10, 2024 12:48
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.

4 participants