Segfault in Simple Programs with 1.33.1, gcc 4.0.2 on Linux

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Segfault in Simple Programs with 1.33.1, gcc 4.0.2 on Linux

Jonathan Y. Walther
I am having problems building the Boost 1.33.1 libraries using gcc 4.0.2
on a Linux system.   I have used boost:regex for years, but am upgrading
to gcc 4.

All builds appear to complete successfully, but even the simplest
program seg faults upon the first boost usage:

Sample program:

$ cat sp20.cc
#include <boost/regex.hpp>

int main (int argc, char *argv[])
{
  boost::regex setEvent_RE("Set");
}

Build:


$ REGEX_INC=/sps_home/play/install/include/boost-1_33_1
$ REGEX_LIB=/sps_home/play/install/lib/libboost_regex-gcc-d.a
$ g++  -I$REGEX_INC -c sp20.cc  -o sp20.o
$ g++ -o sp20 sp20.o $REGEX_LIB -lstdc++

Execution:

$ ./sp20
Segmentation fault

$ ldd ./sp20
        libstdc++.so.6 => /usr/local/lib/libstdc++.so.6 (0x40018000)
        libm.so.6 => /lib/i686/libm.so.6 (0x40114000)
        libgcc_s.so.1 => /usr/local/lib/libgcc_s.so.1 (0x40137000)
        libc.so.6 => /lib/i686/libc.so.6 (0x40142000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

$ gcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.0.2/configure --enable-languages=c++,f95,c
--prefix=/usr/local --with-gmp=/usr/local/
 --with-mpfr=/usr/local/
Thread model: posix
gcc version 4.0.2

Running in the debugger indicates a seg fault when the boost:regex
constuctor is executed. Here is a trace of the debug session:


[mpguser@speedy play]$ gdb ./sp20
GNU gdb 6.4
Copyright 2005 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...Using host libthread_db
library "/lib/libthread_db.so.1".

(gdb) run
Starting program: /mnt/60GB/sps_home/play/sp20

Program received signal SIGSEGV, Segmentation fault.
0x401cdd37 in __strxfrm_l () at strxfrm.c:99
99      strxfrm.c: No such file or directory.
        in strxfrm.c
gdb) backtrace
#0  0x401cdd37 in __strxfrm_l () at strxfrm.c:99
#1  0x40076965 in std::collate<char>::_M_transform (this=0x0, __to=0x0,
__from=0x0, __n=0) at collate_members.cc:55
#2  0x400a179a in std::collate<char>::do_transform (this=0x400fd204,
__lo=0xbffff48a "a", __hi=0xbffff48b "")
    at
/sps_home/play/objdir/i686-pc-linux-gnu/libstdc++-v3/include/bits/locale_facets.tcc:2354
#3  0x40097d57 in std::collate<char>::transform (this=0x2, __lo=0x0,
__hi=0x0)
    at
/sps_home/play/objdir/i686-pc-linux-gnu/libstdc++-v3/include/bits/locale_facets.h:2544
#4  0x0804e413 in
boost::re_detail::cpp_regex_traits_implementation<char>::transform
(this=0x807e3c8, p1=0xbffff48a "a", p2=0xbffff48b "")
    at
/mnt/60GB/sps_home/play/boost_1_33_1/boost/regex/v4/cpp_regex_traits.hpp:560
#5  0x0804e706 in
boost::re_detail::find_sort_syntax<boost::re_detail::cpp_regex_traits_implementation<char>,
char> (pt=0x807e3c8, delim=0x807e5d4 "")
    at
/mnt/60GB/sps_home/play/boost_1_33_1/boost/regex/v4/primary_transform.hpp:70
#6  0x0805f064 in
boost::re_detail::cpp_regex_traits_implementation<char>::init
(this=0x807e3c8)
    at
/mnt/60GB/sps_home/play/boost_1_33_1/boost/regex/v4/cpp_regex_traits.hpp:729
#7  0x0806d331 in cpp_regex_traits_implementation (this=0x807e3c8,
l=@0xbffff6b4)
    at
/mnt/60GB/sps_home/play/boost_1_33_1/boost/regex/v4/cpp_regex_traits.hpp:417
#8  0x080700ca in
boost::object_cache<boost::re_detail::cpp_regex_traits_base<char>,
boost::re_detail::cpp_regex_traits_implementation<char> >::do_get (
    k=@0xbffff6b4, max_cache_size=5) at
