home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / programm / 3966 < prev    next >
Encoding:
Text File  |  1992-07-28  |  2.4 KB  |  60 lines

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