Skip to content

Segmentation fault in __lazy_import__ with non-string fromlist item #158637

Description

@error-3317

Crash report

Bug Details

__lazy_import__() segfaults when fromlist contains a non-string object.

PoC

__lazy_import__("os", fromlist=(123,))

Output

~$ python -X faulthandler -c '__lazy_import__("os", fromlist=(123,))'; echo "exit status: $?"
Fatal Python error: Segmentation fault

Current thread 0x00007fd2b9bd6740 [python] (most recent call first):
  File "<string>", line 1 in <module>

Current thread's C stack trace (most recent call first):
  Binary file "python", at _Py_DumpStack+0x30 [0x4f1dd0]
  Binary file "python" [0x59990b]
  Binary file "python" [0x59985e]
  Binary file "/lib/x86_64-linux-gnu/libc.so.6", at +0x3c050 [0x7fd2b990d050]
  Binary file "python" [0x1d98601]
  Binary file "python", at PyUnicode_FromFormat+0x60 [0x1a2e4e0]
  Binary file "python" [0x1b3efc5]
  Binary file "python" [0x491a67]
  Binary file "python" [0x4916bf]
  Binary file "python", at PyObject_Vectorcall+0x4c [0x1a15d64]
  Binary file "python", at _Py_VectorCallInstrumentation_StackRefSteal+0xca [0x1aa8e9a]
  Binary file "python" [0x1aaa666]
  Binary file "python" [0x1abf644]
  Binary file "python", at PyEval_EvalCode+0xa6 [0x1abf326]
  Binary file "python" [0x1aae98f]
  Binary file "python" [0x1aae7a9]
  Binary file "python" [0x1b7de90]
  Binary file "python", at Py_RunMain+0x58c [0x1b7dd8c]
  Binary file "python" [0x1b7d7dd]
  Binary file "python" [0x1b7d62c]
  Binary file "/lib/x86_64-linux-gnu/libc.so.6", at +0x2724a [0x7fd2b98f824a]
  Binary file "/lib/x86_64-linux-gnu/libc.so.6", at __libc_start_main+0x85 [0x7fd2b98f8305]
  Binary file "python", at _start+0x29 [0x1bf9b69]
Segmentation fault
exit status: 139

CPython versions tested on:

3.15

Operating systems tested on:

Linux

Output from running 'python -VV' on the command line:

Python 3.15.0rc2 (main, Sep 29 2026, 15:02:39) [Clang 22.1.3 ]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)topic-lazy-importstype-crashA hard crash of the interpreter, possibly with a core dump

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions