Skip to content

Exclude non-user portions of the main thread stack from stack scanning on 32 bits. - #1571

Merged
magomez merged 1 commit into
WebPlatformForEmbedded:wpe-2.38from
justinmichaud:eng/stack-scanning-backport
Oct 10, 2025
Merged

Exclude non-user portions of the main thread stack from stack scanning on 32 bits.#1571
magomez merged 1 commit into
WebPlatformForEmbedded:wpe-2.38from
justinmichaud:eng/stack-scanning-backport

Conversation

@justinmichaud

@justinmichaudjustinmichaud commented Oct 9, 2025

Copy link
Copy Markdown

Exclude non-user portions of the main thread stack from stack scanning on 32 bits.
https://bugs.webkit.org/show_bug.cgi?id=293720

Reviewed by NOBODY (OOPS!).

On 32-bit armv7/linux we run into an issue where the environment strings
located at the bottom of the stack, as well as some random bits inside
the libc portion of the stack are interpreted as cells pointing
into the heap, keeping actually dead objects alive.

Yusuke previously attempted to fix this by excluding environ and before,
but there are additional fake roots only a few hundred bytes below that.

This patch excludes the caller of main entirely.

  • Source/JavaScriptCore/jsc.cpp:
    (jscmain):
  • Source/WTF/wtf/StackBounds.cpp:
    (WTF::StackBounds::setBottomOfMainThreadMain):
    (WTF::StackBounds::currentThreadStackBoundsInternal):
  • Source/WTF/wtf/StackBounds.h:
  • Source/WebKit/WebProcess/gtk/WebProcessMainGtk.cpp:
  • Source/WebKit/WebProcess/wpe/WebProcessMainWPE.cpp:
    0f53210
Build-TestsLayout-Tests
❌ 🛠 wpe-246-amd64-build❌ 🧪 wpe-246-amd64-layout
❌ 🛠 wpe-246-arm32-build❌ 🧪 wpe-246-arm32-layout

…g on 32 bits.
https://bugs.webkit.org/show_bug.cgi?id=293720
Reviewed by Yusuke Suzuki.
On 32-bit armv7/linux we run into an issue where the environment strings
located at the bottom of the stack, as well as some random bits inside
the libc portion of the stack are interpreted as cells pointing
into the heap, keeping actually dead objects alive.
Yusuke previously attempted to fix this by excluding environ and before,
but there are additional fake roots only a few hundred bytes below that.
This patch excludes the caller of main entirely.
* Source/JavaScriptCore/jsc.cpp:
(jscmain):
* Source/JavaScriptCore/runtime/JSLock.cpp:
(JSC::JSLock::didAcquireLock):
* Source/WTF/wtf/StackBounds.cpp:
(WTF::StackBounds::setBottomOfMainThreadMain):
(WTF::StackBounds::currentThreadStackBoundsInternal):
* Source/WTF/wtf/StackBounds.h:
(WTF::StackBounds::checkConsistency const):
* Source/WebKit/WebProcess/gtk/WebProcessMainGtk.cpp:
(WebKit::WebProcessMain):
* Source/WebKit/WebProcess/wpe/WebProcessMainWPE.cpp:
(WebKit::WebProcessMain):
@justinmichaud
justinmichaud changed the base branch from wpe-2.46 to wpe-2.38October 9, 2025 15:44
@magomez
magomez self-requested a review October 10, 2025 07:12
@magomez
magomez merged commit 3c84c7a into WebPlatformForEmbedded:wpe-2.38Oct 10, 2025
@justinmichaudjustinmichaud mentioned this pull request Jul 23, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants

@justinmichaud@magomez