Opened 12 years ago

Closed 11 years ago

#4452 closed Bugs (fixed)

NDEBUG causes segv in interprocess::managed_mapped_file

Reported by: Richard Murphy <richard.murphy@…> Owned by: Ion Gaztañaga
Milestone: Boost 1.48.0 Component: interprocess
Version: Boost 1.46.1 Severity: Problem
Keywords: NDEBUG interprocess segv Cc:

Description

I have a small test program that uses interprocess::managed_mapped_file almost identically to one of the interprocess library examples - instead of using managed_shared_memory it uses the managed_mapped_file.

The program works fine unless -DNDEBUG is set. If -DNDEBUG is set then the program segvs whilst contructing the managed_mapped_file.

Attachments (1)

boost-interprocess-bug-report.cpp (2.2 KB ) - added by Richard Murphy <richard.murphy@…> 12 years ago.

Download all attachments as: .zip

Change History (6)

by Richard Murphy <richard.murphy@…>, 12 years ago

comment:1 by Ion Gaztañaga, 12 years ago

Resolution: invalid
Status: newclosed

I could not reproduce the bug, I close this as wontfix and reopen it if the bug is reported by another user.

comment:2 by Lénaïc Huard <lhuard@…>, 11 years ago

Milestone: Boost 1.44.0Boost 1.48.0
Resolution: invalid
Status: closedreopened
Version: Boost 1.43.0Boost 1.46.1

I have exactly the same problem with Boost 1.46.1 and even managed to reproduce it with a smaller program.

Here is the code that reproduces the issue:

#include <cstdlib>
#include <boost/interprocess/managed_shared_memory.hpp>

int main()
{
        boost::interprocess::managed_shared_memory aShm( boost::interprocess::create_only, "/toto", 4096 );
        return EXIT_SUCCESS;
}

In my case, this piece of code works when compiled with g++ 4.4. But this program segvs when compiled:

  • with g++ 4.5 or g++ 4.6;
  • with -DNDEBUG (this is really what triggers the bug);
  • with optimizations enabled. -O1 is enough.

I had a look at that and managed to have the above program work with g++-4.6 -O1 -DNDEBUG by one patch on intrusive/detail/tree_algorithms.hpp:

--- /usr/include/boost/intrusive/detail/tree_algorithms.hpp     2011-06-12 08:15:00.000000000 +0200
+++ boost_patch/include/boost/intrusive/detail/tree_algorithms.hpp      2011-07-02 18:09:02.504756424 +0200
@@ -902,6 +902,7 @@
    {
       //Check if commit_data has not been initialized by a insert_unique_check call.
       BOOST_INTRUSIVE_INVARIANT_ASSERT(commit_data.node != 0);
+      ((commit_data.node != 0) ? static_cast<void> (0) : abort());
       node_ptr parent_node(commit_data.node);
       if(parent_node == header){
          NodeTraits::set_parent(header, new_node);

This patch makes the above program works when compiled with -O1 but is not enough for higher level of optimizations. With -O2 and above and the above patch, the program keeps on segfaulting.

This is obviously not an acceptable patch and I need to better understand the issue, but I hope this gives a clue.

comment:3 by clint@…, 11 years ago

I've noticed in gcc 4.5.0 that passing the -fno-tree-pta seems to clear up the issue on all optimization levels.

There is a known issue with pointer analysis in 4.5.0 that this specific fix may be related to.

in reply to:  3 comment:4 by anonymous, 11 years ago

Replying to clint@…:

I've noticed in gcc 4.5.0 that passing the -fno-tree-pta seems to clear up the issue on all optimization levels.

There is a known issue with pointer analysis in 4.5.0 that this specific fix may be related to.

Upon further investigation, this work around doesn't actually solve the problem. Instead, it merely delayed the segmentation fault for my use case.

comment:5 by Ion Gaztañaga, 11 years ago

Resolution: fixed
Status: reopenedclosed

This was fixed in Boost 1.48 marking offset_ptr operations as non-inlineable.

Note: See TracTickets for help on using tickets.