Author kryheb
Recipients kryheb
Date 2021-06-17.10:14:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1623924852.9.0.945684144321.issue44441@roundup.psfhosted.org>
In-reply-to
Content
Hi all,

I observed misbehavior trying to embed the Python interpreter into a C app.
It seems that after re-initialization, PyImport_Inittab is malformed and points to the memory freed _PyImport_Fini2.


Steps to reproduce:

1. Append embedded module
2. Initialize Python from config with run_filename
3. Run main with an infinite loop
4. Interrupt script execution with async call
5. Finalize Python
6. Repeat all above

Observed behavior:
The script is executed at first iteration, but re-initialization fails with an error:
"
Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 1187, in _install_external_importers
ModuleNotFoundError: No module named 'posix'

Error: external importer setup failed
"

Head of modules list at fist run:
------ Modules: ------
#0 'posix'
#1 'errno'
#2 'pwd'
----------------------
and after re-initialization:
------ Modules: ------
#0 'P ''
#1 'errno'
#2 'pwd'
----------------------

An issue discovered on:
Fedora 33
gcc (GCC) 10.3.1 20210422 (Red Hat 10.3.1-1)
python3-devel.x86_64 3.9.5-2.fc33

Issue still exists on the latest main and on the rc 3.10
Source code to reproduce an issue in attachment.

Best regards,
Krystian Heberlein
History
Date User Action Args
2021-06-17 10:14:12kryhebsetrecipients: + kryheb
2021-06-17 10:14:12kryhebsetmessageid: <1623924852.9.0.945684144321.issue44441@roundup.psfhosted.org>
2021-06-17 10:14:12kryheblinkissue44441 messages
2021-06-17 10:14:12kryhebcreate