/mnt/60GB/sps_home/play/boost_1_33_1/boost/regex/pending/object_cache.hpp:118
#9  0x080707b9 in
boost::object_cache<boost::re_detail::cpp_regex_traits_base<char>,
boost::re_detail::cpp_regex_traits_implementation<char> >::get (
    k=@0xbffff6b4, max_cache_size=5) at
/mnt/60GB/sps_home/play/boost_1_33_1/boost/regex/pending/object_cache.hpp:69
#10 0x080708dd in boost::re_detail::create_cpp_regex_traits<char>
(l=@0xbffff6f0)
    at
/mnt/60GB/sps_home/play/boost_1_33_1/boost/regex/v4/cpp_regex_traits.hpp:822
#11 0x0807093a in cpp_regex_traits (this=0x807e358) at
/mnt/60GB/sps_home/play/boost_1_33_1/boost/regex/v4/cpp_regex_traits.hpp:842
#12 0x0807097f in regex_traits (this=0x807e358) at
/mnt/60GB/sps_home/play/boost_1_33_1/boost/regex/v4/regex_traits.hpp:68
#13 0x08070993 in regex_traits_wrapper (this=0x807e358) at
/mnt/60GB/sps_home/play/boost_1_33_1/boost/regex/v4/regex_traits.hpp:162
#14 0x080709b7 in regex_data (this=0x807e220) at
/mnt/60GB/sps_home/play/boost_1_33_1/boost/regex/v4/basic_regex.hpp:54
#15 0x08070a25 in basic_regex_implementation (this=0x807e220) at
/mnt/60GB/sps_home/play/boost_1_33_1/boost/regex/v4/basic_regex.hpp:85
#16 0x08070a6c in boost::basic_regex<char, boost::regex_traits<char,
boost::cpp_regex_traits<char> > >::do_assign (this=0xbffff840,
p1=0x80728e8 "Set",
    p2=0x80728eb "", f=0) at
/mnt/60GB/sps_home/play/boost_1_33_1/boost/regex/v4/basic_regex.hpp:517
#17 0x0804c048 in boost::basic_regex<char, boost::regex_traits<char,
boost::cpp_regex_traits<char> > >::assign ()
    at
/mnt/60GB/sps_home/play/boost_1_33_1/boost/regex/v4/cpp_regex_traits.hpp:1003
#18 0x0804c07d in boost::basic_regex<char, boost::regex_traits<char,
boost::cpp_regex_traits<char> > >::assign ()
    at
/mnt/60GB/sps_home/play/boost_1_33_1/boost/regex/v4/cpp_regex_traits.hpp:1003
#19 0x0804c0b6 in boost::basic_regex<char, boost::regex_traits<char,
boost::cpp_regex_traits<char> > >::basic_regex ()
    at
/mnt/60GB/sps_home/play/boost_1_33_1/boost/regex/v4/cpp_regex_traits.hpp:1003
#20 0x0804b037 in main ()


I have recreated this error on two different linux machines, and under
two versions of gcc (4.0.2 and 3.4.5).

I have built with and without BOOST_DISABLE_THREADS, and
-fvisibility=default to no avail.  I have also built with the compiler
set in a non standard location and also later in a standard location
(/usr/local)

Both linux systems are older, Red Hat 7.2 systems on which I have just
recently installed gcc 4.0.2.   The compiler built and installed without
problems, but are otherwise untested.

When I try to run regression tests libs/regex/test/regress, I get the
same segfault behavior.  

run_tests.sh runs, but compiler_status returns the following:

warning: could not find build results for 't_1_33_1/status'.

**** exception(205): std::exception:
boost::filesystem::directory_iterator constructor: "": No such file or dir
ectory
******** errors detected; see standard output for details ********

(I am looking into why this program is looking for 't_1_33_1/status'
instead of 'boost_1_33_1/status')



Based on some googling, it does not appear that this is a known problem,
and I strongly suspect that the problem relates to my particular  
installation, but cannot figure out what to try next.


Any ideas?

Regards,

--
Jonathan Y. Walther
[hidden email]



_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build
Reply | Threaded
Open this post in threaded view
|

