Skip to content

Fix stack-use-after-return in TaskDispatchThread Android ctor#57629

Open
javache wants to merge 1 commit into
react:mainfrom
javache:export-D113046624
Open

Fix stack-use-after-return in TaskDispatchThread Android ctor#57629
javache wants to merge 1 commit into
react:mainfrom
javache:export-D113046624

Conversation

@javache

@javache javache commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary:
Under dev_clang_asan, bloks_runtimeTestsAndroid crashes at startup with __asan_report_load4 inside ThreadScope::WithClassLoader. The Android branch of the TaskDispatchThread constructor captures the priorityOffset parameter by reference into the std::thread lambda; the constructor returns immediately, so by the time the thread runs and reads priorityOffset inside setpriority(...) the stack slot is gone. Non-asan builds tolerate the racy read; asan catches it deterministically.

Capture priorityOffset (and this) by value on both the outer thread lambda and the inner WithClassLoader lambda.

Changelog:
[Internal]

Differential Revision: D113046624

Summary:
Under `dev_clang_asan`, `bloks_runtimeTestsAndroid` crashes at startup with `__asan_report_load4` inside `ThreadScope::WithClassLoader`. The Android branch of the `TaskDispatchThread` constructor captures the `priorityOffset` parameter by reference into the `std::thread` lambda; the constructor returns immediately, so by the time the thread runs and reads `priorityOffset` inside `setpriority(...)` the stack slot is gone. Non-asan builds tolerate the racy read; asan catches it deterministically.

Capture `priorityOffset` (and `this`) by value on both the outer thread lambda and the inner `WithClassLoader` lambda.

Changelog:
[Internal]

Differential Revision: D113046624
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 21, 2026
@meta-codesync

meta-codesync Bot commented Jul 21, 2026

Copy link
Copy Markdown

@javache has exported this pull request. If you are a Meta employee, you can view the originating Diff in D113046624.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant