https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70035

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 37867
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37867&action=edit
gcc6-pr70035.patch

As for the crash in libubsan, the problem is that -fsanitize=vptr
instrumentation pretty much assumes that the vtable pointer in the object is
either NULL, or valid table (perhaps of some other class).  But in this case it
is totally uninitialized, random garbage.

The  attached patch is an attempt to just clear those vtable pointers in
objects for -fsanitize=vptr early in the ctor (right after the spot where
-flifetime-dse=2 emits the clobber of the object), so that you get nice
diagnostics instead of a crash.  It would be desirable if the libubsan code
assumed that the pointer in the object could be random garbage and deal with it
more carefully (e.g. through trying a syscall and see if it ended up with
EFAULT etc.).  Though of course, both this patch, or being more careful in
libubsan, will slow -fsanitize=vptr a little bit.

Reply via email to