Re: [Boost-bugs] [Boost C++ Libraries] #11204: undefined behavior sanitizer complains about runtime_error thrown in serialization/singleton.hpp before main()

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #11204: undefined behavior sanitizer complains about runtime_error thrown in serialization/singleton.hpp before main()
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-01-27 14:06:26


#11204: undefined behavior sanitizer complains about runtime_error thrown in
serialization/singleton.hpp before main()
--------------------------------------+---------------------------
  Reporter: Georg Sauthoff <mail@…> | Owner: ramey
      Type: Bugs | Status: reopened
 Milestone: To Be Determined | Component: serialization
   Version: Boost Development Trunk | Severity: Problem
Resolution: | Keywords:
--------------------------------------+---------------------------

Comment (by anonymous):

 Okay, an update on this ticket: I have finally managed to have another
 look at it, and here are the conclusions:

 1) I was wrong to say that ramey's fix (see comment:5) does not resolve
 the original problem of the reporter (as in the UBSan still complains).

 It does work indeed for me now on GCC 5.3 with UBSan enabled, it's just
 that after fixing the reported problem, the program would still crash if
 ASan is **also** enabled **due to a different problem**.

 2) The source of the second problem is in `void_caster` and it is actually
 obvious if one attentively reads the backtrace from ASan and the code.

 ASan doesn't like accesses to unknown addresses: `AddressSanitizer: SEGV
 on unknown address 0x000000000008`. This is caused by the constructor
 called just before the `use()` function and the following patch makes the
 problem go away:

 {{{
 --- boost/serialization/void_cast.hpp 2016-01-27 14:46:23.000000000
 +0100
 +++ boost/serialization/void_cast.hpp.orig 2016-01-18 11:50:19.000000000
 +0100
 @@ -180,7 +180,14 @@
  void_caster_primitive<Derived, Base>::void_caster_primitive() :
      void_caster(
          & type_info_implementation<Derived>::type::get_const_instance(),
 - & type_info_implementation<Base>::type::get_const_instance()
 + & type_info_implementation<Base>::type::get_const_instance(),
 + // note:I wanted to displace from 0 here, but at least one
 compiler
 + // treated 0 by not shifting it at all.
 + reinterpret_cast<std::ptrdiff_t>(
 + static_cast<Derived *>(
 + reinterpret_cast<Base *>(8)
 + )
 + ) - 8
      )
  {
      recursive_register();
 }}}

 After seeing this code, I thinks it's quite obvious where the magical
 `0x000000000008` comes from...

 So, having this said, the original problem is indeed solved, and an
 additional problem is at least diagnosed. Shall we keep this ticket open
 for this additional problem, or you would rather like to close it and have
 me open a new ticket for this second issue?

 Of course, the workaround above works for me right now, but it would be
 great to have a better solution out of the box.

 Thanks for your work on `boost::serialization`!

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11204#comment:8>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:19 UTC