Re: IOCP touching my OVERLAPPED after my Write has completed



Hi Alberto

When the request completes I uncommit the page

Are you doing it in IO completion routine?

Anton Bassov


Alberto Demichelis wrote:
Hi, I've recently posted about a crash I was experiencing in my server on
heavy load.
Recently I've rewritten part of my IOCP routines and added some extra
consistency checks. While doing this I've
realized that the my OVERLAPPED struct gets read by winsock after the IO
request has completed. That in my current implementation means that is
reading freed memory.

This is my scenario. I have a IO request pool implemented using VirtualAlloc.
I reserve few megs of virtual memory, every time I allocate a request I
commit a page and put all my IO structs in it.
When the request completes I uncommit the page.

The result is an access violation in WSAWriteTo() [Access violation reading
location 0x1185d004]. This happens when the IO request completes before
WSAWriteTo() returns.
Probably the same happens in my ReadFrom but apparently it never gets
triggered beacuse I deallocate my read requests in my main app thread after
processing.

Now I'm a bit lost, all the IOCP samples I found on the net use the same
pattern I use. When can I safely
release my OVERLAPPED and related buffers? I thought was 'on completion' by
apparently I'm wrong.

thanks for your time
Alberto

.



Relevant Pages

  • Re: IOCP touching my OVERLAPPED after my Write has completed
    ... DON'T mix a completion routine and IOCP thread, ... Your code will leak memory in this case. ... WSASendTo() it seems a bit different. ... FreeRequest(req); //in debug I decommit the memory of this request ...
    (microsoft.public.win32.programmer.kernel)
  • Irp/Urb Completion Routine Is Called Only Once
    ... Irp/Urb down the stack? ... On the second request, I see the request take place on the USB bus, and I ... But my Completion Routine is not ... I've tried re-using the original Irp and allocating a new Irp, ...
    (microsoft.public.development.device.drivers)
  • Re: Question about completion routine for InternalDeviceControl.
    ... are you allocating the WDFREQUEST yourself or did it come ... > device manager will stop the driver completely. ... > WdfRequestSetCompletionRoutine; ... > to register a completion routine that just print out the text message and ...
    (microsoft.public.development.device.drivers)
  • Re: I/O target from socket doesnt timeout
    ... Did you set a completion callback for this request? ... status you got in your completion routine? ... I have created an I/O target from a socket but when I send an I/O request ... The socket was created with WSASocket passing WSA_FLAG_OVERLAPPED and I ...
    (microsoft.public.development.device.drivers)