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
Diff Detail
Event Timeline
Comment Actions
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).
Comment Actions
Thanks Richard for the comment! I'm not sure whether I can correctly implement what you have suggested here, but let me try this :-)