Boost logo

Boost Users :

From: Bear (bjoern_rasmussen_at_[hidden])
Date: 2004-12-07 12:42:10


Hello there

I'm getting a SIGSEGV when using the boost::shared_ptr in my program and
compiling with the g++ -O2 option, whereas if I'm using the g++ -O0 option
my programs works the way it should. My program is multi-threaded but to the
best of my knowledge it is mutex'ed correctly.

I compile my program the following way when using -O2 and -O0

g++ -O0 -ggdb3 -DNDEBUG -DTTSERVER ....
g++ -O2 -ggdb3 -DNDEBUG -DTTSERVER ....

When I use gdb to step through the program (only with 'n') I go into the
shared_count.hpp file when using the -O2 option whereas the version compiled
with -O0 disregards this file in gdb.

The -O2 version of the program crashes in the file checked_delete.hpp and
the member "checked_delete":

template<class T> inline void checked_delete(T * x)
{
    // intentionally complex - simplification causes regressions
    typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
    (void) sizeof(type_must_be_complete);
=> delete x;
}

Here's the gdb output:

Program received signal SIGSEGV, Segmentation fault.
0x08053370 in
boost::detail::sp_counted_base_impl<teamtalk::server::ServerChannel*,
boost::checked_deleter<teamtalk::server::ServerChannel> >::dispose() (
    this=0x8107170) at checked_delete.hpp:36
(gdb)

As I mentioned earlier, the -O0 run without problems. Has anyone experienced
similar problems?

I'm using
Boost 1.31
g++ (GCC) 3.3.2 20031218 (Gentoo Linux 3.3.2-r5, propolice-3.3-7)
GNU gdb 6.0

Kind regards

Bjoern D. Rasmussen


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net