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

ExtensionFileLoader.load_module aborts when initialized with a path containing null-bytes #127208

Open
devdanzin opened this issue Nov 24, 2024 · 1 comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-importlib type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@devdanzin
Copy link
Contributor

devdanzin commented Nov 24, 2024

Crash report

What happened?

It's possible to abort a debug build by initializing a _frozen_importlib_external.ExtensionFileLoader with a path containing null-bytes, then calling load_module():

import _frozen_importlib_external

_frozen_importlib_external.ExtensionFileLoader("a", "\x00").load_module(None)

Abort message:

python: Python/import.c:939: hashtable_key_from_2_strings: Assertion `strlen(key) == size - 1' failed.
Aborted

Found using fusil by @vstinner.

CPython versions tested on:

3.12, 3.13, 3.14, CPython main branch

Operating systems tested on:

Linux

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

Python 3.14.0a2+ (heads/main:0af4ec3, Nov 20 2024, 21:45:19) [GCC 13.2.0]

@devdanzin devdanzin added the type-crash A hard crash of the interpreter, possibly with a core dump label Nov 24, 2024
@devdanzin
Copy link
Contributor Author

Another way to trigger:

>>> import _imp
>>> class n:
...   name = "A"
...   origin = "\x00"
...
>>> _imp.create_dynamic(n, 1)
python: Python/import.c:939: hashtable_key_from_2_strings: Assertion `strlen(key) == size - 1' failed.
Aborted

@picnixz picnixz added interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-importlib labels Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-importlib type-crash A hard crash of the interpreter, possibly with a core dump
Projects
None yet
Development

No branches or pull requests

2 participants