Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

bpo-40826: Add _PyOS_InterruptOccurred(tstate) function#20599

Merged
vstinner merged 3 commits into
python:masterpython/cpython:masterfrom
vstinner:interrupt_tstateCopy head branch name to clipboard
Jun 3, 2020
Merged

bpo-40826: Add _PyOS_InterruptOccurred(tstate) function#20599
vstinner merged 3 commits into
python:masterpython/cpython:masterfrom
vstinner:interrupt_tstateCopy head branch name to clipboard

Conversation

@vstinner

@vstinner vstinner commented Jun 2, 2020

Copy link
Copy Markdown
Member

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

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.
@vstinner

vstinner commented Jun 2, 2020

Copy link
Copy Markdown
Member Author

@corona10: Ok here my fix for https://bugs.python.org/issue40826 Should I include the test that you wrote in PR #20549?

@corona10

corona10 commented Jun 2, 2020

Copy link
Copy Markdown
Member

@vstinner Please go ahead :)

test_repl: use text=True and avoid SuppressCrashReport in
test_multiline_string_parsing().
@vstinner

vstinner commented Jun 2, 2020

Copy link
Copy Markdown
Member Author

Well, I added a test, but different than yours.

@vstinner

vstinner commented Jun 2, 2020

Copy link
Copy Markdown
Member Author

The test fails on Windows:

FAIL: test_close_stdin (test.test_repl.TestInteractiveInterpreter)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\a\cpython\cpython\lib\test\test_repl.py", line 103, in test_close_stdin
    self.assertEqual(process.returncode, 0)
AssertionError: 3221226505 != 0

@corona10

corona10 commented Jun 2, 2020

Copy link
Copy Markdown
Member

The test fails on Windows:

Yeah, I skipped the test on Windows.

@vstinner

vstinner commented Jun 2, 2020

Copy link
Copy Markdown
Member Author

Yeah, I skipped the test on Windows.

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.
@vstinner

vstinner commented Jun 2, 2020

Copy link
Copy Markdown
Member Author

@corona10: I fixed yet another bug, crash on Windows, in my PR. Would you mind to review the PR?

@corona10 corona10 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! LGTM

The PR is very awesome that it solve also the Windows issue :)

@vstinner vstinner merged commit fa7ab6a into python:master Jun 3, 2020
@vstinner vstinner deleted the interrupt_tstate branch June 3, 2020 12:40
@vstinner

vstinner commented Jun 3, 2020

Copy link
Copy Markdown
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.