Skip to content
This repository was archived by the owner on Nov 23, 2017. It is now read-only.
This repository was archived by the owner on Nov 23, 2017. It is now read-only.

_OverlappedFuture.set_result() should clear the its reference to the overlapped object #196

@GoogleCodeExporter

Description

@GoogleCodeExporter
Hi,

I rewrote the Windows code handling overlapped operations to fix a crash when a 
_WaitHandleFuture was cancelled, to log errors and more generally to cleanup 
the code.

I tried to clear the reference the overlapped operation in _OverlappedFuture. 
_OverlappedFuture.set_exception() now cancels the operation and then clears the 
reference, it works. _OverlappedFuture.cancel() does the same and it works too.

But when I try to clear the reference to the overlapped operation in 
_OverlappedFuture.set_result(), I get random errors. It looks the problem only 
occurs in the fast-path of IocpProactor._register(), when the overlapped is not 
added to _cache. It looks like clearing the reference in _poll(), when 
GetQueuedCompletionStatus() got the status of the operation, it works.

I tried to add the overlapped into _cache but then the event loop hangs or 
raises other errors.

I don't see how to fix the issue. There is a bug somewhere or I misunderstood 
how overlapped operations works. Is it important that 
GetQueuedCompletionStatus() reads the status of the operation? Or should we 
*cancel* the operation after getting the result?

It's really strange because in _register(), the overlapped is not added to 
_cache is the overlapped is not pending. But I get errors in the overlapped 
destructor. According to the destructor code, I'm not supposed to get errors if 
the overlapped already completed.

Maybe I looked at the wrong overlapped object. I don't know.

Original issue reported on code.google.com by victor.s...@gmail.com on 25 Jul 2014 at 11:16

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions