Home > Archive > VC Language > January 2006 > crashed in malloc
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Tushar 2006-01-24, 8:00 am |
| Hi all,
I am experiencing a wierd crash in malloc. There is one call with
malloc(208) and my application crashes in some 'MemPoolSetHighThreads'
funciton which is internally called by malloc.
There does not seem to be any problem with the code surrounding it, and I
dont think that a crash in malloc(208) should be related to the code
surrounding it.
One thing to note here is that the application experienced a crash on a
multiprocessor machine. I just searched through net and found that there
might be memory allocation problems in multiprocessor machines.
Does anyone have any idea about why crash can occur in malloc?
I would appreciate any pointers in this regards.
Thanks in advance,
Tushar.
| |
| Igor Tandetnik 2006-01-24, 8:00 am |
| "Tushar" <Tushar@discussions.microsoft.com> wrote in message
news:FD4D6977-1A5A-4789-963C-2F16F392A9F8@microsoft.com
> I am experiencing a wierd crash in malloc. There is one call with
> malloc(208) and my application crashes in some 'MemPoolSetHighThreads'
> funciton which is internally called by malloc.
Most likely, you have a case of corrupted heap. E.g. this may happen if
you overrun a heap-allocated buffer and destroy memory manager's
internal data structures in the process. This is one of the hardest
problems to track down, since the damage manifests itself much later
with a crash in a completely unrelated part of the code. Check your code
very carefully for these problems.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
| |
| adebaene@club-internet.fr 2006-01-24, 7:07 pm |
|
Tushar wrote:
> Hi all,
> I am experiencing a wierd crash in malloc. There is one call with
> malloc(208) and my application crashes in some 'MemPoolSetHighThreads'
> funciton which is internally called by malloc.
>
> There does not seem to be any problem with the code surrounding it, and I
> dont think that a crash in malloc(208) should be related to the code
> surrounding it.
> One thing to note here is that the application experienced a crash on a
> multiprocessor machine. I just searched through net and found that there
> might be memory allocation problems in multiprocessor machines.
>
To complete Igor's answer : If your app is multithreaded and you are
running on a multiprocessor machine, you need to link against a
multithreaded version of the CRT : See /MD, /MT, etc... compiler
switch.
Arnaud
MVP - VC
| |
| Ben Voigt 2006-01-26, 7:08 pm |
|
<adebaene@club-internet.fr> wrote in message
news:1138112396.827902.201350@g47g2000cwa.googlegroups.com...
>
> Tushar wrote:
>
> To complete Igor's answer : If your app is multithreaded and you are
> running on a multiprocessor machine, you need to link against a
> multithreaded version of the CRT : See /MD, /MT, etc... compiler
> switch.
Sure.
Actually, if your app is multi-threaded, you need multithreaded CRT.
Multiprocessor machines just tend to bring the error to light a lot quicker
(since interleaved execution happens continuously, not just when the
scheduler begins a new quantum).
Also, if performance in more critical than memory usage, you may want to use
HeapCreate (this should be synchronized) to give each thread its own heap,
and then you can allocate with HeapAlloc from all threads simultaneously
without having to synchronize malloc calls. Or a third-party thread-safe
allocator. This is also one of the few good reasons to override operator
new globally.
>
> Arnaud
> MVP - VC
>
|
|
|
|
|