Bug iwith setjmp/longjmp on Vax
Chris Torek
chris at umcp-cs.UUCP
Sat Jun 8 13:00:59 AEST 1985
Your code has a nasty little no-no in it: it longjmp's after the stack
environment in which the setjmp was done has been deallocated. No
surprise it fails ``at random''. Watch:
--------#include <setjmp.h>
--------static jmp_buf env;
--------int mode;
--------main() {
active: env=uninit, mode=0, main()
-------- foo();
[expand foo()]
[]------foo() {
active: env=uninit, mode=0, main(), foo()
[]------ mode = setjmp(env);
active: env=foo(), mode=0, main(), foo()
[]------ if (mode != 0) magic();
[]------}
[return to main()]
active: env=foo() [defunct], mode=0, main()
-------- longjmp(env, 1);
Oops.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251)
UUCP: seismo!umcp-cs!chris
CSNet: chris at umcp-cs ARPA: chris at maryland
More information about the Comp.unix.wizards
mailing list