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

SystemError caused by _interpreters.create() with invalid unicode argument #126223

Closed
devdanzin opened this issue Oct 31, 2024 · 2 comments
Closed
Labels
3.13 bugs and security fixes 3.14 new features, bugs and security fixes extension-modules C modules in the Modules dir topic-subinterpreters type-bug An unexpected behavior, bug, or error

Comments

@devdanzin
Copy link
Contributor

devdanzin commented Oct 31, 2024

Bug report

Bug description:

It's possible to make a debug build of Python abort by passing an invalid Unicode argument to _interpreters.create(), resulting in SystemError: <built-in function create> returned a result with an exception set.

$ ./python -c "import _interpreters; _interpreters.create('\udc80')"
Fatal Python error: _Py_CheckFunctionResult: a function returned a result with an exception set
Python runtime state: initialized
UnicodeEncodeError: 'utf-8' codec can't encode character '\udc80' in position 0: surrogates not allowed

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

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

Current thread 0x00007f0234dca740 (most recent call first):
  File "<string>", line 1 in <module>
Aborted

Found using fusil by @vstinner.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux, Windows

Linked PRs

@devdanzin devdanzin added the type-bug An unexpected behavior, bug, or error label Oct 31, 2024
@ZeroIntensity
Copy link
Member

Confirmed, this is a pretty simple fix. I'll submit a patch.

sobolevn added a commit that referenced this issue Oct 31, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Oct 31, 2024
…pythonGH-126224)

(cherry picked from commit 0141521)

Co-authored-by: Peter Bierma <[email protected]>
Co-authored-by: sobolevn <[email protected]>
Co-authored-by: Bénédikt Tran <[email protected]>
@picnixz picnixz added 3.13 bugs and security fixes 3.14 new features, bugs and security fixes labels Oct 31, 2024
sobolevn added a commit that referenced this issue Oct 31, 2024
GH-126224) (#126242)

gh-126223: Propagate unicode errors in `_interpreters.create()` (GH-126224)
(cherry picked from commit 0141521)

Co-authored-by: Peter Bierma <[email protected]>
Co-authored-by: sobolevn <[email protected]>
Co-authored-by: Bénédikt Tran <[email protected]>
@picnixz
Copy link
Contributor

picnixz commented Oct 31, 2024

Closing since completed and backported. Thank you all!

@picnixz picnixz closed this as completed Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes 3.14 new features, bugs and security fixes extension-modules C modules in the Modules dir topic-subinterpreters type-bug An unexpected behavior, bug, or error
Projects
Status: Done
Development

No branches or pull requests

3 participants