Most extraordinary... I have no explanation for this. I did a test on RH
6.1 which worked fine. I replaced sstream (which I don't know about) by
iostream. I used
g++ -otest test.cpp -lsablot -lexpat
to do the build. Correct? If not, could you send a makefile which
produces the crash with this .cpp file?

Does the same happen with Sablot 0.51?

Tom Kaiser

Mark Turner wrote:

 >
 > Hi
 >
 > We have been developing some apps using the Sablot 0.50 library and
 > have recently found a problem and traced it back to Sablotron. Below
 > is some test code which causes a Segmentation Fault when doing a
 > dynamic_cast, but only when I link the sablot ( &expat ) shared 
libraries.
 >
 > #include <stdio.h>
 > #include <sstream>
 > //#include "sablot.h"
 >
 > class A
 > {
 > public:
 >         virtual void dostuff() { std::cout << "A" << std::endl; }
 > };
 >
 > class B : public A
 > {
 > public:
 >         void dostuff() { std::cout << "B" << std::endl; }
 > };
 >
 > void doit(A& a)
 > {
 >         try
 >         {
 >                 B& b = dynamic_cast<B&>(a);                // this
 > dynamic cast causes a SEGMENTATION FAULT
 >                 b.dostuff();
 >         }
 >         catch( ... )
 >         {
 >                 std::cout << "bad cast" << std::endl;
 >         }
 > }
 >
 > int main()
 > {
 >         std::cout <<"start..."<<std::endl;
 >
 >         A* a = new A();
 >         A* b = new B();
 >
 >         doit(*b);                        // this fails
 >
 >         return 1;
 > }
 >
 >
 > Were using Red Hat 7.0. Has anyone else experienced these problems?
 >
 > thanks
 >
 > Mark Turner



Reply via email to