-
Notifications
You must be signed in to change notification settings - Fork 806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iocp: fix crash, GetQueuedCompletionStatus() write freed WSAOVERLAPPED memory #4136
base: master
Are you sure you want to change the base?
Conversation
Great! I assume you've tested this and it does fix the issue :) I think we also need to run under somekind of stress test, e.g: using ioqueue test in pjlib-test, to make sure all memory pools (of pending ops) are properly released. Note that the after an ioqueue key is unregistered, the key will be put into the closing-key-list and soon into the free-key-list to be reused by another socket. We need to make sure that all pending op has been freed before the key is freed & reused. Next, perhaps we can apply a little bit optimization, e.g: instead of mem-pool for each pending-op, perhaps mem-pool per ioqueue-key to avoid multiple alloc+free for multiple pending-op, using same mechanism as ioqueue key (employing additional list for keeping unused pending-op instances to be reused later). |
Note: |
When |
Tried to run
Not sure if this is the same issue, but this assertion does not happen when using ioqueue select. |
@nanangizz no this patch, Is there this assert? |
Yes, same assert without this patch. |
I found the reason: key double unregister. |
Thanks @jimying . Honestly I haven't got a chance to reproduce the original issue and test the proposed solution. I believe you are using this ioqueue in real world, experienced the issue, and find this solution does work, is that correct? Next, here are few notes about the proposed solution:
Also, this ioqueue has been disabled for quite sometime and some improvement in the ioqueue area may not be integrated into this ioqueue, e.g: group lock for key. So please understand that there may still be some steps required to enable this ioqueue again :) |
@nanangizz i write a simple demo to reproduce the crash issue in msys2, #4172 I have tested it, in old code, it can 100% reproduce the crash. To test new code we can git cherry-pick the demo patch to this branch. |
Thanks @jimying. |
…D memory try to fix issue pjsip#985
Hi @jimying, please let us know whether you plan to incorporate @nanangizz suggestions above. |
@sauwming sorry, I will submit it as soon as possible today or tomorrow |
new commits do:
|
The pool is owned by key/socket, instead of by ioqueue, to avoid possible infinite memory grow in ioqueue.
try to fix issue #985