This is an archive of the discontinued LLVM Phabricator instance.

[sanitizer] Restrict clock_gettime workaround to glibc
ClosedPublic

Authored by MaskRay on Feb 17 2021, 7:04 PM.

Details

Summary

The hackery is due to glibc clock_gettime crashing from preinit_array (D40679).
32-bit musl architectures do not define __NR_clock_gettime so the code causes a compile error.

Tested on Alpine Linux x86-64 (musl) and FreeBSD x86-64.

Diff Detail

Event Timeline

MaskRay created this revision.Feb 17 2021, 7:04 PM
MaskRay requested review of this revision.Feb 17 2021, 7:04 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 17 2021, 7:04 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
vitalybuka accepted this revision.Mar 5 2021, 12:16 PM

Trivial test which just call the function from preinit array and do not crash would be nice

This revision is now accepted and ready to land.Mar 5 2021, 12:16 PM

Trivial test which just call the function from preinit array and do not crash would be nice

This (clock_gettime in .preinit_array time) has been tested by scudo tests (D40679).
Actually I cannot reproduce the failure (on glibc 2.31) if I delete the SANITIZER_GLIBC guarded code.
Perhaps this is glibc version dependent.

@cryptoad Perhaps we can delete these blocks once the minimum supported glibc does not need these.

Hope this patch makes these places stand out.

MaskRay edited the summary of this revision. (Show Details)Mar 6 2021, 10:30 AM
This revision was landed with ongoing or failed builds.Mar 6 2021, 10:32 AM
This revision was automatically updated to reflect the committed changes.