home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.programmer
- Path: sparky!uunet!wupost!gumby!destroyer!caen!hellgate.utah.edu!fcom.cc.utah.edu!gateway.univel.com!gateway.novell.com!terry
- From: terry@npd.Novell.COM (Terry Lambert)
- Subject: Re: register windows and setjmp/longjmp
- Message-ID: <1992Jul28.174201.12612@gateway.novell.com>
- Sender: news@gateway.novell.com (NetNews)
- Nntp-Posting-Host: thisbe.eng.sandy.novell.com
- Organization: Novell NPD -- Sandy, UT
- References: <2203@tivoli.UUCP>
- Date: Tue, 28 Jul 1992 17:42:01 GMT
- Lines: 47
-
- In article <2203@tivoli.UUCP> bjv@shasta.tivoli.com (Brian Vetter) writes:
- >I am working on a program that creates its own lightweight threads (must manage
- >the stacks). To detect stack overflow, I am using the mprotect() system
- >call to create a guard page at the end of the stack. Instead of just dumping
- >core when the stack overflows, I want to exit the failed thread (the others
- >get to keep running).
- >
- >My idea is to use setjmp() at the beginning of each thread to provide a "place"
- >to come back, and to call longjmp() from the bus error handler. To do this,
- >I have to have a separate signal stack (using sigstack() and sigvec()).
- >
- >The guard page works (I get my bus error), but I can't unwind the stack
- >using longjmp(). I'm doing this on a Sun4 (ELC), and I suspect that there
- >is some register window weirdness going on.
- >
- >The function calling setjmp gets control after the longjmp but it gets a
- >bus error as soon as it returns to its caller. The $i7 and $fp registers
- >are foobar when the function calling setjmp() gets control. I tried the
- >#pragma unknown_control_flow for my function but it still doesn't get
- >the correct $i7 and $fp. (If I set them to their correct values by hand
- >in the debugger, everything works ok).
- >
- >After disassembling the setjmp/longjmp code in the library, I'm wondering
- >how they ever work with long stack depths with the register windows.
- >
- >Does anyone know what I'm doing incorrectly? Or am I faced with a
- >bug in SunOS (the rev. is 4.1.1)?
-
- There is a techinical report on wuarchive.wustl.edu entitled
- "Register Windows and User-Space Threads on the SPARC*"
- by David Keppel. It's number is #91-08-01.
-
-
- It's available from FTP, or:
-
- Department of Computer Science and Engineering
- University of Washington
- Seattle, Washington 98195
-
-
-
- Terry Lambert
- terry_lambert@gateway.novell.com
- terry@icarus.weber.edu
- ---
- Disclaimer: Any opinions in this posting are my own and not those of
- my present or previous employers.
-