Re: segmentation fault on calloc
From: Mathieu Fregeau (mathieu.fregeau_at_polymtl.ca)
Date: 11/02/03
- Next message: nobody: "Re: segmentation fault on calloc"
- Previous message: Jem Berkes: "Re: Dealing with fragmented getopt parameters"
- In reply to: Måns Rullgård: "Re: segmentation fault on calloc"
- Next in thread: Måns Rullgård: "Re: segmentation fault on calloc"
- Reply: Måns Rullgård: "Re: segmentation fault on calloc"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 2 Nov 2003 16:05:41 -0500
Hi Mans,
thank you. If I understand, the heap is used when you use malloc (or
new/delete in C++), is that right? an object, or the main function is not
created on the heap (?). For me, I don't see a difference (and I was not
making care of knowing that), since when I want to use memory, that is not
my problem, I just request it. I understand a little more now, but is it me
(the code) or the system that creates the heap? if that's me, I could
increase its size, or something like: when I request memory (calloc), the
minimum block allocated is xx, (?) can I change the xx for something larger?
(...how?), can I track the heap validity? in windows there is the
heapwalk( _HEAPINFO *info) function, but in unix, the _HEAPINFO is an
unkonwn type... even with the <malloc.h> and <errno.h> file included...?
My question now relates on the heap, how to check its validity, and how to
make it valid (or increases its size)..
thank you!
Mathieu
"Måns Rullgård" <mru@kth.se> a écrit dans le message de
news:yw1xwuaipl1j.fsf@kth.se...
>
> Top-posting corrected by Gnus.
>
> "Mathieu Fregeau" <mathieu.fregeau@polymtl.ca> writes:
>
> >> >> > code. Rewritting the code is NOT an option. (about 10 years of
> >> >> > developement at NASA).
> >> >>
> >> >> Unfortunately there are many cases where a decade of development has
> >> >> produced an astonishing amount terrible code. It might be working,
> >> >> but any attempt to tinker with it results in things breaking, as we
> >> >> have seen. If only people could structure their code a little bit.
> >> >
> >> > in fact it is structured, but it is not documented.
> >>
> >> OK for structured, but it uses global variables, which is bad. As for
> >> documentation, that's equally important to code quality when dealing
> >> with long-lived code. I can barely understand my own code that I
> >> wrote less than a year ago.
> >
> > in fact, there is documentation, but not intended to an eventual
> > developper to modify its source... only for a user! The long reply
> > list suggest me that nobody in the world have an idea of a
> > solution. am I right?
>
> Without seeing the source, it's impossible to come up with anything
> better than guesses, based on experience with similar problems. I've
> seen lots of crashes in malloc, calloc and free, and all of them were
> caused by either buffer overflows, or attempts to use freed memory.
>
> I noticed in another post of yours that you seemed a little uncertain
> about what the heap was. The heap is the memory area of a process not
> containing code, stack, or static data (global variables, whether
> declared "static" or not), i.e. the memory managed by malloc and
> friends. To be able to do its work, malloc must store some
> information, such as size of each allocated block and lists of free
> blocks. This information is stored on the head, some of it between
> blocks returned from malloc to the caller. If the program writes past
> the end of an allocated block, it is almost certain to overwrite some
> of malloc's internal data. This will go unnoticed until the next call
> to a memory management function (no other code is allowed to touch
> it). When malloc (or calloc, or free) is called the next time, it
> might me using corrupted data, and crash.
>
> --
> Måns Rullgård
> mru@kth.se
- Next message: nobody: "Re: segmentation fault on calloc"
- Previous message: Jem Berkes: "Re: Dealing with fragmented getopt parameters"
- In reply to: Måns Rullgård: "Re: segmentation fault on calloc"
- Next in thread: Måns Rullgård: "Re: segmentation fault on calloc"
- Reply: Måns Rullgård: "Re: segmentation fault on calloc"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|