[Boost-bugs] [Boost C++ Libraries] #13300: boost stacktrace broken on solaris

Subject: [Boost-bugs] [Boost C++ Libraries] #13300: boost stacktrace broken on solaris
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-11-17 18:08:16


#13300: boost stacktrace broken on solaris
------------------------------+---------------------
 Reporter: dkimura@… | Owner: (none)
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: None
  Version: Boost 1.65.0 | Severity: Problem
 Keywords: |
------------------------------+---------------------
 Solaris `dladdr` doesn’t match function signature of most platforms nor
 the signature expected in boost stacktrace sources.

 Solaris: `int dladdr(void* addr, Dl_info* info);`[[br]]
 Darwin: `int dladdr(const void* addr, Dl_info* info);`

 This caused the following build errors on Solaris SPARC and Solaris X86.

 {{{
 location_from_symbol.hpp, line 31: Error: Cannot cast away const or
 volatile.
 location_from_symbol.hpp, line 31: Error: Formal argument 1 of type void*
 in call to dladdr(void*, dl_info*) is being passed const void*.
 frame_unwind.ipp, line 87: Error: Cannot cast away const or volatile.
 frame_unwind.ipp, line 87: Error: Formal argument 1 of type void* in call
 to dladdr(void*, dl_info*) is being passed const void*const.
 }}}

 Following diff seems to fix this issue:

 {{{
 diff -ru a/boost/stacktrace/detail/frame_unwind.ipp
 b/boost/stacktrace/detail/frame_unwind.ipp
 --- a/boost/stacktrace/detail/frame_unwind.ipp Sat Aug 19 16:49:49 2017
 +++ b/boost/stacktrace/detail/frame_unwind.ipp Fri Sep 15 20:12:08 2017
 @@ -84,7 +84,7 @@
  std::string frame::name() const {
  #if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
      ::Dl_info dli;
 +#if defined(__sun)
 + const bool dl_ok = !!::dladdr(const_cast<void *>(addr_), &dli);
 +#else
      const bool dl_ok = !!::dladdr(addr_, &dli);
 +#endif
      if (dl_ok && dli.dli_sname) {
          return boost::core::demangle(dli.dli_sname);
      }
 diff -ru a/boost/stacktrace/detail/location_from_symbol.hpp
 b/boost/stacktrace/detail/location_from_symbol.hpp
 --- a/boost/stacktrace/detail/location_from_symbol.hpp Sat Aug 19
 16:49:49 2017
 +++ b/boost/stacktrace/detail/location_from_symbol.hpp Fri Sep 15
 20:12:51 2017
 @@ -28,7 +28,7 @@
      explicit location_from_symbol(const void* addr) BOOST_NOEXCEPT
          : dli_()
      {
 +#if defined(__sun)
 + if (!::dladdr(const_cast<void *>(addr), &dli_)) {
 +#else
         if (!::dladdr(addr, &dli_)) {
 +#endif
              dli_.dli_fname = 0;
          }
      }
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac10/boost/ticket/13300>
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-11-17 18:15:15 UTC