Hi!

The upstream libubsan in the name of behaving more similarly between
all the other sanitizers turned the library from a lightweight set of a few
helper routines that print errors if something goes wrong into yet another
library that overrides various functions.

In particular, it now overrides signal and sigaction functions and therefore
requires to be initialized before anything else (otherwise, if somebody
calls signal or sigaction before the library is fully initialized, it just
crashes).  But this overriding isn't really needed for what the library is
doing, just so that there is some pretty printing of fatal signals.

I really don't like that, IMHO libubsan has no business in doing that, so
instead of adding .preinit_array initializers for the library, this patch
just removes that useless initialization and overriding from the library.
If people really need the pretty printing, they can use -fsanitize=address,
or leak or thread which all do need the heavy early initialization.

With this change, the ubsan initialization is performed on the first call
that actually wants to print something (and the initialization is only the
minimal set of stuff, parsing env vars, handling suppressions etc.).

Bootstrapped/regtested on x86_64-linux and i686-linux, additionally tested
with x86_64-linux --with-build-config=bootstrap-ubsan --enable-checking=release
bootstrap/regtest.

Ok for trunk?

2017-11-08  Jakub Jelinek  <ja...@redhat.com>

        PR bootstrap/82670
        * ubsan/Makefile.am (ubsan_files): Remove ubsan_init_standalone.cc
        and ubsan_signals_standalone.cc.
        * ubsan/Makefile.in: Regenerated.

--- libsanitizer/ubsan/Makefile.am.jj   2017-10-19 13:20:58.000000000 +0200
+++ libsanitizer/ubsan/Makefile.am      2017-11-07 17:40:23.589026215 +0100
@@ -22,10 +22,7 @@ ubsan_plugin_files = \
        ubsan_type_hash_win.cc \
        ubsan_value.cc
 
-ubsan_files = \
-       $(ubsan_plugin_files) \
-       ubsan_init_standalone.cc \
-       ubsan_signals_standalone.cc
+ubsan_files = $(ubsan_plugin_files)
 
 libubsan_la_SOURCES = $(ubsan_files) 
 libubsan_la_LIBADD = $(top_builddir)/sanitizer_common/libsanitizer_common.la 
--- libsanitizer/ubsan/Makefile.in.jj   2017-10-19 15:14:17.000000000 +0200
+++ libsanitizer/ubsan/Makefile.in      2017-11-07 17:40:47.378733040 +0100
@@ -111,8 +111,7 @@ am__objects_1 = ubsan_diag.lo ubsan_flag
        ubsan_handlers_cxx.lo ubsan_init.lo ubsan_type_hash.lo \
        ubsan_type_hash_itanium.lo ubsan_type_hash_win.lo \
        ubsan_value.lo
-am__objects_2 = $(am__objects_1) ubsan_init_standalone.lo \
-       ubsan_signals_standalone.lo
+am__objects_2 = $(am__objects_1)
 am_libubsan_la_OBJECTS = $(am__objects_2)
 libubsan_la_OBJECTS = $(am_libubsan_la_OBJECTS)
 libubsan_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
@@ -306,11 +305,7 @@ ubsan_plugin_files = \
        ubsan_type_hash_win.cc \
        ubsan_value.cc
 
-ubsan_files = \
-       $(ubsan_plugin_files) \
-       ubsan_init_standalone.cc \
-       ubsan_signals_standalone.cc
-
+ubsan_files = $(ubsan_plugin_files)
 libubsan_la_SOURCES = $(ubsan_files) 
 libubsan_la_LIBADD =  \
        $(top_builddir)/sanitizer_common/libsanitizer_common.la \
@@ -436,8 +431,6 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ubsan_handlers.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ 
@am__quote@./$(DEPDIR)/ubsan_handlers_cxx.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ubsan_init.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ 
@am__quote@./$(DEPDIR)/ubsan_init_standalone.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ 
@am__quote@./$(DEPDIR)/ubsan_signals_standalone.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ubsan_type_hash.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ 
@am__quote@./$(DEPDIR)/ubsan_type_hash_itanium.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ 
@am__quote@./$(DEPDIR)/ubsan_type_hash_win.Plo@am__quote@

        Jakub

Reply via email to