This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: [Windows] test_asyncio fails with application verifier! _cancel_overlapped() fails with "The handle is invalid"
Type: Stage:
Components: asyncio, Tests Versions: Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Alexander Riccio, asvetlov, samjonas, vstinner, yselivanov
Priority: normal Keywords:

Created on 2019-05-04 00:10 by Alexander Riccio, last changed 2022-04-11 14:59 by admin.

Files
File name Uploaded Description Edit
python_test_invalid_handle_failure.TXT Alexander Riccio, 2019-05-04 00:10 Windbg output for the failure
python_invalid_handle.PNG Alexander Riccio, 2019-05-04 00:13 screencap of tracebacj
Messages (6)
msg341365 - (view) Author: Alexander Riccio (Alexander Riccio) * Date: 2019-05-04 00:10
I compiled PCBuild Debug x64 from an updated clone of upstream, and when running the testsuite under Application Verifier with handle verification, the test triggers an invalid handle access by passing an invalid overlapped handle to CancelIoEx with this code: Py_CancelIoEx(self->handle, &self->overlapped) (where self->handle appears to be the offending variable).

I have no idea who's calling _overlapped.cancel, and a quick spelunking through the codebase only confuses me more.
msg341366 - (view) Author: Alexander Riccio (Alexander Riccio) * Date: 2019-05-04 00:13
Hmm, proceeding a bit further pointed to finish_recv in windows_events.py
msg342459 - (view) Author: sam jonas (samjonas) Date: 2019-05-14 13:07
Thanks for the solution...
msg342460 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2019-05-14 13:11
What is "Application Verifier"?
Could you provide an instruction on how to install and run it to reproduce the issue?
msg342526 - (view) Author: Alexander Riccio (Alexander Riccio) * Date: 2019-05-15 00:11
It's part of the Windows SDK, and is installed with it. To enable for this error, add the Python executable in Application Verifier, and check the Handles box.
msg355046 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-10-21 10:34
> when running the testsuite under Application Verifier

test_asyncio is quite big. Can you run test_asyncio in verbose mode, and attach the output as a file to the issue? Or try to identify a few examples of tests which fail with "The handle is invalid" errors"?

It seems like "The handle is invalid" errors" error occurs while calling _cancel_overlapped().
History
Date User Action Args
2022-04-11 14:59:14adminsetgithub: 80971
2019-10-21 10:34:16vstinnersetnosy: + vstinner
title: test_asyncio fails with application verifier! -> [Windows] test_asyncio fails with application verifier! _cancel_overlapped() fails with "The handle is invalid"
messages: + msg355046

versions: + Python 3.9, - Python 3.8
2019-05-15 00:11:50Alexander Ricciosetmessages: + msg342526
2019-05-14 13:11:13asvetlovsetmessages: + msg342460
2019-05-14 13:07:12samjonassetnosy: + samjonas
messages: + msg342459
2019-05-06 11:28:16asvetlovsetcomponents: + asyncio
2019-05-04 00:19:06xtreaksetnosy: + asvetlov, yselivanov
2019-05-04 00:13:49Alexander Ricciosetfiles: + python_invalid_handle.PNG

messages: + msg341366
2019-05-04 00:10:11Alexander Ricciocreate