bpo-40826: Add _PyOS_InterruptOccurred(tstate) function#20599
Merged
vstinner merged 3 commits intopython:masterfrom Jun 3, 2020
vstinner:interrupt_tstate
Merged
bpo-40826: Add _PyOS_InterruptOccurred(tstate) function#20599vstinner merged 3 commits intopython:masterfrom vstinner:interrupt_tstate
vstinner merged 3 commits intopython:masterfrom
vstinner:interrupt_tstate
Conversation
my_fgets() now calls _PyOS_InterruptOccurred(tstate) to check for pending signals, rather calling PyOS_InterruptOccurred(). my_fgets() is called with the GIL released, whereas PyOS_InterruptOccurred() must be called with the GIL held.
Member
Author
|
@corona10: Ok here my fix for https://bugs.python.org/issue40826 Should I include the test that you wrote in PR #20549? |
Member
|
@vstinner Please go ahead :) |
test_repl: use text=True and avoid SuppressCrashReport in test_multiline_string_parsing().
Member
Author
|
Well, I added a test, but different than yours. |
Member
Author
|
The test fails on Windows: |
Member
Yeah, I skipped the test on Windows. |
Member
Author
Well, 3221226505 exit code is STATUS_STACK_BUFFER_OVERRUN (0xC0000409): it's a crash. It seems like fgets() crash when the file descriptor is closed. |
On Windows, fgets(fp) does crash if fileno(fp) is closed.
Member
Author
|
@corona10: I fixed yet another bug, crash on Windows, in my PR. Would you mind to review the PR? |
corona10
approved these changes
Jun 3, 2020
Member
corona10
left a comment
There was a problem hiding this comment.
Nice! LGTM
The PR is very awesome that it solve also the Windows issue :)
Member
Author
|
Thanks for the review @corona10. |
vstinner
added a commit
that referenced
this pull request
Jun 3, 2020
* bpo-40826: Fix GIL usage in PyOS_Readline() (GH-20579) Fix GIL usage in PyOS_Readline(): lock the GIL to set an exception. Pass tstate to my_fgets() and _PyOS_WindowsConsoleReadline(). Cleanup these functions. (cherry picked from commit c353764) * bpo-40826: Add _PyOS_InterruptOccurred(tstate) function (GH-20599) my_fgets() now calls _PyOS_InterruptOccurred(tstate) to check for pending signals, rather calling PyOS_InterruptOccurred(). my_fgets() is called with the GIL released, whereas PyOS_InterruptOccurred() must be called with the GIL held. test_repl: use text=True and avoid SuppressCrashReport in test_multiline_string_parsing(). Fix my_fgets() on Windows: fgets(fp) does crash if fileno(fp) is closed. (cherry picked from commit fa7ab6a)
vstinner
added a commit
that referenced
this pull request
Jun 3, 2020
* bpo-40826: Fix GIL usage in PyOS_Readline() (GH-20579) Fix GIL usage in PyOS_Readline(): lock the GIL to set an exception. Pass tstate to my_fgets() and _PyOS_WindowsConsoleReadline(). Cleanup these functions. (cherry picked from commit c353764) * bpo-40826: Add _PyOS_InterruptOccurred(tstate) function (GH-20599) my_fgets() now calls _PyOS_InterruptOccurred(tstate) to check for pending signals, rather calling PyOS_InterruptOccurred(). my_fgets() is called with the GIL released, whereas PyOS_InterruptOccurred() must be called with the GIL held. test_repl: use text=True and avoid SuppressCrashReport in test_multiline_string_parsing(). Fix my_fgets() on Windows: fgets(fp) does crash if fileno(fp) is closed. (cherry picked from commit fa7ab6a)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
my_fgets() now calls _PyOS_InterruptOccurred(tstate) to check for
pending signals, rather calling PyOS_InterruptOccurred().
my_fgets() is called with the GIL released, whereas
PyOS_InterruptOccurred() must be called with the GIL held.
https://bugs.python.org/issue40826