home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / os / os2 / programm / 6637 < prev    next >
Encoding:
Internet Message Format  |  1992-11-23  |  2.1 KB

  1. Path: sparky!uunet!nntp1.radiomail.net!cronos!Metaphor.COM!pstevens
  2. From: pstevens@Metaphor.COM (Paul Stevens)
  3. Newsgroups: comp.os.os2.programmer
  4. Subject: Re: sprintf() hangs application
  5. Message-ID: <2660@cronos.metaphor.com>
  6. Date: 23 Nov 92 22:11:11 GMT
  7. References: <1992Nov17.190901.16350@panix.com>
  8. Sender: news@cronos.metaphor.com
  9. Reply-To: pstevens@Metaphor.COM (Paul Stevens)
  10. Organization: m4
  11. Lines: 36
  12.  
  13. In article <1992Nov17.190901.16350@panix.com>, os2man@panix.com (Larry Salomon Jr.) writes:
  14. |> For some reason, a call to sprintf() instead one of my routines
  15. |> (called getTempName()) hangs my PM application (using C-Set/2 from
  16. |> CD ROM to compile).
  17. |> 
  18. |> Since sprintf() calls malloc() I decided to allocate 100 bytes before
  19. |> calling sprintf() (and immediately free the 100 bytes), and - sure enough -
  20. |> the app hung on the malloc() call.
  21. |> 
  22. |> It sounds like something is getting trashed somewhere, but I don't make
  23. |> any calls to malloc() (I use my own home-grown routines, which I am 99%
  24. |> sure are correct) so it's not like the run-time is suffering from memory
  25. |> fragmentation.
  26. |> 
  27. |> If *anyone* has any ideas what's going on, *please* let me know, since this
  28. |> is a "show stopper."
  29. |> 
  30.  
  31. We had a situation like this that was caused because someone was using
  32. an uninitialized semaphore handle (value of 0) and requesting that 
  33. semaphore.  Turns out that 0 is indeed a valid handle and is, in fact,
  34. the sem that the C runtime library uses!  Finding this was *not*
  35. easy (a lot of digging with the kernel debugger).  Good Luck!
  36.  
  37. Oh, yeah, this is only true if you are using the multi-threaded
  38. C library (the sem is used to sync access to global structures for
  39. each calling thread).
  40.  
  41. I think this is a major bad architectural choice to allow 0 as a
  42. legal semaphore handle, and then to find that it will be used by
  43. something as pervasive as the C runtime library.
  44. +------------------------------------------------------------------------+
  45.  
  46.    Paul Stevens                        {apple|decwrl}!metaphor!pstevens
  47.    Metaphor Computer Systems           pstevens@metaphor.com
  48.    Mountain View, CA
  49.