public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* __builtin_setjmp/__builtin_longjmp Implementation Implementation
@ 2007-02-02  7:24 王 刚伟
  2007-02-02 11:52 ` John Love-Jensen
  0 siblings, 1 reply; 5+ messages in thread
From: 王 刚伟 @ 2007-02-02  7:24 UTC (permalink / raw)
  To: gcc-help

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=gb2312; format=flowed, Size: 542 bytes --]

Hi all:
In gcc4.1.1/gcc/unwind-sjlj.c.
#define setjmp __builtin_setjmp
#define longjmp __builtin_longjmp

the implementation of them are "expand_builtin_setjmp" and 
"expand_builtin_longjmp"  in gcc4.1.1/gcc/builtins.c?

My program about exception handle crashs ,when "longjmp" is called to 
restore context,and registers are not restored correctly.

thank you:)

--David

_________________________________________________________________
ÏíÓÃÊÀ½çÉÏ×î´óµÄµç×ÓÓʼþϵͳ¡ª MSN Hotmail¡£  http://www.hotmail.com  

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

* Re: __builtin_setjmp/__builtin_longjmp Implementation  Implementation
  2007-02-02  7:24 __builtin_setjmp/__builtin_longjmp Implementation Implementation 王 刚伟
@ 2007-02-02 11:52 ` John Love-Jensen
  2007-02-02 12:18   ` __builtin_setjmp/__builtin_longjmp Implementation 王 刚伟
  0 siblings, 1 reply; 5+ messages in thread
From: John Love-Jensen @ 2007-02-02 11:52 UTC (permalink / raw)
  To: 王 刚伟 , MSX to GCC

Hi David,

> My program about exception handle crashs ,when "longjmp" is called to
> restore context,and registers are not restored correctly.

Is your program a C program?  A C++ program?

If it is a C++ program, are you using C++ exceptions (try/throw/catch)?  If
you are using C++ exceptions, you cannot interleave C++ exceptions and
setjmp/longjmp.

Are you using the volatile qualifier on stack variables outside the context
of the setjmp, if they are used within the context of the body of the
setjmp?

Without more information, it will be very difficult to diagnose the problem
you are experiencing.

Sincerely,
--Eljay

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

* Re: __builtin_setjmp/__builtin_longjmp Implementation
  2007-02-02 11:52 ` John Love-Jensen
@ 2007-02-02 12:18   ` 王 刚伟
  2007-02-02 13:06     ` John Love-Jensen
  0 siblings, 1 reply; 5+ messages in thread
From: 王 刚伟 @ 2007-02-02 12:18 UTC (permalink / raw)
  To: eljay, gcc-help

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=gb2312; format=flowed, Size: 1861 bytes --]

Hi Eljay,

   when I established my compiler ,I set my configure options as:
../gcc-4.1-20060407/configure --target=sh-elf --host=i686-pc-cygwin 
--build=i686-pc-cygwin --prefix=$PREFIX --with-newlib --with-gnu-as 
--with-gnu-ld --enable-threads --enable-languages=c,c++ 
--enable-version-specific-runtime-libs --enable-sjlj-exceptions

  My program is a c++ program ,and uses etry/throw/catch.I tried to compile 
my program with GCC,you know,with "--enable-sjlj-exceptions" configured, 
the compiler will process the exception with a setjmp/longjmp mechanism.but 
My program crashed.
 
  Should I try the other exception handling mechanism "dwarf2 mechanism" ? 
If I want to try,only need I change the "--enable-sjlj-exceptions" as 
"--with-dwarf2"?

  thank you !

  Sincerely,
--David

>From: John Love-Jensen <eljay@adobe.com>
>To: Íõ ¸Õΰ <gwwang10@hotmail.com>,        MSX to GCC 
<gcc-help@gcc.gnu.org>
>Subject: Re: __builtin_setjmp/__builtin_longjmp Implementation 
Implementation
>Date: Fri, 02 Feb 2007 05:51:48 -0600
>
>Hi David,
>
> > My program about exception handle crashs ,when "longjmp" is called to
> > restore context,and registers are not restored correctly.
>
>Is your program a C program?  A C++ program?
>
>If it is a C++ program, are you using C++ exceptions (try/throw/catch)?  
If
>you are using C++ exceptions, you cannot interleave C++ exceptions and
>setjmp/longjmp.
>
>Are you using the volatile qualifier on stack variables outside the 
context
>of the setjmp, if they are used within the context of the body of the
>setjmp?
>
>Without more information, it will be very difficult to diagnose the 
problem
>you are experiencing.
>
>Sincerely,
>--Eljay
>

_________________________________________________________________
ÓëÁª»úµÄÅóÓѽøÐн»Á÷£¬ÇëʹÓà MSN Messenger:  http://messenger.msn.com/cn  

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

* Re: __builtin_setjmp/__builtin_longjmp Implementation
  2007-02-02 12:18   ` __builtin_setjmp/__builtin_longjmp Implementation 王 刚伟
@ 2007-02-02 13:06     ` John Love-Jensen
  2011-04-03  7:45       ` licheng
  0 siblings, 1 reply; 5+ messages in thread
From: John Love-Jensen @ 2007-02-02 13:06 UTC (permalink / raw)
  To: 王 刚伟 , MSX to GCC

Hi David,

My first suspicion is that your setjmp/longjmp is interleaved with C++
exception handling mechanism (regardless if the mechanism is sjlj or
something else).

Those two mechanisms do not play nice together.

Since you are programming in C++, I strongly recommend that you remove all
setjmp/longjmp code, and solely use the C++ exception mechanism.

If you cannot do that, I strongly recommend that you only use C code inside
the context of the setjmp body, which should insure that you never leak an
exception out of the context of the setjmp body, nor that you interleave
setjmp/longjmp and C++ exceptions.

Otherwise, since it interleaving them won't work in software, you'll have to
fix the problem in marketing, and have them sell random crashes as a
feature.

HTH,
--Eljay

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

* Re: __builtin_setjmp/__builtin_longjmp Implementation
  2007-02-02 13:06     ` John Love-Jensen
@ 2011-04-03  7:45       ` licheng
  0 siblings, 0 replies; 5+ messages in thread
From: licheng @ 2011-04-03  7:45 UTC (permalink / raw)
  To: gcc-help

John Love-Jensen <eljay <at> adobe.com> writes:

> 
> Hi David,
> 
> My first suspicion is that your setjmp/longjmp is interleaved with C++
> exception handling mechanism (regardless if the mechanism is sjlj or
> something else).
>


i have got the same problem, but i don't understand what you means!
my project have c,c++,and java files,use gcc and gcj and sjlj.

my project hava setjmp/longjmp,but it's all in c files, you have say "I strongly
recommend that you only use C code inside the context of the setjmp body",is
that means c file is ok to hava setjmp/longjmp?





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

end of thread, other threads:[~2011-04-03  7:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-02  7:24 __builtin_setjmp/__builtin_longjmp Implementation Implementation 王 刚伟
2007-02-02 11:52 ` John Love-Jensen
2007-02-02 12:18   ` __builtin_setjmp/__builtin_longjmp Implementation 王 刚伟
2007-02-02 13:06     ` John Love-Jensen
2011-04-03  7:45       ` licheng

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).