Click to See Complete Forum and Search --> : Threads and heap
kaushikagrawal
June 14th, 2007, 02:12 PM
Hi folks,
I am working on a crash dump got from a customer and what I see is that 2 of the threads are trying to access the same heap (HeapAlloc) function at the same time. I am not 100% sure if we use Mutexes since I am new to the company but I believe they do. Is it possible for something like HeapAllocation to cause a crash. Please help me out. It might also be heap corruption. I will try to post some code soon, but I would like to get some initial reaction from someone.
Thanks a a lot in advance.
JVene
June 14th, 2007, 03:52 PM
The multi-threaded CRT allocation system (malloc, new, etc) will lock it's own object (critical section I would think) for all calls. It would crash if, for some reason, it's not the multi-threaded version of the library.
Otherwise, it's fairly well nailed down there.
kaushikagrawal
June 14th, 2007, 04:29 PM
Is it possible that one thread which is accessing the heap via win32 API (assuming that it locks that heap as a critical section) but if a thread created by my application is not taking care of that and calling the heap directly via a heapAlloc function would cause a crash - an access violation.
Am I making any sense??
JVene
June 14th, 2007, 05:27 PM
As long as the libraries are the multi-threaded libraries in the setup, this shouldn't be a problem. There can be situations where you link a static library or load a DLL that's built in, say, the non-multi-threaded library, but your application is built with multi-threaded, and you can end up with this problem.
There should be linker complaints, but some linker settings can 'get around' this to generate an invalid executable.
This is rare, though - so after a quick check on the related compiler settings, I'd seriously think in the application code direction.
kaushikagrawal
June 18th, 2007, 09:51 AM
Hi,
I checked all the settings and all of the DLL projects are indeed set to be multi-threaded. Can you give me some pointers as to what can be causing such a problem in the application code. Would really appreciate it.
Thanks.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.