This is an archive of the discontinued LLVM Phabricator instance.

Skip Ubsan's vptr checks on constructors and destructors.
Needs ReviewPublic

Authored by byoungyoung on Jul 15 2014, 3:33 PM.

Details

Reviewers
samsonov
rsmith
Summary

Initial patch attempts to skip Ubsan's vptr checks on ctors and dtors as many (seemingly harmless) undefined behaviors were observed in ctors and dtors. This feature should be opted out with some other compiler flags (e.g., -mllvm for Asan), but right now there are no such flags in this patch.

Diff Detail

Event Timeline

byoungyoung retitled this revision from to Skip Ubsan's vptr checks on constructors and destructors..
byoungyoung updated this object.
byoungyoung edited the test plan for this revision. (Show Details)
byoungyoung added reviewers: samsonov, rsmith.
byoungyoung added a subscriber: Unknown Object (MLST).
rsmith edited edge metadata.Jul 15 2014, 4:27 PM

It's not OK to just turn off this checking for everyone. It's also not appropriate to blindly turn off all checks in a constructor or destructor. This also doesn't do the right thing for code invoked from a constructor or destructor.

Instead, I'd suggest you do the following:

  • When a complete object constructor starts for a polymorphic class type, write a record to a (thread-local) stack indicating the address, size, and type_info of the complete object.
  • When the sanitizer runtime detects a problem, check this side-table. If the access is to a subobject that would be present once the complete object is constructed, suppress the diagnostic (possibly based on a runtime flag).

Thanks Richard for the comment! I'm not sure whether I can correctly implement what you have suggested here, but let me try this :-)