Re: Segfault in Simple Programs with 1.33.1, gcc 4.0.2 on Linux

Caleb Epstein-3
On 2/2/06, Jonathan Y. Walther <[hidden email]> wrote:
I am having problems building the Boost 1.33.1 libraries using gcc 4.0.2
on a Linux system.   I have used boost:regex for years, but am upgrading
to gcc 4.

Sounds like a compiler issue.  Your test program works here on g++ version 4.0.3 20060128 (prerelease) (Debian 4.0.2-8) and 1.33.1.  I do seem to have ICU enabled as well though.

[11:22] cae @ tela 534% g++ -o sp20 sp20.cpp -lboost_regex
[11:22] cae @ tela 535% ./sp20
[11:22] cae @ tela 536% ldd sp20
        linux-gate.so.1 =>  (0xffffe000)
        libboost_regex-gcc-mt-1_33_1.so.1.33.1 => /usr/lib/libboost_regex-gcc-mt-1_33_1.so.1.33.1 (0x40028000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x400d1000)
        libm.so.6 => /lib/tls/libm.so.6 (0x401ae000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x401d4000)
        libc.so.6 => /lib/tls/libc.so.6 (0x401df000)
        librt.so.1 => /lib/tls/librt.so.1 (0x40316000)
        libicui18n.so.34 => /usr/lib/libicui18n.so.34 (0x4031f000)
        libicuuc.so.34 => /usr/lib/libicuuc.so.34 (0x4043e000)
        libpthread.so.0 => /lib/tls/libpthread.so.0 (0x40548000)
        /lib/ld- linux.so.2 (0x40000000)
        libicudata.so.34 => /usr/lib/libicudata.so.34 (0x4055a000)

--
Caleb Epstein
caleb dot epstein at gmail dot com
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build
Reply | Threaded
Open this post in threaded view
|

Re: Segfault in Simple Programs with 1.33.1, gcc 4.0.2 on Linux

John Maddock
In reply to this post by Jonathan Y. Walther
> $ REGEX_INC=/sps_home/play/install/include/boost-1_33_1
> $ REGEX_LIB=/sps_home/play/install/lib/libboost_regex-gcc-d.a
> $ g++  -I$REGEX_INC -c sp20.cc  -o sp20.o
> $ g++ -o sp20 sp20.o $REGEX_LIB -lstdc++

Do you need that -lstdc++ there?  Could it be picking up the wrong one?

> Program received signal SIGSEGV, Segmentation fault.
> 0x401cdd37 in __strxfrm_l () at strxfrm.c:99
> 99      strxfrm.c: No such file or directory.
>        in strxfrm.c
> gdb) backtrace
> #0  0x401cdd37 in __strxfrm_l () at strxfrm.c:99
> #1  0x40076965 in std::collate<char>::_M_transform (this=0x0,
> __to=0x0, __from=0x0, __n=0) at collate_members.cc:55
> #2  0x400a179a in std::collate<char>::do_transform (this=0x400fd204,
> __lo=0xbffff48a "a", __hi=0xbffff48b "")

That's worrying: stack frame #2 looks OK, there's a valid "this" address and
the arguments look OK, but stack frame #1 has a null pointer for "this", no
wonder it segfaults!

> I have recreated this error on two different linux machines, and under
> two versions of gcc (4.0.2 and 3.4.5).
>
> I have built with and without BOOST_DISABLE_THREADS, and
> -fvisibility=default to no avail.  I have also built with the compiler
> set in a non standard location and also later in a standard location
> (/usr/local)
>
> Both linux systems are older, Red Hat 7.2 systems on which I have just
> recently installed gcc 4.0.2.   The compiler built and installed
> without problems, but are otherwise untested.
>
> When I try to run regression tests libs/regex/test/regress, I get the
> same segfault behavior.

Darn.

> Based on some googling, it does not appear that this is a known
> problem, and I strongly suspect that the problem relates to my
> particular installation, but cannot figure out what to try next.

No it's not a known problem and we regularly build and test with gcc-4.0.x,
it leads me to suspect that there is some kind of issue with your libstdc++
install, could you try a short test program that uses std::collate?
Something like:

#include <locale>

int main()
{
  std::locale l;
  bool b = l("a", "A");
  return b;
}

