Deadlock allocating memory 
Author Message
 Deadlock allocating memory

Hi everyone. The problem I have might seem unrelated to COM, but since I'm
dealing with lots of COM componentes around me, that might have some
influence on it. Excuse me if this posting is unrelated to this group.

I am developing a free threaded EXE server, which is called by a VB dll
(apartment threaded), and sometimes needs to call another EXE server
(written in VB, apartment threaded also).
Every method in my exe copys its parameters, fires a thread and returns
control immediately. And due to the nature of the component, there are try /
catch pairs all over the place, so it doesn't crash in the user's face,
instead it logs the error to a file. Well... sometimes, access violations
occurs. That is acceptable, as long as I can gracefully recover from the
error, which usually I can. But sometimes the server locks, and every call
made to it gets queued. When I kill it through the Task Manager, the calls
which were queued begins to execute. I've narrowed the problem down to a
critical section being locked and never released. The sequence might look
like this:
- A call to the exe is made, parameters are copyed and control is returned
to the caller
- Internal processing in my component causes an access violation (freeing
memory). I catch the exception and log it.
- Another call is made. When the parameters are copyed, the first memory
allocation made locks.

Debugging the call, the memory allocator locks when it tries to aquire
ownership of a critical section. (I think all operations on the heap of a
process are protected by critical sections, right?). I'm using C++'s new and
sometimes malloc. Should I be using CoTaskMemAlloc ?? I have no experience
with this API, and I don't know when it should be used...

Thank you very much for your help.

Greetings!
Ignacio Burgue?o

P.S. Forgive my {*filter*}english



Sat, 12 Feb 2005 06:51:57 GMT  
 Deadlock allocating memory
You should really concentrate on debugging and getting rid of access
violations. They are not acceptable. I strongly doubt there is any way
to completely recover from an access violation - who knows what internal
state got corrupted. Leaving a critical section locked is just one of
many possible problems.
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:
> Hi everyone. The problem I have might seem unrelated to COM, but since
I'm
> dealing with lots of COM componentes around me, that might have some
> influence on it. Excuse me if this posting is unrelated to this group.

> I am developing a free threaded EXE server, which is called by a VB
dll
> (apartment threaded), and sometimes needs to call another EXE server
> (written in VB, apartment threaded also).
> Every method in my exe copys its parameters, fires a thread and
returns
> control immediately. And due to the nature of the component, there are
try /
> catch pairs all over the place, so it doesn't crash in the user's
face,
> instead it logs the error to a file. Well... sometimes, access
violations
> occurs. That is acceptable, as long as I can gracefully recover from
the
> error, which usually I can. But sometimes the server locks, and every
call
> made to it gets queued. When I kill it through the Task Manager, the
calls
> which were queued begins to execute. I've narrowed the problem down to
a
> critical section being locked and never released. The sequence might
look
> like this:
> - A call to the exe is made, parameters are copyed and control is
returned
> to the caller
> - Internal processing in my component causes an access violation
(freeing
> memory). I catch the exception and log it.
> - Another call is made. When the parameters are copyed, the first
memory
> allocation made locks.

> Debugging the call, the memory allocator locks when it tries to aquire
> ownership of a critical section. (I think all operations on the heap
of a
> process are protected by critical sections, right?). I'm using C++'s
new and
> sometimes malloc. Should I be using CoTaskMemAlloc ?? I have no
experience
> with this API, and I don't know when it should be used...

> Thank you very much for your help.

> Greetings!
> Ignacio Burgue?o

> P.S. Forgive my {*filter*}english



Sun, 13 Feb 2005 00:53:56 GMT  
 Deadlock allocating memory
You're right, Igor. There's no way I can guarantee that I can recover from
an access violation, so I'll just have to get rid of them.

Thanks a lot and greetings!
Ignacio Burgue?o



Quote:
> You should really concentrate on debugging and getting rid of access
> violations. They are not acceptable. I strongly doubt there is any way
> to completely recover from an access violation - who knows what internal
> state got corrupted. Leaving a critical section locked is just one of
> many possible problems.
> --
> With best wishes,
>     Igor Tandetnik

> "For every complex problem, there is a solution that is simple, neat,
> and wrong." H.L. Mencken



Sun, 13 Feb 2005 02:25:31 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Questions about memory size and memory allocate.

2. Allocating a memory block that doesn't overlap physical memory

3. Dynamic allocate memory size in memory mapping

4. allocate memory in a predifined location of the memory

5. Released allocated memory

6. memory allocated to structures

7. What is the proper way to allocate and free memory in this instance

8. Possible to allocate 1 Megabyte of memory?

9. allocating memory for a char **

10. Allocating memory for a matrix

11. allocating memory in functionsII

12. allocating memory with functions

 

 
Powered by phpBB® Forum Software