#54 5.0.2 / 5.1.0: SEGV on RHEL3 using -O3 compiler option

5.0
closed-rejected
3
2006-12-07
2006-08-01
Mark Usher
No

The follow program generates a segmentation fault when
compiled with gcc 3.2.3 under Red Hat Enterprise Linux
3.0 using optimisation level -O3

This happens both with STLport 5.0.2 and 5.1.0 RC1

Note: the bool in class C is important! without this
bool, no SEGV occurs!

stlport_crash.cpp:

#include <string>
#include <vector>
#include <map>
#include <stdio.h>

class C
{
public:
bool B;
std::vector<std::string> V;
};

int main (int argc, char** argv)
{
std::map<std::string, C> M;

C a;
a.V.push_back ("01234567890123456789");
M.insert (std::pair<std::string, C> ("", a));

return 0;

}

g++ -O3 -DNDEBUG -DTHREAD_SAFE -D_REENTRANT
-fexceptions -I"/STLport-5.1.0/stlport"
-L"/usr/lib/gcc-lib/i386-redhat-linux/3.2/"
-L"/STLport-5.1.0/lib" -lc -lstdc++ -lrt -lstlport
./stlport_crash.cpp -o ./stlport_crash

./stlport_crash
free(): invalid pointer 0x8066188!
Segmentation fault

(gdb)
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1218555776 (LWP 18744)]
0x00bfd2a7 in _int_free () from /lib/tls/libc.so.6
(gdb) bt
#0 0x00bfd2a7 in _int_free () from /lib/tls/libc.so.6
#1 0x00bfc278 in free () from /lib/tls/libc.so.6
#2 0x00fa6203 in operator delete () from
/usr/lib/libstdc++.so.5
#3 0x08049456 in stlp_std::basic_string<char,
stlp_std::char_traits<char>, stlp_std::allocator<char>
>::~basic_string ()
#4 0x08049978 in
stlp_std::__destroy_range_aux<stlp_std::reverse_iterator<stlp_std::basic_string<char,
stlp_std::char_traits<char>, stlp_std::allocator<char>
>*>, stlp_std::basic_string<char,
stlp_std::char_traits<char>, stlp_std::allocator<char>
> > ()
#5 0x080490d2 in main ()

Discussion

    • priority: 5 --> 3
    • assigned_to: nobody --> complement
     
    • status: open --> closed-rejected
     
  • Logged In: YES
    user_id=615813
    Originator: NO

    Compiler bug. Not STLport issue.