home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / aix / 9377 < prev    next >
Encoding:
Text File  |  1992-09-03  |  3.8 KB  |  82 lines

  1. Newsgroups: comp.unix.aix
  2. Path: sparky!uunet!portal!kdenning
  3. From: kdenning@portal.hq.videocart.com (Karl Denninger)
  4. Subject: Re: AIX malloc and fault tolerance
  5. Message-ID: <1992Sep4.044125.861@portal.hq.videocart.com>
  6. Summary: I've been nailed by this here.
  7. Organization: VideOcart Inc.
  8. References: <1992Sep3.135156.9166@medtron.medtronic.com>
  9. Date: Fri, 4 Sep 1992 04:41:25 GMT
  10. Lines: 70
  11.  
  12. In article <1992Sep3.135156.9166@medtron.medtronic.com> sh0001@israel (Scott Hansohn) writes:
  13. >In AIX, a nonzero return from malloc does not guarantee that the
  14. >memory requested has been allocated to the process.  Neither does
  15. >a successful launch of a program containing a large static buffer
  16. >guarantee that the buffer may be fully usable.
  17. >
  18. >    program: Hey malloc!  I'd like a few megabytes please.
  19. >    malloc:  No problem, here you go -- it's at this address.
  20. >    program: Thanks very much.  I'll just go and fill this memory, and --
  21. >    malloc:  Just kidding!  I didn't really give you the memory.  And by
  22. >             the way, you're going to die if you continue to use it.  Ha!
  23. >
  24. >It turns out that when my program went to fill in the memory, it was sent
  25. >a SIGKILL by AIX.  This was clearly a bug of some kind, so I reported it.
  26. >I sent a demo program that just malloc'd as big a buffer as it could get,
  27. >and then started zeroing a byte every 4k.  When I started up a couple of
  28. >them, they all died.  Some got bus errors, others were sent SIGKILL.
  29. >
  30. >IBM said that they don't allocate the paging space until it's needed, in
  31. >order to accommodate programs which ask for large amounts of memory that
  32. >they never use (some nonsense about sparse arrays).  
  33. >
  34. >I have questions:
  35. >    1) Has anyone seen a system where static memory may not really be
  36. >       there, or where a nonzero malloc doesn't guarantee the successful
  37. >       usage of the memory?
  38.  
  39. Yeah, on AIX :-)
  40.  
  41. >    2) Has anyone heard of SIGDANGER before?
  42.  
  43. You bet. I've had entire PRODUCTION SYSTEMS come crashing down because of
  44. this.  Believe it or not, I have had >curses< programs get SIGDANGER when
  45. the machine was heavily loaded.  The result is a nice program crash.
  46.  
  47. Further, I have had processes receive SIGDANGER when only one of two paging
  48. spaces on the system was close to filling.  It seems that if >any< page
  49. space on an AIX box gets close to being full you get the SIGDANGER, even if
  50. there are other paging spaces with lots of room left.  Yikes!  So much for
  51. the performance advantages of spreading the page space across spindles!
  52.  
  53. >    3) Read the POSIX standard for malloc from a "legal" standpoint.
  54. >       If IBM claims POSIX compliance, can I use this as a weapon?
  55.  
  56. Probably ;-)
  57.  
  58. >    4) Even if I use this malloc wrapper everywhere in my own code,
  59. >       how do I deal with third-party code I purchase that calls the
  60. >       unwrapped malloc?
  61.  
  62. You don't, other than to allow it to die.  Oh, you had something >important<
  63. in that program going on, like perhaps a financial transaction?  Too bad --
  64. that SIGKILL you just received can't be caught!  So much for reliable
  65. software.
  66.  
  67. This is one of the reasons I hate AIX.  There are lots of them, but this is
  68. definately one of the top 5.  When malloc() returns non-NULL, you are supposed
  69. to have the space available >period<.  Same is true for static arrays -- I
  70. typically will declare these for things I >must< be able to get at and can't
  71. afford a NULL malloc() return for.  It is quite a surprise to get SIGDANGER 
  72. or SIGKILL when you don't expect it, and have no way to deal with it. 
  73. Oh, you mean that large static array I have declared really >can't< be 
  74. used, and you won't tell me ahead of time?!  Oh, that array is declared in a
  75. library (like internal to Curses)?  Now what the hell do I do about it?
  76.  
  77. This is a >big< problem on heavily-loaded machines.
  78.  
  79. --
  80. Karl Denninger         Inet:  kdenning@hq.videocart.com
  81. VideOcart Inc.        Voice: (312) 987-5022
  82.