Boost logo

Boost Users :

Subject: [Boost-users] [regex] Segmentation fault on regex_search only on CentOS
From: Narinder Claire (narinder.claire_at_[hidden])
Date: 2011-07-14 18:53:45


I'll illustrate the problem I have seen in the past with an example.
It may or may not be directly or indirectly linked with the seg fault
issue you are seeing. Although mine is not a seg fault, it does
demonstrate very different behaviour between gcc on Centos (4.1.2)
and gcc on Ubuntu (4.5.2)

Consider the following 3 source files:

main.cpp ->

using namespace std;

void foo();
int main()
       catch(const my_exception &err)
               cout << err.what();
       //catch(const exception &err)
               //cout << "OOPs unknown error ";

       cout <<"\n";

dll.cpp ->

void  __attribute__ ((visibility("default"))) foo()
  throw my_exception();

my_exception.h ->

class  my_exception: public std::exception
       virtual const char* what() const throw()
               return "my_exception";
       virtual ~my_exception()throw(){}

and the following makefile

makefile ->
       $(CXX) dll.cpp   -fvisibility=hidden  -fPIC -shared -o
       $(CXX) main.cpp   -fPIC -L./ -ldll   -o main
       rm -fr lib*.so main


Compiled on Centos 5.6 with gcc with the following specs:
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-libgcj-multifile
--enable-java-awt=gtk --disable-dssi --disable-plugin
--with-cpu=generic --host=x86_64-redhat-linux
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-50)

The output is :
terminate called after throwing an instance of 'my_exception'
 what():  my_exception

However compiled  with gcc on Ubuntu 11.04 with specs:
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.5 --enable-shared --enable-multiarch
--with-multiarch-defaults=x86_64-linux-gnu --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib/x86_64-linux-gnu
--without-included-gettext --enable-threads=posix
--libdir=/usr/lib/x86_64-linux-gnu --enable-nls --with-sysroot=/
--enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-plugin --enable-gold
--enable-ld=default --enable-objc-gc
--disable-werror --with-arch-32=i686 --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4)

The output is :

If I execute the Ubuntu compiled binary on Centos I still get the same
'Aborted' output.
If I execute the Centos compiled binary on Ubuntu I get the expected
output of the string 'my_exception'
This suggests that the 'difference' is not coming from the compiler
but from the runtime.

As stated before this may not be related to your seg fault issue but
the authors of regex could most likely tell straight away.

Best Wishes

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at