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-116510: Fix crash due to shared immortal interned strings. #124646

Merged
merged 1 commit into from
Sep 27, 2024

Conversation

nascheme
Copy link
Member

@nascheme nascheme commented Sep 27, 2024

Fix a crash caused by immortal interned strings being shared between
sub-interpreters that use basic single-phase init. In that case, the string
can be used by an interpreter that outlives the interpreter that created and
interned it. For interpreters that share obmalloc state, also share the
interned dict with the main interpreter.

@nascheme nascheme added type-crash A hard crash of the interpreter, possibly with a core dump 3.13 bugs and security fixes 3.14 new features, bugs and security fixes needs backport to 3.13 bugs and security fixes labels Sep 27, 2024
@nascheme nascheme merged commit 98b2ed7 into python:main Sep 27, 2024
42 checks passed
@miss-islington-app
Copy link

Thanks @nascheme for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 27, 2024
@bedevere-app
Copy link

bedevere-app bot commented Sep 27, 2024

GH-124648 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Sep 27, 2024
@bedevere-bot
Copy link

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

Hi! The buildbot iOS ARM64 Simulator 3.x has failed when building commit 98b2ed7.

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/#/builders/1380/builds/1423) and take a look at the build logs.
  4. Check if the failure is related to this commit (98b2ed7) 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/#/builders/1380/builds/1423

Failed tests:

  • test_support

Failed subtests:

  • test_fd_count - test.test_support.TestSupport.test_fd_count

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

==

Click to see traceback logs
Traceback (most recent call last):
  File "/Users/buildbot/Library/Developer/XCTestDevices/D9F34191-E74B-4D29-B721-2C5A66CE9BF9/data/Containers/Bundle/Application/C6972B3B-1B34-4FF9-A4EE-30CA8E98F224/iOSTestbed.app/python/lib/python3.14/test/test_support.py", line 565, in test_fd_count
    self.assertEqual(more - start, 1)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
AssertionError: 0 != 1

@mhsmith
Copy link
Member

mhsmith commented Sep 27, 2024

@freakboy3742: It might be a good idea to skip this test on iOS for the same reason as WASM: "The platform starts and stops background threads that use fds". I haven't seen this failure on Android yet, but I did have to skip a similar one in test_fd_leak in test_os.py.

@freakboy3742
Copy link
Contributor

@mhsmith Agreed; see #124683

Yhg1s pushed a commit that referenced this pull request Sep 27, 2024
…h-124646) (#124648)

gh-116510: Fix crash due to shared immortal interned strings. (gh-124646)
(cherry picked from commit 98b2ed7)

Co-authored-by: Neil Schemenauer <[email protected]>
nascheme added a commit to nascheme/cpython that referenced this pull request Sep 30, 2024
nascheme added a commit to nascheme/cpython that referenced this pull request Sep 30, 2024
The pythongh-124646 fix has the issue that it breaks the trace-refs debug
build.  This is a simpler fix that avoids the use-after-free crashes by
just leaking immortal interned strings allocated by legacy
subinterpreters.
nascheme added a commit to nascheme/cpython that referenced this pull request Sep 30, 2024
The pythonGH-124646 fix has the issue that it breaks the trace-refs debug
build.  This is a simpler fix that avoids the use-after-free crashes by
just leaking immortal interned strings allocated by legacy
subinterpreters.
Yhg1s added a commit to Yhg1s/cpython that referenced this pull request Sep 30, 2024
nascheme pushed a commit that referenced this pull request Sep 30, 2024
…ed strings (gh-124646)" (gh-124807)

Revert "gh-116510: Fix crash due to shared immortal interned strings. (gh-124646)"

This reverts commit 98b2ed7.
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 30, 2024
…ortal interned strings (pythongh-124646)" (pythongh-124807)

Revert "pythongh-116510: Fix crash due to shared immortal interned strings. (pythongh-124646)"

This reverts commit 98b2ed7.
(cherry picked from commit 7bdfabe)

Co-authored-by: T. Wouters <[email protected]>
Yhg1s added a commit that referenced this pull request Oct 1, 2024
… interned strings (gh-124646)" (gh-124807) (#124812)

gh-124785: Revert "gh-116510: Fix crash due to shared immortal interned strings (gh-124646)" (gh-124807)

Revert "gh-116510: Fix crash due to shared immortal interned strings. (gh-124646)"

This reverts commit 98b2ed7.
(cherry picked from commit 7bdfabe)

Co-authored-by: T. Wouters <[email protected]>
Yhg1s added a commit to Yhg1s/cpython that referenced this pull request Oct 1, 2024
…red immortal interned strings (pythongh-124646)" (pythongh-124807)

Revert "pythongh-116510: Fix crash due to shared immortal interned strings. (pythongh-124646)"

This reverts commit 98b2ed7.
(cherry picked from commit 7bdfabe)

Co-authored-by: T. Wouters <[email protected]>
ericsnowcurrently added a commit to ericsnowcurrently/cpython that referenced this pull request Oct 1, 2024
ericsnowcurrently added a commit that referenced this pull request Oct 9, 2024
…4865)

