View Bug Activity | Format For Printing
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?..)
gcc hardcodes this for setjmp, vfork etc. already, are you sure it makes a difference? See special_function_p in gcc/calls.c.
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?'
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; }
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
No bug in glibc.