Skip to content

Segfault in GC at shutdown in 3.14-alpha.5 #130380

@bdarnell

Description

@bdarnell

Bug report

Bug description:

While testing Tornado's test suite on 3.14-alpha.5, I found that after running certain (innocuous-looking) tests I would get a segfault in GC as the process shuts down. Unfortunately faulthandler doesn't give me any useful information:

(tornado) bdarnell@MacBookPro tornado % PYTHONFAULTHANDLER=1 uv run --no-project -p 3.14 python  -m tornado.test tornado.test.ioloop_test.TestPeriodicCallbackAsync.test_periodic_plain
.
----------------------------------------------------------------------
Ran 1 test in 0.031s

OK
Fatal Python error: Segmentation fault

Current thread 0x00000001f7ee4840 (most recent call first):
  Garbage-collecting
  <no Python frame>

I've narrowed the problem down to two tests in TestPeriodicCallbackAsync, test_periodic_plain and test_periodic_coro. Curiously, the very similar test_periodic_async test in the same class does not trigger the segfault. The GC failure appears to be deterministic when either of these tests are run and does not occur on any older version from 3.9-3.13. I've seen it on both macOS and linux (ubuntu 22.04 and 24.04).

The tests themselves are small, although they pull in a non-trivial amount of machinery from Tornado and asyncio (note that this is all pure python on the Tornado side; the small amount of C code we use isn't imported in this test). I'll see if I can reduce the test case further to be more self-contained. Is there anything that can be done to get more information about the objects being GC'd in the failure?

The exact tornado commit I'm testing is tornadoweb/tornado@5ae2fbb. This includes some unmerged changes to adapt to new deprecation warnings.

CPython versions tested on:

3.14

Operating systems tested on:

Linux, macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions