GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-130163: Fix usage of borrow references from _PySys_GetAttr by sergey-miryanov · Pull Request #130282 · python/cpython

Conversation

@sergey-miryanov

@sergey-miryanov sergey-miryanov commented Feb 18, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

WIP

  • Issue: Crash when concurrently writing with print and concurrently modifying sys.stdout #130163
Repro Tests Raised exception
_pickle.c/whichmodule No No Don't keep
_threadmodule.c/thread_excepthook No No Keep
faulthandler.c/faulthandler_get_fileno Yes Yes Don't keep
bltinmodule.c/builtin_print_impl Yes Yes Don't keep
bltinmodule.c/builtin_input_impl Yes Yes Don't keep
errors.c/write_unraisable_exc No No Keep
errors.c/format_unraisable_v Yes Yes Keep
_warnings.c/show_warning Yes Yes Don't keep
intrinsics.c/print_expr No No Don't keep
pylifecycle.c/flush_std_files Yes/No Yes/No Don't keep
pythonrun.c/_PyRun_InteractiveLoopObject No No Don't keep
pythonrun.c/pyrun_one_parse_ast No No Don't keep
pythonrun.c/_Py_HandleSystemExitAndKeyboardInterrupt No No Don't keep
pythonrun.c/_PyErr_PrintEx Yes Yes Don't keep
pythonrun.c/PyErr_Display No No Don't keep
pythonrun.c/flush_io_stream No No Don't keep
sysmodule.c/sys_displayhook Maybe No Don't keep
sysmodule.c/get_warnoptions No No Don't keep
sysmodule.c/PySys_ResetWarnOptions No No Don't keep
sysmodule.c/PySys_HasWarnOptions No No Don't keep
sysmodule.c/_PySys_AddXOptionWithError No No Don't keep
sysmodule.c/PySys_SetArgvEx No No Don't keep
sysmodule.c/sys_write No No Don't keep
sysmodule.c/sys_format No No Don't keep
traceback.c/_Py_FindSourceFile No No Don't keep
  • I can get a "segfault" error when I use sys_displayhook, but not where it's used.
  • For sys_write, sys_format - I have checked all the places where they called, and most of the locations are safe. However, a few places use %s specifier, in such places it is very tricky to get segfault.
  • get_warnoptions, PySys_ResetWarnOptions, _PySys_AddXOptionWithError - are deprecated, but it is a very tricky to get segfault too.
  • flush_io_stream, PyErr_Display, pyrun_one_parse_ast, print_expr, write_unraisable_exc, thread_excepthook - very tight - They use a borrowed reference right after getting. It might be possible to reproduce it under heavy contention, but I wasn't able to do so.
  • _PyRun_InteractiveLoopObject only checks presence of ps1 and ps2.
  • flush_std_files used from _Py_Finalize and from fatal_error. For _Py_Finalize I can repro, for fatal_error - no.
  • whichmodule, _Py_FindSourceFile iterate borrowed reference, but I wasn't able to reproduce segfault.
  • Keep or not before raised exception - in the most places _PySys_GetAttr called without an exception set.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@sergey-miryanov
Add test for changing stdout from thread
f5b64f6
@bedevere-app bedevere-app Bot added the tests Tests in the Lib/test dir label Feb 18, 2025
@sergey-miryanov
sergey-miryanov marked this pull request as draft February 18, 2025 19:58
@bedevere-app bedevere-app Bot added awaiting review and removed awaiting review labels Feb 18, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Feb 18, 2025
Crash when concurrently writing with print and concurrently modifying sys.stdout #130163
Closed
sergey-miryanov added 8 commits February 20, 2025 19:05
@sergey-miryanov
Add tests for faulthandler
97e0b2e
@sergey-miryanov
Add tests for warnings and simplify for print
1987fb2
- also add checks of exit code
@sergey-miryanov
Add tests for input
f13cdbb
@sergey-miryanov
Add test for unraisablehook
1d0b0e0
@sergey-miryanov
Add tests for pylifecycle/flush_std_files
9cf4173
@sergey-miryanov
Fix tests for input
e65b17c
@sergey-miryanov
Add test for _PyErr_PrintEx
93d9fb7
@sergey-miryanov
Simplify tests for print and add _check to unify tests
4139409
@sergey-miryanov sergey-miryanov mentioned this pull request Feb 24, 2025
Add replacements for PySys_GetObject() capi-workgroup/decisions#54
Closed
@sergey-miryanov
Add comments to tests
9220dd2
@sergey-miryanov

sergey-miryanov commented Feb 25, 2025

Copy link
Copy Markdown
Contributor Author

Close in favor #130503

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sergey-miryanov sergey-miryanov closed this Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

tests Tests in the Lib/test dir

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@sergey-miryanov
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.