darwin: pass NULL envp to arm64 initializers#1114
Conversation
|
Thank you! Why only do this for arm64? And what is the exact issue here, is it that we're passing an empty envp, and there's code assuming there's at least one element before the terminator? |
|
Thanks for taking a look! I kept this arm64-only because that is where I have a reliable repro and validation: iOS arm64e, attaching to a target that previously crashed during early initializer execution. I have not verified the same failure mode on the x86 or The issue I observed does not look like code iterating an empty envp and assuming there is at least one element before the terminator. The crash evidence points to the non-NULL pointer value itself leaking through the arm64 initializer ABI. The mapper was calling initializers with: In the failing process, the initializer-triggered path entered an Objective-C/framework path. The crashing frame was Passing |
Summary
This changes the Darwin arm64 mapper to pass
NULLforenvpwhen invoking Mach-O initializers, while keeping the existing emptyargv,apple, andresulthandling unchanged.Details
The current arm64 mapper passes the same synthetic
empty_strvpointer for bothargvandenvp. This meansenvpis non-NULL and points into mapper-owned runtime data.Most initializers ignore this value, but initializer-triggered runtime/framework paths may propagate argument registers or reinterpret them across callback boundaries. In those cases, a non-NULL synthetic
envpcan be treated as an arbitrary pointer instead of an absent environment, which may cause crashes during early attach.Passing
NULLbetter represents the absence of an injected-process environment and avoids exposing mapper-owned storage throughenvp.Testing