Boost logo

Boost Users :

Subject: Re: [Boost-users] [regex] Segmentation fault on regex_search only on CentOS
From: Viatcheslav.Sysoltsev_at_[hidden]
Date: 2011-07-15 03:10:54


> 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 ->
> ----------------------------------
> #include<iostream>
> #include"my_exception.h"
>
> using namespace std;
>
> void foo();
> int main()
> {
> try
> {
> foo();
> }
> catch(const my_exception &err)
> {
> cout << err.what();
> }
> //catch(const exception &err)
> //{
> //cout << "OOPs unknown error ";
> //}
>
> cout <<"\n";
> }
> ----------------------------------
>
> dll.cpp ->
> ----------------------------------
> #include"my_exception.h"
>
> void __attribute__ ((visibility("default"))) foo()
> {
> throw my_exception();
> }
> ----------------------------------
>
>
> my_exception.h ->
> ----------------------------------
> #include<exception>
>
> class my_exception: public std::exception
> {
> public:
> virtual const char* what() const throw()
> {
> return "my_exception";
> }
> my_exception()throw(){}
> virtual ~my_exception()throw(){}
> };
> ----------------------------------
>
>
> and the following makefile
>
> makefile ->
> ----------------------------------
> CXX=g++
> all:
> $(CXX) dll.cpp -fvisibility=hidden -fPIC -shared -o libdll.so
> $(CXX) main.cpp -fPIC -L./ -ldll -o main
> clean:
> rm -fr lib*.so main
>
> ----------------------------------

Take a look to
http://gcc.gnu.org/wiki/Visibility
chapter "How to use the new C++ visibility support" and then the section
"Problems with C++ exceptions".


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