GeezerVison is showing github.com — bpo-42972: Fix GC assertion error in _winapi by untracking Overlapped earlier by Fidget-Spinner · Pull Request #26429 · python/cpython
Conversation
See #26381 (comment). This untracks a possible 'bad' object earlier so the GC stops having weird race conditions. Fixes a gc assertion error in debug mode in test_httplib.
python_d.exe -m test test_httplib -m test_local_bad_hostname
...\cpython\Modules\gcmodule.c:446: update_refs: Assertion "gc_get_refs(gc) != 0" failed
Enable tracemalloc to get the memory block allocation traceback
object address : 000002DADE2A99D0
object refcount : 0
object type : 000002DADDF72F60
object type name: _winapi.Overlapped
object repr : <refcnt 0 at 000002DADE2A99D0>
Fatal Python error: _PyObject_AssertFailed: _PyObject_AssertFailed
Python runtime state: initialized
https://bugs.python.org/issue42972
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@vstinner seems like your gut feeling about UnTrack was right
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
test_httplib doesn't use asyncio, so it's unrelated. The test_httplib crash is: https://bugs.python.org/issue44252
python_d.exe -m test test_httplib -m test_local_bad_hostname
...\cpython\Modules\gcmodule.c:446: update_refs: Assertion "gc_get_refs(gc) != 0" failed
Enable tracemalloc to get the memory block allocation traceback
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
vstinner
commented
May 28, 2021
•
edited by bedevere-bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
If you want to modify overlapped_dealloc(), I suggest to also remove the compatibility code for Windows XP.
if (self->pending) {
if (check_CancelIoEx() &&
Py_CancelIoEx(self->handle, &self->overlapped) &&
GetOverlappedResult(self->handle, &self->overlapped, &bytes, TRUE))
{
/* The operation is no longer pending -- nothing to do. */
}
else if (_Py_IsFinalizing())
{
/* The operation is still pending -- give a warning. This
will probably only happen on Windows XP. */
PyErr_SetString(PyExc_RuntimeError,
"I/O operations still in flight while destroying "
"Overlapped object, the process may crash");
PyErr_WriteUnraisable(NULL);
}
else
{
/* The operation is still pending, but the process is
probably about to exit, so we need not worry too much
about memory leaks. Leaking self prevents a potential
crash. This can happen when a daemon thread is cleaned
up at exit -- see #19565. We only expect to get here
on Windows XP. */
CloseHandle(self->overlapped.hEvent);
SetLastError(err);
return;
}
}
check_CancelIoEx() can be removed and CancelIoEx() can be used directly. It's available since Windows Vista and Python 3.11 requires Windows Vista or newer:
https://docs.microsoft.com/en-us/windows/win32/fileio/cancelioex-func
See also bpo-32592 "Drop support of Windows Vista and Windows 7".
Please open a separated PR for that.
I don't think that it's worth it to only move the PyObject_GC_UnTrack() call.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, I was referring to another crash. These 2 build bots crashed when running in python debug mode due to my previous commit:
Ah ok, I merged your PR.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Can you please create a 3.10 backport which contains your two commits? Use git cherry-pick -x.
|
Fidget-Spinner reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
I closed #26431 which only contained the first fix.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Can you please create a 3.10 backport which contains your two commits? Use git cherry-pick -x.
Yep, #26430 has both fixes. Thanks!
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
vstinner
Awaiting requested review from vstinner
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|