473,407 Members | 2,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

crashed in malloc

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.
Jan 24 '06 #1
6 1620
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.


Heap corruption is usually the first suspect.
You can try to test the application with PageHeap to see if that's the case:
http://www.debuginfo.com/tips/userbpntdll.html

PageHeap should also be able to detect some synchronization-related bugs.

Regards,
Oleg
[VC++ MVP http://www.debuginfo.com/]


Jan 24 '06 #2
Could it be that you are using the single threaded runtime library perhaps?
for multithreading apps you have to use the multithreaded runtime library.

apart from that my best guess is memory corruption due to race conditions or
wrong pointers. that can cause any sort of behavior, including crashes in the
runtime library or nt dlls.

a last thing that comes to mind is that you might be using a lib that uses a
different version of the runtime library than the one you are using (for
example single threaded vs multithreaded) so that you are using
multithreading with a library that was only intended for single threading, or
something like that.

kind regards,
Bruno.
"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.

Does anyone have any idea about why crash can occur in malloc?
I would appreciate any pointers in this regards.

Thanks in advance,
Tushar.

Jan 24 '06 #3
Thanks for the reply Oleg.
Unfortunately, my application does not use the Windows heap but uses
SmartHeap.
Would PageHeap.exe help in this case?

Thanks,
Tushar.

"Oleg Starodumov" wrote:
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.


Heap corruption is usually the first suspect.
You can try to test the application with PageHeap to see if that's the case:
http://www.debuginfo.com/tips/userbpntdll.html

PageHeap should also be able to detect some synchronization-related bugs.

Regards,
Oleg
[VC++ MVP http://www.debuginfo.com/]


Jan 25 '06 #4
Thanks for the reply Bruno.
The application has been build with multithreaded run time libraries and it
has a number of threads running in parallel at any time.
I think the heap corruption due to some pointer assignment is the most
likely cause of the crash, but with a number of threads running, this has
become virtually impossible to find which thread might be causing the memory
corruption and where....:-(

Thanks again,
Tushar.

"Bruno van Dooren" wrote:
Could it be that you are using the single threaded runtime library perhaps?
for multithreading apps you have to use the multithreaded runtime library.

apart from that my best guess is memory corruption due to race conditions or
wrong pointers. that can cause any sort of behavior, including crashes in the
runtime library or nt dlls.

a last thing that comes to mind is that you might be using a lib that uses a
different version of the runtime library than the one you are using (for
example single threaded vs multithreaded) so that you are using
multithreading with a library that was only intended for single threading, or
something like that.

kind regards,
Bruno.
"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.

Does anyone have any idea about why crash can occur in malloc?
I would appreciate any pointers in this regards.

Thanks in advance,
Tushar.

Jan 25 '06 #5
debugging a multithreaded program is tricky indeed.
Here are a few things you can try:

- if things are passed from one thread to the other, check if there can be
race conditions.
- if possible, remove threads one at a time to see which thread triggers the
problem. this only works if your program can somehow run without all the
threads you mentioned.
- remove code from the different threads until the system becomes stable.
then you'll have found at least part of the problem.
- explain the architecture / implementation of your multithreaded program to
someone else. chances are that during the explanation, you'll notice
something fishy.

kind regards,
Bruno.

"Tushar" wrote:
Thanks for the reply Bruno.
The application has been build with multithreaded run time libraries and it
has a number of threads running in parallel at any time.
I think the heap corruption due to some pointer assignment is the most
likely cause of the crash, but with a number of threads running, this has
become virtually impossible to find which thread might be causing the memory
corruption and where....:-(

Thanks again,
Tushar.

"Bruno van Dooren" wrote:
Could it be that you are using the single threaded runtime library perhaps?
for multithreading apps you have to use the multithreaded runtime library.

apart from that my best guess is memory corruption due to race conditions or
wrong pointers. that can cause any sort of behavior, including crashes in the
runtime library or nt dlls.

a last thing that comes to mind is that you might be using a lib that uses a
different version of the runtime library than the one you are using (for
example single threaded vs multithreaded) so that you are using
multithreading with a library that was only intended for single threading, or
something like that.

kind regards,
Bruno.
"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.

Does anyone have any idea about why crash can occur in malloc?
I would appreciate any pointers in this regards.

Thanks in advance,
Tushar.

Jan 25 '06 #6
Unfortunately, my application does not use the Windows heap but uses
SmartHeap. Would PageHeap.exe help in this case?


Most likely it cannot help, unless you can rebuild the application to use
the standard Win32 heap.

If it is not possible, I would second the approach suggested by Bruno.
In addition, if the app's design allows, it might make sense to use defensive locking
(protect large pieces of code with sync. objects until the problem disappears,
then narrow down the scope of synchronization to find the place where
the problem reappears). Often tracing can also help to find race conditions
and other similar problems.

Oleg


Jan 25 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Subhash | last post by:
Hello, I am trying to generate dynamic graphics using the GD library and TTF fonts. The resulting image shows up fine. But in the apache error_log file the following lines are appended: child...
2
by: ChrisWinterscheid | last post by:
Occasionally we see these messages in the db2diag.log file. Can someone tell me what they mean and are they anything to worry about? 2005-03-03-10.42.04.286220 Instance:db2inst1 Node:000...
231
by: Brian Blais | last post by:
Hello, I saw on a couple of recent posts people saying that casting the return value of malloc is bad, like: d=(double *) malloc(50*sizeof(double)); why is this bad? I had always thought...
7
by: Rano | last post by:
/* Hello, I've got some troubles with a stupid program... In fact, I just start with the C language and sometime I don't understand how I really have to use malloc. I've readden the FAQ...
15
by: Martin Jørgensen | last post by:
Hi, I have a (bigger) program with about 15-30 malloc's in it (too big to post it here)... The last thing I tried today was to add yet another malloc **two_dimensional_data. But I found out that...
71
by: desktop | last post by:
I have read in Bjarne Stroustrup that using malloc and free should be avoided in C++ because they deal with uninitialized memory and one should instead use new and delete. But why is that a...
0
by: Curious | last post by:
A program crashed silently. Fortunately, I was able to get a .dmp file. Hopefully it can provide us with info on why it crashed. When I opened the .dmp file in Notepad, it took a long time to...
8
by: Pallav singh | last post by:
#include<iostream.h> #include<memory.h> #include<string.h> // product class Pizza { private : std::string Topping;
1
by: raghulvarma | last post by:
Hai friends, I need to know what would happen when my IIS gets crashed? what would happen to all the projects present inside it?How should I rectify that?What should I do when I am...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.