public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Exception handling with shared libraries
@ 2002-08-07 10:07 Paolo Mosna
  2002-08-07 13:36 ` bjorn rohde jensen
  0 siblings, 1 reply; 2+ messages in thread
From: Paolo Mosna @ 2002-08-07 10:07 UTC (permalink / raw)
  To: gcc-help

   Hope this is the right mailing list.

I have strange problems with gcc version 2.96 20000731 (Red Hat Linux
7.1 2.96-98)
(obtained with the command gcc -v) and
with kernel  2.4.7-10 #1 Thu Sep 6 17:27:27 EDT 2001 i686 unknown
(otained with uname -a command)
using exception handling with shared libraries.
I have done a deep search on internet but I have not found somthing
similar to my problems.

This is the situation.

I have defined my  exception class as follows in the file Exception.h
and Exception.cc

class Exception{
...
... // My basic code
...
};

and I have created a first shared library libGCASUtils.so with the
following command:

(1) compiling:
g++ -DNO_DEBUG -fPIC -DLIN -DLININTEL -DCSFDB -funsigned-char -Wall
-DCSFDB -O3 -DNDEBUG  -D_REENTRANT -D_THREAD_SAFE
-D"__DEBUG__"-DNO_DEBUG -fPIC -DLIN -DLININTEL -DCSFDB -funsigned-char
-Wall  -DCSFDB -O3 -DNDEBUG  -I. -I.. -I/src/cleditor -I/src/clstepcore
-I/src/clutils -I/src/cldai -I -I
-I/usr/local/nana/nana-bin-2.5/include
-I/usr/local/commonC++/commoncpp-bin-2-0.99.4/include/cc++2 -c Exception.cc

(2) linking:
g++ -shared -Wl,-export-dynamic --shared-libgcc -o libGCASUtils.so
Exception.o Logger.o LoggerManager.o GenericDataVector.o Link.o Node.o
GenericDataNode.o GenericDataLink.o Graph.o
-L/usr/lib/gcc-lib/i386-redhat-linux/2.96 -lgcc
-L/usr/local/commonC++/commoncpp-bin-2-0.99.4/lib -lccgnu2 -lccext2
-pthread -ldl -lz -lxml -lxml2 -L/usr/local/nana/nana-bin-2.5/lib -lnana

at this point I have the shared library: libGCASUtils.so


Then I have a .cc file with a class ImportManager and a
method importSTEPFile(...) that throws an exception
as below reported:

class ImportManager {

static void importSTEPFile(...) throw (GCAS::Exception);

}

I have created another shared library with this class with the following
steps:

(1) compilation:
g++ -DNO_DEBUG -fPIC -DLIN -DLININTEL -DCSFDB -funsigned-char -Wall
-DCSFDB -O3 -DNDEBUG  -D_REENTRANT -D_THREAD_SAFE -D"__TRACE__"
-D"__DEBUG__"  -I. -I.. -I/usr/local/STEP/scl3-2/src/cleditor
-I/usr/local/STEP/scl3-2/src/clstepcore
-I/usr/local/STEP/scl3-2/src/clutils -I/usr/local/STEP/scl3-2/src/cldai
-I/usr/local/STEP/scl3-2/data/ap214/lib
-I/usr/local/STEP/scl3-2/arch-gcc-linux2.4.7.10-none
-I/usr/local/nana/nana-bin-2.5/include
-I/usr/local/commonC++/commoncpp-bin-2-0.99.4/include/cc++2
-I/home/paolo/workspace/CPPReuse/utils/include/
-I/usr/local/CASCADE/CASCADE-bin-4.0/ref/inc -c ImportManager.cc

(2) linking
g++ -shared -Wl,-export-dynamic -g --shared-libgcc --export-dynamic  -o
libCEScore.so needFunc.o Part.o Assembly.o Element.o Interaction.o
DirectContact.o ProximityInteraction.o STEPWrapper.o PartManager.o
ImportManager.o GlobalResources.o GeoTopology.o
-L/usr/lib/gcc-lib/i386-redhat-linux/2.96 -L/lib -lgcc -lstdc++
-L/usr/local/STEP/scl3-2/arch-gcc-linux2.4.7.10-none/Probes/ap214
-lCap214 -L/usr/local/STEP/scl3-2/arch-gcc-linux2.4.7.10-none/lib
-lCedcore -lCutils -lCdai
-L/usr/local/commonC++/commoncpp-bin-2-0.99.4/lib -lccgnu2 -lccext2
-pthread -ldl -lz -lxml -lxml2
-L/home/paolo/workspace/CPPReuse/utils/src -lGCASUtils
-L/usr/local/CASCADE/CASCADE-bin-4.0/ref/Linux/lib -lTKernel -lTKV3d
-lTKG3d -lTKService -lTKPrim -lTKBRep -lTKTopAlgo -lTKPShape -lPTKernel
-lTKShapeSchema -lTKIGESStd -lTKSTEPStd -lTKVRML -lTKSTL -lTKXSBase
-lTKShHealingStd -lTKCDF -lTKPCAF -lTKFillet -lTKjcas -lTKOffset
-lTKShHealing -lTKIGES -lTKSTEP -lTKFeat -lTKGeomAlgo -lTKGeomBase
-lTKBool -lTKV2d -lTKHLR -lTKG2d -lTKMath -L/usr/X11R6/lib -lGL -lXext
-lX11 -lm -L/usr/local/nana/nana-bin-2.5/lib -lnana

At this time I have a new shared library libCEScore.so.

Now I have the wollowing code in the main application:

      43    try{
      44
      45       ImportManager::importSTEPFile(argv[1], pPartMgr);
      46
      47    }catch(GCAS::Exception &e){
      48       e.Report();
      49       LoggerManager::TRACE_INFO("main","Unable to import the
STEP file.", DEBUG_1);
      50       LoggerManager::TRACE_LOCAL_STDOUT("Unable to import the
STEP file.");
      51       LoggerManager::TRACE_LOCAL_STDOUT("Program aborted.");
      52
      53       LoggerManager::TRACE_EXIT("main","int main(int argc, char
* argv [])");
      54
      55       delete pPartMgr;
      56       delete pLM;
      57
      58       cout << "Here we are" << endl;
      59
      60    }
      61
      62    cout << "Before exit" << endl;
      63
      64    return 0;

The compilation and linking of the code are OK as reported below

compiling main.cc

g++ -D_REENTRANT -D_THREAD_SAFE -D"__TRACE__" -D"__DEBUG__"  -I. -I..
-I/usr/local/STEP/scl3-2/src/cleditor
-I/usr/local/STEP/scl3-2/src/clstepcore
-I/usr/local/STEP/scl3-2/src/clutils -I/usr/local/STEP/scl3-2/src/cldai
-I/usr/local/STEP/scl3-2/data/ap214/lib
-I/usr/local/STEP/scl3-2/arch-gcc-linux2.4.7.10-none
-I/usr/local/nana/nana-bin-2.5/include
-I/usr/local/commonC++/commoncpp-bin-2-0.99.4/include/cc++2
-I/home/paolo/workspace/CPPReuse/utils/include/
-I/usr/local/CASCADE/CASCADE-bin-4.0/ref/inc
-I/home/paolo/workspace/CES/CPPcore/src  -c main.cc

Linking ...

g++ --shared-libgcc --export-dynamic -dc -i -Wl -o geoModule main.o
/home/paolo/workspace/CES/CPPcore/src/libCEScore.a
-L/usr/lib/gcc-lib/i386-redhat-linux/2.96 -L/lib -lgcc -lstdc++
-L/usr/local/STEP/scl3-2/arch-gcc-linux2.4.7.10-none/Probes/ap214
-lCap214 -L/usr/local/STEP/scl3-2/arch-gcc-linux2.4.7.10-none/lib
-lCedcore -lCutils -lCdai
-L/usr/local/CASCADE/CASCADE-bin-4.0/ref/Linux/lib -lTKernel -lTKV3d
-lTKG3d -lTKService -lTKPrim -lTKBRep -lTKTopAlgo -lTKPShape -lPTKernel
-lTKShapeSchema -lTKIGESStd -lTKSTEPStd -lTKVRML -lTKSTL -lTKXSBase
-lTKShHealingStd -lTKCDF -lTKPCAF -lTKFillet -lTKjcas -lTKOffset
-lTKShHealing -lTKIGES -lTKSTEP -lTKFeat -lTKGeomAlgo -lTKGeomBase
-lTKBool -lTKV2d -lTKHLR -lTKG2d -lTKMath
-L/usr/local/commonC++/commoncpp-bin-2-0.99.4/lib -lccgnu2 -lccext2
-pthread -ldl -lz -lxml -lxml2
-L/home/paolo/workspace/CPPReuse/utils/src -lGCASUtils -L/usr/X11R6/lib
-lGL -lXext -lX11 -lm  -L/usr/local/nana/nana-bin-2.5/lib -lnana

At this point I run the program with a wrong file name:

  ./geoModule skjs

and this is the result:

The input file skjs is not a good file!
Exception: Not a good file. Check-out trace file.
LOCAL TRACING >> Unable to import the STEP file.
LOCAL TRACING >> Program aborted.
Here we are
Segmentation fault

It seems that the exception is properly thrown,
and that the same exception is properly catched but when
the execution terminates the catch bloch (catch {})
the application crashes....???

What is the problem???

Thank's in advance for any help.

Paolo Mosna.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Exception handling with shared libraries
  2002-08-07 10:07 Exception handling with shared libraries Paolo Mosna
@ 2002-08-07 13:36 ` bjorn rohde jensen
  0 siblings, 0 replies; 2+ messages in thread
From: bjorn rohde jensen @ 2002-08-07 13:36 UTC (permalink / raw)
  To: pmosna; +Cc: gcc-help

Hi Paolo,

 I have had similar experiences playing with dynamic
loading and unloading of shared objects, where i was
too quick to unload the shared objects in the exception
handling parts. I had unloaded the shared objects before
the exception class' destructor had run causing a
predictable problem;) This sort of thing will show up
in a stack trace under gdb as a call to an unknown method,
that is with ?? instead of method name and such. Just a
thought:)

Yours sincerely,

Bjorn

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-08-07 20:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-07 10:07 Exception handling with shared libraries Paolo Mosna
2002-08-07 13:36 ` bjorn rohde jensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).