This is sources Bugzilla
Bugzilla Version 2.17.5
Bugzilla Bug 4662
  setjmp doesn't specify __attribute__((returns_twice)) Last modified: 2007-08-22 04:04
     Query page      Enter new bug
Bug#: 4662   Hardware:   Reporter: Ryan Cocks <bugzilla@ryancocks.net>
Host: Target: Build:
Product:     Add CC:
Component:   Version:   CC:
Remove selected CCs
Status: RESOLVED   Priority:  
Resolution: INVALID   Severity:  
Assigned To: Ulrich Drepper <drepper@redhat.com>   Target Milestone:  
Flags: Requestee:
  backport ()
  examined ()
  testsuite ()
Summary:
Keywords:

Attachment Description Type Created Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 4662 depends on: Show dependency tree
Show dependency graph
Bug 4662 blocks:

Additional Comments:


Leave as RESOLVED INVALID
Reopen bug
Mark bug as VERIFIED

View Bug Activity   |   Format For Printing


Description:   Last confirmed: 0000-00-00 00:00 Opened: 2007-06-18 16:52
Working recently on ARM i found my this pointer was being corrupted in a method
containing a setjmp.

When exiting the setjmp via the longjmp the this pointer had been incremented.

There was quite a lot of code between where the setjmp and the longjmp were
called, and the this pointer wasn't used for the tail end of that code. Gcc was
clobbering the this pointer when it went out of use, incrementing it to refer to
a member variable.

That behaviour should be prevented with __attribute__((returns_twice)) in the
headers, likewise for vfork, but returns_twice doesn't seem to be specified
anywhere in glibc (cvs.)

I can try and put a test case together, I refrained so far because I'm a little
busy and it seems obvious that the flag needs to be specified. (and perhaps
implemented in gcc too?..)

------- Additional Comment #1 From Jakub Jelinek 2007-06-18 17:56 -------
gcc hardcodes this for setjmp, vfork etc. already, are you sure it makes
a difference?
See special_function_p in gcc/calls.c.

------- Additional Comment #2 From Ryan Cocks 2007-06-19 10:21 -------
Looks like what you say is true, but if I run a build of our codebase with
-save-temps and take a look at the pre-processor output the symbol being called
is '_setjmp'. It looks to me like that gcc code only spots 'setjmp' and
'syscall_setjmp?'

------- Additional Comment #3 From Jakub Jelinek 2007-06-19 10:33 -------
Even _setjmp is considered to return twice:
      /* Disregard prefix _, __ or __x.  */
      if (name[0] == '_')
        {
          if (name[1] == '_' && name[2] == 'x')
            tname += 3;
          else if (name[1] == '_')
            tname += 2;
          else
            tname += 1;
        }

------- Additional Comment #4 From Ryan Cocks 2007-06-19 15:45 -------
I guess I'm going to have to make up that testcase then, and raise this with the
gcc folk instead [as its evidently a compiler bug wrt returns_twice]

Cheers,

r

------- Additional Comment #5 From Ulrich Drepper 2007-08-22 04:04 -------
No bug in glibc.

     Query page      Enter new bug
Actions: New | Query | bug # | Reports | Requests   New Account | Log In