public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Charles Y. Kim" <ckim@telcontar.com>
To: "'Janis Johnson'" <janis187@us.ibm.com>
Cc: <gcc@gcc.gnu.org>
Subject: RE: Throw/Catch not working in SO?
Date: Mon, 14 Oct 2002 18:39:00 -0000	[thread overview]
Message-ID: <001001c273e0$ce95af60$7201000a@sanjose.telcontar.com> (raw)
In-Reply-To: <20021014171542.A10842@us.ibm.com>

Good points Janis.  Here are a few answers.

I've tried building the SO with the -fPIC flag.  The shared object is being
built with "g++ -shared".

Do I have to do something special when I open up the SO with dlopen?  I've
tried using dlopen("...", RTLD_NOW/LAZY || RTLD_GLOBAL) and those don't seem
to do anything either.  I've added -Wl,-E to the link line as well, but to
no avail.

This works in other platforms... I'm just stumped as to why it might not
work with Linux.  Also, this is a multithreaded app, and the actual SO is
FAR more complex than the code sample below.

I can see that throw is being called because I've checked out the stack
trace in GDB.

- Charles



-----Original Message-----
From: Janis Johnson [mailto:janis187@us.ibm.com]
Sent: Monday, October 14, 2002 5:16 PM
To: Charles Y. Kim
Cc: gcc@gcc.gnu.org
Subject: Re: Throw/Catch not working in SO?


On Mon, Oct 14, 2002 at 03:37:40PM -0700, Charles Y. Kim wrote:
> Hi all,
>
> I'm using some exception handling in a shared object, and while the
> throw()/catch() works in both Windows and FreeBSD (using GCC 2.96), in
Linux
> (GCC 3.02 --enable-shared --enable-threads=posix) the throw is executed,
and
> the catch never happens.
>
> For example... let's say I have the following code in the shared object...
>
> void error() {
> 	throw(1);
> }
>
> void error2() {
> 	error();
> }
>
> void function() {
> 	try {
> 		if (blah)
> 			error2();
> 	}
> 	catch(...) {
> 		printf("exception caught");
> 	}
> }
>
> I know that error2() is being called and the exception is being thrown...
> but it's not being caught at all.
>
> Does anyone have ANY ideas?

It works fine for me with GCC 3.0.4 on i686-pc-linux-gnu, but I
can't tell what I might have done differently.

Your code fragment isn't complete (it can't be compiled without
additional code added), and you don't say how you built your shared
object or how you know that error2 was called.  If you provide a
complete example, someone might be able to help.

Janis

  reply	other threads:[~2002-10-15  0:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-14 17:36 Charles Y. Kim
2002-10-14 18:38 ` Janis Johnson
2002-10-14 18:39   ` Charles Y. Kim [this message]
2002-10-14 21:14     ` Fergus Henderson
2002-10-15  2:45 Rob

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='001001c273e0$ce95af60$7201000a@sanjose.telcontar.com' \
    --to=ckim@telcontar.com \
    --cc=gcc@gcc.gnu.org \
    --cc=janis187@us.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).