home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.os.os2.programmer:4310 comp.lang.c:12493
- Newsgroups: comp.os.os2.programmer,comp.lang.c
- Path: sparky!uunet!elroy.jpl.nasa.gov!usc!rpi!maniattb
- From: maniattb@cs.rpi.edu (Bill Maniatty)
- Subject: Re: malloc causes a segmentation violation!?
- Message-ID: <3dfy6bq@rpi.edu>
- Nntp-Posting-Host: fornax.cs.rpi.edu
- References: <1992Aug18.143135.6259@cc.tut.fi>
- Date: Tue, 18 Aug 1992 18:17:16 GMT
- Lines: 62
-
- In article <1992Aug18.143135.6259@cc.tut.fi>, mn87504@cs.tut.fi (Naatula Mika) writes:
- |>
- |> I wonder if this is a familiar bug to someone.
- |>
- |> The problem is:
- |> Sometimes my program causes a segmentation fault. If I drive it with
- |> CVP I can find out (from calls sequence) that the error was caused by
- |> malloc. To be exact, malloc calls an internal(?) function named
- |> _searchseg() that fails. Any ideas what this function might be?
- |>
- |> I use MSC 6.00 in OS/2 1.3 environment.
- |>
- |> I write programs for Lotus Notes using Lotus Notes API libraries. (But
- |> I think it is irrelevant to the promlem).
- |> The memory model used is Large.
- Possibility - Bug is yours (very small I'm sure, but still possible)
-
- Can you compile and link with a debugging version of malloc?
- (Some environments provide for one).
-
- You might want to count number of mallocs/frees and trap on a free when
- number malloced < number freed.
-
- Verify that no access is made beyond the end of malloced structures. Typically
- malloc creates a linked list looking like the following:
-
- --------------------------------------------
- | malloc info a | user data | malloc info b|
- --------------------------------------------
-
- The malloc info contains ptrs to other blocks in free/use chain, size information,
- etc... Please note that malloc info may be found at one end or the other of
- the structure, and writing beyond the end of structure would trash it and corrupt
- the heap.
-
- Possibility Bug is in Notes Library (less likely, but also possible)_
-
- Can you stub out calls.
-
- Possibility Bug is in MSC 6.00 (less likely)
-
- Try compiling and linking with competitor's compiler/older version
-
- Possibility Hardware / OS bug
-
- Try a different machine
-
- |>
- |> My program uses a lot of dynamic memory allocation, but I am quite
- |> sure that there is no bugs in my code. I have spent two days checking
- |> out the memory allocation of this program.
- |>
- |> --
- |> __ | Mika Naatula Email: mic@cc.tut.fi
- |> |\ //| || // \ | Lindfrosinkatu 8 A 11 mn87504@cs.tut.fi
- |> | \/ | || || | 33720 Tampere, FINLAND
- |> | | || \\__/ | 931-185 993
-
- --
- |
- | maniattb@cs.rpi.edu - in real life Bill Maniatty
- |
-