Skip to content
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

gh-110365: Fix error overwrite in termios.tcsetattr #110366

Merged
merged 10 commits into from
Oct 5, 2023

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Oct 4, 2023

@erlend-aasland we fixed several similar errors before, would you mind to take a look?

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

See also the loop below. The result of PyLong_AsLong() is not checked.

Modules/termios.c Outdated Show resolved Hide resolved
Modules/termios.c Outdated Show resolved Hide resolved
Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

See also PyLong_AsLong() in the loop below.

@sobolevn
Copy link
Member Author

sobolevn commented Oct 4, 2023

@serhiy-storchaka yes, you found one more problem, this code crashes!

Before:

>>> termios.tcsetattr(0, 0, [0, 1, 2, 3, 4, 5, [*range(0, 19), sys.maxsize * 10]])
Fatal Python error: _Py_CheckFunctionResult: a function returned a result with an exception set
    Python runtime state: initialized
                                     OverflowError: Python int too large to convert to C long

  The above exception was the direct cause of the following exception:

                                                                      SystemError: <built-in function tcsetattr> returned a result with an exception set

                                                             Current thread 0x00000001de555300 (most recent call first):
                               File "<stdin>", line 1 in <module>
                                                                 [1]    20789 abort      ./python.exe

After:

>>> import termios, sys
>>> termios.tcsetattr(0, 0, [0, 1, 2, 3, 4, 5, [*range(0, 19), sys.maxsize * 10]])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: Python int too large to convert to C long
>>> 
KeyboardInterrupt
>>> ^D

Modules/termios.c Outdated Show resolved Hide resolved
Modules/termios.c Outdated Show resolved Hide resolved
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
erlend-aasland
erlend-aasland previously approved these changes Oct 5, 2023
@erlend-aasland
Copy link
Contributor

[...] found one more problem, this code crashes! [...]

Could you add this test case to the test suite?

@erlend-aasland erlend-aasland dismissed their stale review October 5, 2023 08:13

My suggestion was buggy, and there is no tests

@sobolevn
Copy link
Member Author

sobolevn commented Oct 5, 2023

Could you add this test case to the test suite?

Please, see my comment here: #110365

We don't have test_termios.py at all.
I can start small with tests that are described in this issue/PR. But, I won't be able to create the whole suite right now.

Modules/termios.c Outdated Show resolved Hide resolved
Modules/termios.c Outdated Show resolved Hide resolved
@sobolevn
Copy link
Member Author

sobolevn commented Oct 5, 2023

Thanks, @erlend-aasland!

@sobolevn
Copy link
Member Author

sobolevn commented Oct 5, 2023

New issue about missing tests: #110380

@erlend-aasland erlend-aasland enabled auto-merge (squash) October 5, 2023 09:29
@erlend-aasland erlend-aasland added needs backport to 3.11 only security fixes needs backport to 3.12 bug and security fixes labels Oct 5, 2023
@erlend-aasland erlend-aasland merged commit 2bbbab2 into python:main Oct 5, 2023
25 checks passed
@miss-islington
Copy link
Contributor

Thanks @sobolevn for the PR, and @erlend-aasland for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 5, 2023
…-110366)

(cherry picked from commit 2bbbab2)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Erlend E. Aasland <erlend@python.org>
@bedevere-app
Copy link

bedevere-app bot commented Oct 5, 2023

GH-110389 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 bug and security fixes label Oct 5, 2023
@bedevere-app
Copy link

bedevere-app bot commented Oct 5, 2023

GH-110390 is a backport of this pull request to the 3.11 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.11 only security fixes label Oct 5, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 5, 2023
…-110366)

(cherry picked from commit 2bbbab2)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Erlend E. Aasland <erlend@python.org>
@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot s390x Fedora LTO 3.x has failed when building commit 2bbbab2.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/55/builds/3943) and take a look at the build logs.
  4. Check if the failure is related to this commit (2bbbab2) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/55/builds/3943

Failed tests:

  • test_subprocess

Failed subtests:

  • test_pipesize_default - test.test_subprocess.ProcessTestCase.test_pipesize_default

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/home/dje/cpython-buildarea/3.x.edelsohn-fedora-z.lto/build/Lib/test/test_subprocess.py", line 763, in test_pipesize_default
    self.assertEqual(
AssertionError: 65536 != 8192

@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 Debian root 3.x has failed when building commit 2bbbab2.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/345/builds/6019) and take a look at the build logs.
  4. Check if the failure is related to this commit (2bbbab2) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/345/builds/6019

Failed tests:

  • test.test_concurrent_futures.test_shutdown

Failed subtests:

  • test_interpreter_shutdown - test.test_concurrent_futures.test_shutdown.ProcessPoolSpawnProcessPoolShutdownTest.test_interpreter_shutdown

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/test/test_concurrent_futures/test_shutdown.py", line 50, in test_interpreter_shutdown
    self.assertEqual(out.strip(), b"apple")
AssertionError: b'' != b'apple'

erlend-aasland added a commit that referenced this pull request Oct 5, 2023
…) (#110389)

(cherry picked from commit 2bbbab2)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Erlend E. Aasland <erlend@python.org>
erlend-aasland added a commit that referenced this pull request Oct 5, 2023
…) (#110390)

(cherry picked from commit 2bbbab2)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Erlend E. Aasland <erlend@python.org>
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.

None yet

5 participants