[Boost-bugs] [Boost C++ Libraries] #10432: 32-bit offset_ptr crashes on 64-bit platform

Subject: [Boost-bugs] [Boost C++ Libraries] #10432: 32-bit offset_ptr crashes on 64-bit platform
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-08-31 13:13:20

#10432: 32-bit offset_ptr crashes on 64-bit platform
 Reporter: andysem | Owner: igaztanaga
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: interprocess
  Version: Boost 1.56.0 | Severity: Problem
 Keywords: offset_ptr |
 There seem to be problems with handling offset_ptrs with 32-bit offsets on
 a 64-bit platform. The attached code sample tries to create a file mapping
 with managed_external_buffer using 32-bit offset_ptrs. The program crashes
 sometimes when trying to initialize the mapping (see the attached valgrind
 log for one of such crashes). The offset_ptr is declared as follows:

 typedef boost::interprocess::offset_ptr< void, std::ptrdiff_t,
 std::int32_t > void_pointer;

 My theory is that there are incorrect offset conversions somewhere in
 Boost.Interprocess which sometimes result in incorrect pointers and a
 subsequent crash. This may not happen on every run of the program because
 the mapping address of the file region can change between runs.

 One of the problems with 32-bit offset_ptrs is that its implementation
 performs implicit casts of the offset to std::size_t (see calls to
 offset_ptr_to_raw_pointer and offset_ptr_to_offset), which makes incorrect
 result if the offset type is unsigned and smaller than std::size_t. I
 didn't find any restrictions on the offset type in the docs or the code,
 and by default the offset type is unsigned. IMO, the code should be
 corrected to perform sign extension of the offset or restrict the offset
 type to be signed integers. This should be documented as well.

 However, even if my program uses a signed offset type, it still crashes,
 so there have to be other issues elsewhere.

 I tested this on Kubuntu 14.04 x86_64.

Ticket URL: <https://svn.boost.org/trac/boost/ticket/10432>
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:16 UTC