Discussion:
program crashes at malloc
(too old to reply)
l***@rediffmail.com
2007-10-30 15:44:43 UTC
Permalink
Hi,

I have a multithread console program (only C language used). The
program runs fine for some time, but it crashes at malloc
consistently. The call stack is given below. If there is heap
overrun, the free should crash. Why mallos crshes? What could be the
possible reasons? How can I detect the source of the problem?

NTDLL! 7c901230()
NTDLL! 7c9497f1()
NTDLL! 7c918238()
NTDLL! 7c92a326()
NTDLL! 7c96d6aa()
NTDLL! 7c949d18()
NTDLL! 7c91b298()
_heap_alloc_base(unsigned int 32816) line 161
_heap_alloc_dbg(unsigned int 32768, int 1, const char * 0x00000000,
int 0) line 367 + 9 bytes
_nh_malloc_dbg(unsigned int 32768, int 0, int 1, const char *
0x00000000, int 0) line 242 + 21 bytes
malloc(unsigned int 32768) line 130 + 21 bytes

Thanks
Mohan
David Lowndes
2007-10-30 16:49:17 UTC
Permalink
Post by l***@rediffmail.com
I have a multithread console program (only C language used). The
program runs fine for some time, but it crashes at malloc
consistently. The call stack is given below. If there is heap
overrun, the free should crash. Why mallos crshes? What could be the
possible reasons? How can I detect the source of the problem?
Mohan,

If you're using a recent version of VS I'd ensure you have the
run-time checking compiler options set - these may help identify the
source of the problem.

Dave
psp
2007-11-12 20:49:51 UTC
Permalink
Post by l***@rediffmail.com
I have a multithread console program (only C language used). The
program runs fine for some time, but it crashes at malloc
consistently. The call stack is given below. If there is heap
overrun, the free should crash. Why mallos crshes? What could be the
possible reasons? How can I detect the source of the problem?
You should make sure you are linking with the multithreaded version of
the C runtime library. This makes sure that calls to malloc/free etc.
are thread safe.
In VS 6.0 look under Project Settings for the C/C++ tab. In the "Use
run-time library" option select the appropriate multithreaded library.
Loading...