I think should probe to see if it's working OK, if that works try
constructing the locale object like this:

std::locale l("en_US");

and see if that reproduces the issue.

Hopefully that will tell is whether it's your gcc install that's to blame.

John.

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build
Reply | Threaded
Open this post in threaded view
|

Re: Segfault in Simple Programs with 1.33.1, gcc 4.0.2 on Linux

Jonathan Y. Walther
In reply to this post by Jonathan Y. Walther
Thanks for your very fast responses.

>> $ REGEX_INC=/sps_home/play/install/include/boost-1_33_1
>> $ REGEX_LIB=/sps_home/play/install/lib/libboost_regex-gcc-d.a
>> $ g++ -I$REGEX_INC -c sp20.cc -o sp20.o
>> $ g++ -o sp20 sp20.o $REGEX_LIB -lstdc++
>
>
>Do you need that -lstdc++ there? Could it be picking up the wrong one?

No, I did not need -lstdc++.   But removing it did not change the behavior.

$ REGEX_LIB=/mnt/60GB/sps_home/play/install/lib/libboost_regex-gcc-d.a
$ REGEX_INC=/mnt/60GB/sps_home/play/install/include/boost-1_33_1
$ g++  -I$REGEX_INC -c sp20.cc  -o sp20.o
$ ./sp20
Segmentation fault



<snip>

>> Based on some googling, it does not appear that this is a known
>> problem, and I strongly suspect that the problem relates to my
>> particular installation, but cannot figure out what to try next.
>
>
>No it's not a known problem and we regularly build and test with >gcc-4.0.x,
>it leads me to suspect that there is some kind of issue with your >libstdc++
>install, could you try a short test program that uses std::collate?
>Something like:
>
>
>#include <locale>
>
>
>int main()
>{
>  std::locale l;
>  bool b = l("a", "A");
>  return b;
>}


No, this does not work:


$ cat jmTest.cc
#include <locale>
int main()
{
  std::locale l;
  bool b = l("a", "A");
  return b;
}

$ g++  -I$REGEX_INC -c jmTest.cc -o jmTest.o
jmTest.cc: In function 'int main()':
jmTest.cc:5: error: no match for call to '(std::locale) (const char [2], const char [2])'


Or, more to the point:

$ g++  -c jmTest.cc -o jmTest.o
jmTest.cc: In function 'int main()':
jmTest.cc:5: error: no match for call to '(std::locale) (const char [2], const char [2])'


I am not familiar with the locale include, but I gather that this should
work, and the fact that is does not indicates problems with my
installation of gcc.  Looks like I need to run the gcc test suite.   If
I were to guess, it seems like there are multiple versions of this
include, and perhaps gcc4 is finding the wrong one.  And somehow I
managed to confuse both linux systems that I installed it on.

If anyone has any further suggestions, I would be happy to hear them,
but it seems like a compiler issue.



Thanks again,


--
Jonathan Y. Walther
[hidden email]



_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build
Reply | Threaded
Open this post in threaded view
|

Re: Segfault in Simple Programs with 1.33.1, gcc 4.0.2 on Linux

John Maddock
> Or, more to the point:
>
> $ g++  -c jmTest.cc -o jmTest.o
> jmTest.cc: In function 'int main()':
> jmTest.cc:5: error: no match for call to '(std::locale) (const char
> [2], const char [2])'

!!! My mistake, this one does work:

#include <locale>
int main()
{
  std::locale l;
  bool b = l(std::string("a"), std::string("A"));
  return b;
}

Hopefully that will tell you if libstdc++ is working OK: it certainly should
be, but I can't think of anything else right now.

John.

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build
Reply | Threaded
Open this post in threaded view
|

Re: Segfault in Simple Programs with 1.33.1, gcc 4.0.2 on Linux

Caleb Epstein-3
In reply to this post by Jonathan Y. Walther
On 2/2/06, Jonathan Y. Walther <[hidden email]> wrote:

No, this does not work:


$ cat jmTest.cc
#include <locale>
int main()
{
  std::locale l;
  bool b = l("a", "A");
  return b;
}

Change the call to:

    bool b = l(std::string("a"), std::string("A"));

I get a return value of 0.

--
Caleb Epstein
caleb dot epstein at gmail dot com
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build