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

Increase default stack size #3010

Merged

Conversation

eloparco
Copy link
Contributor

With the previous stack size, I can't even run the simple no_pthread example on MacOS.

./iwasm wasm-apps/no_pthread.wasm
[3/3] Linking C executable iwasm

#00 main
#01 __main_void
#02 _start

Exception: native stack overflow

Copy link
Contributor

@wenyongh wenyongh left a comment

Choose a reason for hiding this comment

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

LGTM

@yamt
Copy link
Collaborator

yamt commented Jan 15, 2024

With the previous stack size, I can't even run the simple no_pthread example on MacOS.

./iwasm wasm-apps/no_pthread.wasm
[3/3] Linking C executable iwasm

#00 main
#01 __main_void
#02 _start

Exception: native stack overflow

it works for me on macOS 12.7.1 / x86-64.

spacetanuki% ./iwasm wasm-apps/no_pthread.wasm
New thread ID: 1, starting parameter: 52
Updated value: 60
Thread completed, new value: 60, thread id: 1
spacetanuki% 

@yamt
Copy link
Collaborator

yamt commented Jan 15, 2024

i guess it's simpler to allow APP_THREAD_STACK_SIZE_DEFAULT=0, which means "leave it to the system default". how do you think?

@wenyongh
Copy link
Contributor

wenyongh commented Jan 15, 2024

i guess it's simpler to allow APP_THREAD_STACK_SIZE_DEFAULT=0, which means "leave it to the system default". how do you think?

It should be good if we only use 0 for pthread_create, but there are some other places using it and APP_THREAD_STACK_SIZE_MIN, and it may be used in non-posix platforms:

max_stack_size =
(size_t)(APP_THREAD_STACK_SIZE_MAX + page_size - 1) & ~(page_size - 1);
if (max_stack_size < APP_THREAD_STACK_SIZE_DEFAULT)
max_stack_size = APP_THREAD_STACK_SIZE_DEFAULT;

#if BH_ENABLE_ZEPHYR_MPU_STACK == 0
if (stack_size < APP_THREAD_STACK_SIZE_MIN)
stack_size = APP_THREAD_STACK_SIZE_MIN;
thread_data_size = offsetof(os_thread_data, stack) + stack_size;
#else

Seems it's better to set a non-zero value for it. Another option may be let each platform set its value individually.

@wenyongh wenyongh merged commit 54bc9f2 into bytecodealliance:main Jan 15, 2024
395 checks passed
victoryang00 pushed a commit to victoryang00/wamr-aot-gc-checkpoint-restore that referenced this pull request May 27, 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

Successfully merging this pull request may close these issues.

None yet

3 participants