Shared Lib and Exception handling

bridged with qdn.public.qnxrtp.devtools
Post Reply
Rejean Senecal

Shared Lib and Exception handling

Post by Rejean Senecal » Wed Jan 08, 2003 8:12 pm

After converting my static libraries into shared libraries. I discover that exception are not catch if thrown from a function inside the shared library. A signal SIGABRT is send instead!!!

Can some from QWX can confirm this.

Also the following document seem to confirm this problem
http://gcc.gnu.org/gcc-2.95/caveats.html

We are using QNX 6.1.0
Thanks
Rejean Senecal ing.
Oerlikon Contraves - www.oerlikon.ca

Marcin Dzieciol

Re: Shared Lib and Exception handling

Post by Marcin Dzieciol » Wed Jan 08, 2003 11:36 pm

Hello,

What is the target?, how did you build your libs?, do you have a siimple
test case?

Marcin

"Rejean Senecal" <nospam@forums.openqnx.com> wrote in message
news:23863701.1042056753403.JavaMail.fliu@tiger...
After converting my static libraries into shared libraries. I discover
that exception are not catch if thrown from a function inside the shared
library. A signal SIGABRT is send instead!!!
Can some from QWX can confirm this.

Also the following document seem to confirm this problem
http://gcc.gnu.org/gcc-2.95/caveats.html

We are using QNX 6.1.0
Thanks
Rejean Senecal ing.
Oerlikon Contraves - www.oerlikon.ca

Rejean Senecal

Re: Shared Lib and Exception handling

Post by Rejean Senecal » Thu Jan 09, 2003 12:48 pm

The target is a PC104 pentium 266. I see the same problem on our server,a pentium 4 1.3Ghz.

Here is a sample test case I made. When executed, nothing will be catched but a SIGABRT will be raised and it will enter the SignalHandler function.

First the main program.

/*main.cpp*/
#include <stdio.h>
#include <stdlib.h>
#include <iostream.h>
#include <signal.h>
#include "mysharelib.hpp"

void SignalHandler( int sig_no)
{
cout << "signal catched! no " << sig_no << endl;
exit(0);
}

int main(int argc, char *argv)
{
signal(SIGABRT,SignalHandler);
try{
ThrowSomething();
}
catch(...){
cout << "Catch somethihg " << endl;
}
cout << "The end" << endl;
return 0;
}

The makefile does this to compile

QCC -O0 -DNDEBUG -w8 -Wc,-mcpu=pentium,-march=pentium,-fomit-frame-pointer,-freg-struct-return -fhonor-std -fno-builtin -fno-default-inline -I mysharelib -c -o obj/test.o ./test.cpp

QCC -O0 -DNDEBUG -w8 -Wc,-mcpu=pentium,-march=pentium,-fomit-frame-pointer,-freg-struct-return -fhonor-std -fno-builtin -fno-default-inline -o ./main obj/test.o -L mysharelib -l mysharelib


Then the sharelib
/* mysharelib.cpp*/
#include <stdio.h>
#include <stdlib.h>
#include <iostream.h>
#include "mysharelib.hpp"
void ThrowSomething(void)
{
throw(123);
return;
}

And the include
/* mysharelib.hpp */

void ThrowSomething(void);

The makefile for the share lib is

nice QCC -O0 -DNDEBUG -w8 -Wc,-mcpu=pentium,-march=pentium,-fomit-frame-pointer,-freg-struct-return -fhonor-std -fno-builtin -fno-default-inline -shared -fPIC -c -o obj/mysharelib.o ./mysharelib.cpp
echo Linking to ./libmysharelib.so
Linking to ./libmysharelib.so
rm -f ./libmysharelib.so
qcc -o ./libmysharelib.so -shared -W,-soname=./libmysharelib.so obj/mysharelib.o

Colin Burgess

Re: Shared Lib and Exception handling

Post by Colin Burgess » Thu Jan 09, 2003 2:11 pm

qcc -o ./libmysharelib.so -shared -W,-soname=./libmysharelib.so obj/mysharelib.o
Here's your problem. You must tell qcc that your lib is a C++ lib (so it will
link in the exception support objects)

Try

qcc -lang-c++ -o ./libmysharelib.so -shared -W,-soname=./libmysharelib.so obj/mysharelib.o



--
cburgess@qnx.com

Rejean Senecal

Re: Shared Lib and Exception handling

Post by Rejean Senecal » Thu Jan 09, 2003 3:25 pm

Thank you veryyyy much. It works now

Post Reply

Return to “qdn.public.qnxrtp.devtools”