Fix a crash caused by immortal interned strings being shared between
sub-interpreters that use basic single-phase init. In that case, the string
can be used by an interpreter that outlives the interpreter that created and
interned it. For interpreters that share obmalloc state, also share the
interned dict with the main interpreter.

This is an un-revert of gh-124646 that then addresses the Py_TRACE_REFS
failures identified by gh-124785.
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 9, 2024
…ythongh-124865)

Fix a crash caused by immortal interned strings being shared between
sub-interpreters that use basic single-phase init. In that case, the string
can be used by an interpreter that outlives the interpreter that created and
interned it. For interpreters that share obmalloc state, also share the
interned dict with the main interpreter.

This is an un-revert of pythongh-124646 that then addresses the Py_TRACE_REFS
failures identified by pythongh-124785.
(cherry picked from commit f2cb399)

Co-authored-by: Eric Snow <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 9, 2024
…ythongh-124865)

Fix a crash caused by immortal interned strings being shared between
sub-interpreters that use basic single-phase init. In that case, the string
can be used by an interpreter that outlives the interpreter that created and
interned it. For interpreters that share obmalloc state, also share the
interned dict with the main interpreter.

This is an un-revert of pythongh-124646 that then addresses the Py_TRACE_REFS
failures identified by pythongh-124785.
(cherry picked from commit f2cb399)

Co-authored-by: Eric Snow <[email protected]>
encukou pushed a commit that referenced this pull request Nov 12, 2024
…gh-124865) (gh-125709) (GH-125204)

* gh-116510: Fix a Crash Due to Shared Immortal Interned Strings (gh-124865)

Fix a crash caused by immortal interned strings being shared between
sub-interpreters that use basic single-phase init. In that case, the string
can be used by an interpreter that outlives the interpreter that created and
interned it. For interpreters that share obmalloc state, also share the
interned dict with the main interpreter.

This is an un-revert of gh-124646 that then addresses the Py_TRACE_REFS
failures identified by gh-124785.
(cherry picked from commit f2cb399)

Co-authored-by: Eric Snow <[email protected]>

* [3.13] gh-125286: Share the Main Refchain With Legacy Interpreters (gh-125709)

They used to be shared, before 3.12.  Returning to sharing them resolves a failure on Py_TRACE_REFS builds.

---------

Co-authored-by: Eric Snow <[email protected]>
ericsnowcurrently added a commit that referenced this pull request Dec 3, 2024
…gh-125205)

Fix a crash caused by immortal interned strings being shared between
sub-interpreters that use basic single-phase init. In that case, the string
can be used by an interpreter that outlives the interpreter that created and
interned it. For interpreters that share obmalloc state, also share the
interned dict with the main interpreter.

This is an un-revert of gh-124646 that then addresses the Py_TRACE_REFS
failures identified by gh-124785 (i.e. backporting gh-125709 too).

(cherry picked from commit f2cb399, AKA gh-124865)

Co-authored-by: Eric Snow <[email protected]>
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 type-crash A hard crash of the interpreter, possibly with a core dump
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants