getting AccessViolationException in IOCompletionCallback

蹲街弑〆低调 提交于 2019-12-11 08:45:59

问题


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:


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.



来源:https://stackoverflow.com/questions/25433135/getting-accessviolationexception-in-iocompletioncallback

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!