getting AccessViolationException in IOCompletionCa

2019-08-03 22:57发布

I get the following exception on application startup:

System.AccessViolationException
   at System.Threading.Overlapped.get_iocbHelper()
   at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

That's the entire call stack. It only happens one in twenty runs right on application startup. I do use IOCompletion in my socket code. I assume it is related to that. However, why would this exception not show when I call Socket.ReceiveFromAsync? I have a lot of sockets that simultaneously call ReceiveFromAsync, but I don't call it twice on the same socket concurrently. Any ideas on the cause?

1条回答
兄弟一词,经得起流年.
2楼-- · 2019-08-03 23:45

After trying really hard to get the IO-completion method to work, I finally gave up and just wrote my own threads that call the synchronous versions of send and receive. I haven't had any problems since.

I have some C++ code that uses IO-completion, in a high-volume setting even, and I've never had this problem.

So it seems clear to me that the C# implementation of IO-completion is bugged, and that it's not anti-malware, firewall, or any (non-Microsoft) crapware.

查看更多
登录 后发表回答