Skip to content

Fix on-heap aux stack allocation#1865

Merged
wenyongh merged 1 commit into
bytecodealliance:dev/wasi_threadsfrom
loganek:loganek/fix-heap-aux-stack-alloc
Jan 6, 2023
Merged

Fix on-heap aux stack allocation#1865
wenyongh merged 1 commit into
bytecodealliance:dev/wasi_threadsfrom
loganek:loganek/fix-heap-aux-stack-alloc

Conversation

@loganek

@loganek loganek commented Jan 5, 2023

Copy link
Copy Markdown
Contributor

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

eloparco commented Jan 5, 2023

Copy link
Copy Markdown
Contributor

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

loganek commented Jan 5, 2023

Copy link
Copy Markdown
Contributor Author

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.

Comment thread core/iwasm/libraries/thread-mgr/thread_manager.c Outdated
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
vickiegpt pushed a commit to vickiegpt/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