StackOverflowException

G

Guest

Hi All,

I'm having a problem with a StackOverflowException in a managed class.

The exception is thrown when I attempt to allocate an unmanaged char array
inside the managed class. It appears to be caused by a call to mtinitlocknum
which throws the exception.

I've done some reading and most posts suggest that the problem is caused by
recursion or infinite loops. I've been through most of my code which leads up
to the exception but have not been able to see any functions which may be
using recursion.

I do call some of the Crypt Win32API functions such as CertOpenStore,
CertAddSerializedElementToStore and CryptStringToBinary and have my
suspicions that they may be causing the problem.

I've also been through my code looking for variables that I may not have
released correctly and so far haven't been able to see any.

Does anyone have any idea's as to why I'm receiving this message when trying
to allocate unmanaged pointers? It only seems to happen at the one point in
the code as well, I can declare plenty of unmanaged arrays before the point
where the exception is thrown.

Thanks
John
 
G

Guest

I think I've discovered what's causing it, although I don't really know what
to do about it.

It seems that the call to new I'm using to allocate the array is what is
introducing the recursion.

When the new operator is called it attempts to call _mlock(_HEAP_LOCK) to
lock the heap because this is a multi-threaded application. In my case the
locktable is null when I'm attempting to allocate my unmanaged array. I've
stepped through some other unmanaged array allocations which happen in
different classes/dll's in the project and all of these have the locktable
array allocated and don't have this problem.

So can anyone think of what I may be doing wrong to cause this to happen?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top