This is an archive of the discontinued LLVM Phabricator instance.

[Sanitizer] Fix demangling for Swift symbol names
ClosedPublic

Authored by yln on Jun 11 2020, 6:05 PM.

Details

Summary

The Swift symbol name prefix has changed from _T0 to _$s as
documented here [1]. This prevents Swift names from properly being
symbolicated when using the in-process LLVM symbolizer. The best way to
fix this seems to be to avoid the duplication of "Is this a Swift symbol
name?" here. We can simply remove this check as swift_demangle
already returns null for non-Swift names [2,3].

The check was included in the initial support for Swift name demangling
to avoid superfluous calls to dlsym() [4]. A subsequent commit
changed this logic to retrieve the swift_demangle function pointer
eagerly during sanitizer initialization, but did not remove the check
[5].

[1] https://github.com/apple/swift/blob/master/docs/ABI/Mangling.rst
[2] https://github.com/apple/swift/blob/b5a8b518eae54cea997f3b0954760fc7858829f6/include/swift/Demangling/Demangle.h#L643
[3] https://github.com/apple/swift/blob/b5a8b518eae54cea997f3b0954760fc7858829f6/stdlib/public/runtime/Demangle.cpp#L656
[4] https://reviews.llvm.org/D19135
[5] https://reviews.llvm.org/D20015

rdar://62753845

Diff Detail

Event Timeline

yln created this revision.Jun 11 2020, 6:05 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 11 2020, 6:05 PM
Herald added subscribers: Restricted Project, Charusso. · View Herald Transcript
kubamracek accepted this revision.Jun 30 2020, 5:14 PM

Looks reasonable. Could you check that swift_demangle has been correctly returning NULL for a "long time" (a couple years at least)? I'm asking because we can run on older OS's.

This revision is now accepted and ready to land.Jun 30 2020, 5:14 PM
yln added a comment.Jun 30 2020, 6:06 PM

Looks reasonable. Could you check that swift_demangle has been correctly returning NULL for a "long time" (a couple years at least)? I'm asking because we can run on older OS's.

swift_demangle first appeared (renamed from different name in April 2016) with the check:
https://github.com/apple/swift/commit/4ba7e418cb30e9fd10908bcbb6e9c91d28b8069c#diff-9ede1d68887f90e86c2802013504d0d9R1224-R1228

Changed to current version here:
https://github.com/apple/swift/commit/36a07e9a6bc0f8a4a0f9418e1e68d35092079a05

This revision was automatically updated to reflect the committed changes.