threads without kernel mods
Chris Torek
torek at elf.ee.lbl.gov
Sun Jun 2 22:27:31 AEST 1991
In article <10728 at castle.ed.ac.uk> simon at castle.ed.ac.uk (Simon Brown) writes:
[an involved method for guaranteeing up-stack-jumps]
>But this is pretty slow, as it needs to handle a signal on each reschedule.
>And pretty disgusting too, come to think of it.
Indeed. :-)
>Such as a change which causes longjmp to destructively unwind the stack, say.
>(I seem to have a vague clouded memory that the V7 longjmp did this? Or maybe
>it was 4.1BSD)
4BSD VAX longjmps have done this for some time. It correctly restores
the values of registers, so that
register int f = 0;
(void) setjmp(label);
printf("%d\n", ++f);
longjmp(label, 1);
prints
1
2
3
.
.
.
Many `typical' implementations print
1
1
1
.
.
.
The BSD Vax unwind looks essentially like this:
while (fp != desired frame) {
if (we are above the desired frame) {
write(2, "longjmp botch\n", 14);
dump core;
}
stuff our own address into the return pc;
``return'';
}
and hence if you have mucked with the stack, and the frames are not
in a single chain leading to the top, you will lose out. The BSD tahoe
unwind is almost identical.
--
In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 415 486 5427)
Berkeley, CA Domain: torek at ee.lbl.gov
More information about the Comp.unix.internals
mailing list