llvm-project
3bff1a81 - [XRay] Always register constructor(0) alongside .preinit_array (#188788)

Commit
27 days ago
[XRay] Always register constructor(0) alongside .preinit_array (#188788) On musl-based systems the dynamic linker does not process DT_PREINIT_ARRAY, so the .preinit_array entry alone never calls __xray_init(). Without initialization, the global XRay Flags struct is zero-initialized and flags()->xray_mode is NULL. When the basic-mode or FDR-mode static initializers run from .init_array and call internal_strcmp(flags()->xray_mode, ...), they dereference NULL and crash. Fix this by always registering a constructor(0) in addition to the .preinit_array entry. On glibc where .preinit_array works, __xray_init() will have already run and the constructor returns immediately (the function is idempotent). On musl, the constructor ensures __xray_init() runs before other .init_array entries that depend on XRay flags being initialized.
Author
Parents
Loading