This is an archive of the discontinued LLVM Phabricator instance.

Implementation NonUniqueARMRTTIBit __type_name has higher bits set on arm64
ClosedPublic

Authored by usama54321 on Nov 6 2022, 5:37 PM.

Details

Summary

This problem arises because ubsan can not currently import c++ headers, and the type_info definition goes out of sync.

On arm64 Apple, we have the NonUniqueARMRTTIBit implementation of typeinfo. Copying from typeinfo header:

// When constructing the type_info,
// the compiler packs the pointer to the type name into a uintptr_t and reserves
// the high bit of that pointer, which is assumed to be free for use under that
// ABI. If that high bit is set, that specific copy of the RTTI can't be assumed
// to be unique within the program. If the high bit is unset, then the RTTI can
// be assumed to be unique within the program.

The corresponding implementation __non_unique_arm_rtti_bit_impl masks out these bits when returning the pointer to the type name in __type_name_to_string function. This patch just syncs the type_info definition in ubsan with this masking.

The fix is needed because some ubsan tests (vptr*) crash while trying to symbolicate the type name during diagnositcs.

Diff Detail

Event Timeline

usama54321 created this revision.Nov 6 2022, 5:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 6 2022, 5:37 PM
usama54321 requested review of this revision.Nov 6 2022, 5:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 6 2022, 5:37 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
usama54321 updated this revision to Diff 473531.Nov 6 2022, 5:45 PM

Fix commit message

Can you please add a description of the change?

usama54321 edited the summary of this revision. (Show Details)Nov 14 2022, 10:47 AM
usama54321 edited the summary of this revision. (Show Details)Nov 14 2022, 10:51 AM
ldionne accepted this revision.Nov 17 2022, 10:31 AM

LGTM, assuming you don't need to add a test because this is already fixing a test failure.

This revision is now accepted and ready to land.Nov 17 2022, 10:31 AM