home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / progc / fixed300.arj / CDSS0022.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-03-01  |  1.8 KB  |  58 lines

  1. #if 0
  2. From:
  3. Subject:
  4. Status: Works for me on ZTC++ 2.18
  5. #endif
  6.  
  7. #if 0
  8. From uunet.uu.net!xanadu!ravi Fri Jan 18 04:21:27 1991
  9. Received: from proto by nazgul.UUCP id aa05667; Fri, 18 Jan 91 4:21:15 GMT
  10. Received: from zortech by proto.COM id aa02167; Thu, 17 Jan 91 19:21:59 PST
  11. Received: from proto by zortech.UUCP id aa22535; Thu, 17 Jan 91 21:21:19 EST
  12. Received: from uunet by proto.COM id aa02044; Thu, 17 Jan 91 17:22:18 PST
  13. Received: from xanadu.UUCP by uunet.UU.NET (5.61/1.14) with UUCP 
  14.     id AA04987; Thu, 17 Jan 91 17:10:48 -0500
  15. Received: by xanadu  (4.1/SMI-4.0.2) id AA19943; Thu, 17 Jan 91 14:11:14 PST
  16. Date: Thu, 17 Jan 91 14:11:14 PST
  17. From: Ravi Pandya <xanadu!ravi@uunet.uu.net>
  18. Message-Id: <9101172211.AA19943@xanadu >
  19. To: zortech-bugs@proto.com
  20. Subject: DOS386 C++ 2.18 setjmp problem
  21. Status: RO
  22.  
  23. This is an easy problem to fix, but it is insidious and very
  24. dangerous. The jmp_buf type is not being declared sufficiently large
  25. to hold the information that the 386 library routine puts into it,
  26. causing it to overwrite whatever comes next in memory. It can be fixed
  27. by adding "-DM_I386" to the CFLAGS environment variable. Here's a
  28. piece of code that causes the error.
  29.     --ravi
  30.  
  31.     Ravi Pandya
  32.     Xanadu Operating Company
  33.     550 California Avenue
  34.     Suite 101
  35.     Palo Alto, CA 94306
  36.     415 856 4112 ext 122
  37.     415 856 2251 fax
  38.     ravi@xanadu.com
  39.  
  40. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  41. compile with ztc -3 -O setjmp.c
  42. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  43. #endif
  44.  
  45. #include <setjmp.h>
  46. #include <stdio.h>
  47.  
  48. void main (int argc, char * argv[]) {
  49.     struct {
  50.         jmp_buf jump;
  51.         int stomp;
  52.     } foo;
  53.  
  54.     foo.stomp = 666;
  55.     setjmp (foo.jump);
  56.     printf ("stomp changed to %d from 666\n", foo.stomp);
  57. }
  58.