-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
extmod/asyncio/event.py: Fix ThreadSafeFlag.ioctl return. #12443
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
extmod/asyncio/event.py: Fix ThreadSafeFlag.ioctl return. #12443
Conversation
@dpgeorge This PR solves the problem and aioble works now, but it's worth noting that this actually triggered a seg fault, because the nlr raise in the middle of This might be a case for the new nlr jump callback, to cleanup if the ioctl failed? i.e. it seems wrong that poller.register can raise and leave the poller in an invalid state if the pollable's ioctl raises. |
Code size report:
|
Added a change to the ThreadSafeFlag test to make it no longer sensitive to the order that the scheduler runs relative to the main code. e.g. the ioctl(MP_STREAM_GET_FILENO) call could trigger the scheduler. |
Codecov Report
@@ Coverage Diff @@
## master #12443 +/- ##
==========================================
- Coverage 98.39% 98.38% -0.01%
==========================================
Files 158 158
Lines 20939 20940 +1
==========================================
Hits 20602 20602
- Misses 337 338 +1 |
Yes I was aware of this issue when writing the code. It was really hard to solve so I just left it and instead added the comment in
The poll change was made before nlr jump callbacks were added, so, yes, maybe we can use nlr jump callbacks to fix this issue. It's low priority though, because a well-behaved program shouldn't crash in this way. |
iobase_ioctl expects that an ioctl method must return an integer, and will raise otherwise. This was tripping up aioble on Unix, where the new hybrid modselect.c implementation will attempt to extract a file descriptor from the pollable via ioctl(MP_STREAM_GET_FILENO). However, ThreadSafeFlag's ioctl only supported MP_STREAM_POLL, and returned None otherwise. This makes it return `-1` (to match tests/extmod/select_poll_custom.py). It should probably be `-22` (corresponding to MP_EINVAL), but the value is never checked, and MP_EINVAL can be a different value on different ports. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
1. Remove the skip for detecting support for polling user-defined objects as this is always possible now on all ports. 2. Don't print when the scheduled task runs as the ordering of this relative to the other prints is dependent on other factors (e.g. if using the native emitter). This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
3e204b8
to
fae83a6
Compare
iobase_ioctl expects that an ioctl method must return an integer, and will raise otherwise.
This was tripping up aioble on Unix, where the new hybrid modselect.c implementation will attempt to extract a file descriptor from the pollable via ioctl(MP_STREAM_GET_FILENO).
However, ThreadSafeFlag's ioctl only supported MP_STREAM_POLL, and returned None otherwise.
This makes it return
-1
(to match tests/extmod/select_poll_custom.py). It should probably be-22
(corresponding to MP_EINVAL), but the value is never checked, and MP_EINVAL can be a different value on different ports.This work was funded through GitHub Sponsors.