Skip to content

Require names when using STACK_OVERFLOW_CHECK=2#26878

Open
sbc100 wants to merge 1 commit intoemscripten-core:mainfrom
sbc100:STACK_OVERFLOW_CHECK
Open

Require names when using STACK_OVERFLOW_CHECK=2#26878
sbc100 wants to merge 1 commit intoemscripten-core:mainfrom
sbc100:STACK_OVERFLOW_CHECK

Conversation

@sbc100
Copy link
Copy Markdown
Collaborator

@sbc100 sbc100 commented May 6, 2026

This change is needed so that WebAssembly/binaryen#8679 can roll in.

The combination will then fix #24964

@sbc100 sbc100 requested review from dschuff and kripken May 6, 2026 22:13
Comment thread tools/emscripten.py
args.append('--check-stack-overflow')
# The check-stack pass in binaryen needs to be able to locate `__stack_pointer` by name.
modify_wasm = True
need_name_section = True
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this stripped out from the final binary, if it doesn't need to be there? We have tests for that in general but I'm not sure if for this specific mode. I'm just worried about silently starting to emit the name section in this situation.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I verified locally that this is removed later. This need_name_section does not apply to the later binaries passes that run. For example when we do optimization with wasm-opt this does not apply.

Its a local-variable and does not effect the presence of absence of -g in the later optimization phases.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Actually, we have an even better guarantee than that.

Since we set need_name_section but we don't do args.append('-g'), when wasm-emscripten-finalize will strip the name section by default.

I confirmed that that name section is stripped both before and after this change when running:

$ ./emcc  ~/test/hello.c -sSTACK_OVERFLOW_CHECK=2

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Before this change the stripping was happening in the llvm-objcopy phase. After this change the stripping happens during wasm-emscripten-finalize, which is what we want.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sounds good. Maybe add a test for it?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It can just be another line in the existing names section test in other.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Are you think of a particular test? I tried to find one but didn't have much look. It looks like only test_emsymbolizer_functions and test_separate_dwarf use the .has_name_section method.

@sbc100 sbc100 enabled auto-merge (squash) May 6, 2026 23:35
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.

Stack overflow check in pthread+dynamic linking mode test failure

2 participants