Repository navigation
Use RhpGetThread with emulated TLS in arm64 EH helpers - #137697
Conversation
INLINE_GETTHREAD reads tls_CurrentThread directly on arm64, which does not exist with FEATURE_EMULATED_TLS (Android). Call RhpGetThread in CallEHFunclet and RhpResumeAfterCatch instead, like PInvoke.S and GcProbe.S do. Fixes dotnet#137692 Co-authored-by: Cursor <[email protected]>
|
Azure Pipelines: Successfully started running 3 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib |
There was a problem hiding this comment.
🟡 Changes recommended
A critical unwind issue remains: GETTHREAD_ETLS_2 restores fp without resetting the CFA to sp, which can cause asynchronous stack walks on emulated-TLS builds to recover the wrong caller stack pointer.
1 open issue
What changed in this PR
This PR addresses the Android ARM64 NativeAOT link failure reported in #137692 by making exception-handling helpers use RhpGetThread when emulated thread-local storage is enabled.
Changes:
- Preserve funclet arguments across thread lookup in
CallEHFunclet. - Use the emulated-TLS accessor in
RhpResumeAfterCatch, while retaining inline access for native-TLS builds.
| File | Description |
|---|---|
src/coreclr/runtime/arm64/EHHelpers.S |
Adds conditional RhpGetThread lookup and argument preservation for funclet invocation. |
src/coreclr/nativeaot/Runtime/arm64/ExceptionHandling.S |
Adds emulated-TLS lookup during catch resumption and uses x2 for the thread pointer. |
Review effort: Balanced
PROLOG_SAVE_REG_PAIR_INDEXED fp, lr makes fp the CFA register, and the epilog does not switch it back to sp, so the unwind rules after these macros were based on the caller's fp.
There was a problem hiding this comment.
🔵 Needs a closer look
Static review found no actionable defects, but the ARM64 EH register-preservation and shared TLS unwind-metadata changes require Android ARM64 NativeAOT linking and exception/GC smoke validation that has not been performed.
No open issues 🎉
1 resolved since last review
Review effort: Balanced

INLINE_GETTHREADreadstls_CurrentThreaddirectly on arm64, which does not exist withFEATURE_EMULATED_TLS(Android). CallRhpGetThreadinCallEHFuncletandRhpResumeAfterCatchinstead, likePInvoke.SandGcProbe.Sdo.Fixes #137692