home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / os / os2 / programm / 4310 < prev    next >
Encoding:
Internet Message Format  |  1992-08-18  |  2.6 KB

  1. Xref: sparky comp.os.os2.programmer:4310 comp.lang.c:12493
  2. Newsgroups: comp.os.os2.programmer,comp.lang.c
  3. Path: sparky!uunet!elroy.jpl.nasa.gov!usc!rpi!maniattb
  4. From: maniattb@cs.rpi.edu (Bill Maniatty)
  5. Subject: Re: malloc causes a segmentation violation!?
  6. Message-ID: <3dfy6bq@rpi.edu>
  7. Nntp-Posting-Host: fornax.cs.rpi.edu
  8. References:  <1992Aug18.143135.6259@cc.tut.fi>
  9. Date: Tue, 18 Aug 1992 18:17:16 GMT
  10. Lines: 62
  11.  
  12. In article <1992Aug18.143135.6259@cc.tut.fi>, mn87504@cs.tut.fi (Naatula Mika) writes:
  13. |> 
  14. |> I wonder if this is a familiar bug to someone.
  15. |> 
  16. |> The problem is:
  17. |> Sometimes my program causes a segmentation fault. If I drive it with
  18. |> CVP I can find out (from calls sequence) that the error was caused by
  19. |> malloc. To be exact, malloc calls an internal(?) function named
  20. |> _searchseg() that fails. Any ideas what this function might be?
  21. |> 
  22. |> I use MSC 6.00 in OS/2 1.3 environment.
  23. |> 
  24. |> I write programs for Lotus Notes using Lotus Notes API libraries. (But
  25. |> I think it is irrelevant to the promlem). 
  26. |> The memory model used is Large.
  27. Possibility - Bug is yours (very small I'm sure, but still possible)
  28.  
  29. Can you compile and link with a debugging version of malloc?
  30.     (Some environments provide for one).
  31.  
  32. You might want to count number of mallocs/frees and trap on a free when
  33. number malloced < number freed.
  34.  
  35. Verify that no access is made beyond the end of malloced structures.  Typically
  36. malloc creates a linked list looking like the following:
  37.  
  38.     --------------------------------------------
  39.     | malloc info a | user data | malloc info b|
  40.     --------------------------------------------
  41.  
  42. The malloc info contains ptrs to other blocks in free/use chain, size information,
  43. etc...  Please note that malloc info may be found at one end or the other of
  44. the structure, and writing beyond the end of structure would trash it and corrupt
  45. the heap.
  46.  
  47. Possibility Bug is in Notes Library (less likely, but also possible)_
  48.  
  49. Can you stub out calls.
  50.  
  51. Possibility Bug is in MSC 6.00 (less likely)
  52.  
  53. Try compiling and linking with competitor's compiler/older version
  54.  
  55. Possibility Hardware / OS bug
  56.  
  57. Try a different machine
  58.  
  59. |> 
  60. |> My program uses a lot of dynamic memory allocation, but I am quite
  61. |> sure that there is no bugs in my code. I have spent two days checking
  62. |> out the memory allocation of this program.
  63. |> 
  64. |> -- 
  65. |>              __   | Mika Naatula            Email: mic@cc.tut.fi
  66. |> |\ //| ||  //  \  | Lindfrosinkatu 8 A 11          mn87504@cs.tut.fi
  67. |> | \/ | || ||      | 33720 Tampere, FINLAND
  68. |> |    | ||  \\__/  | 931-185 993
  69.  
  70. -- 
  71. |
  72. |    maniattb@cs.rpi.edu - in real life Bill Maniatty
  73. |
  74.