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
Embedded python crashed on 4th run, if "ctypes" is used #51118
Comments
When embedding python from C, and importing "ctypes" module in embedded Code: #include <stdio.h>
#include <python.h>
int main()
{
int i;
for (i=0; i<10; i++)
{
printf("--- %d ---\n", i);
Py_Initialize();
PyRun_SimpleString("import ctypes");
Py_Finalize();
}
return 0;
} Output: Process returned -1073741819 (0xC0000005) execution time : 3.109 s |
Tested
obj=PyImport_ImportModule("ctypes");
Py_DECREF(obj);
instead of PyRun_SimpleString(...) - same result |
on python2.5 / mac os x 10.5.7: $ cat main.c
#include <stdio.h>
#include <python.h>
int main()
{
int i;
for (i=0; i<10; i++)
{
printf("--- %d ---\n", i);
Py_Initialize();
PyRun_SimpleString("import ctypes");
Py_Finalize();
}
return 0;
} $ gcc -I/usr/include/python2.5/ -L/usr/lib/python2.5/ -lpython main.c
$ ./a.out
--- 0 --- 1 --- |
I hope attached patch will fix this issue. |
I can confirm that the patch fix this issue. I adapted the patch (variable names changed): 5523a5524
5529a5531
5535a5538
5541a5545
5547a5552
5553a5559
Platform: Linux (kubuntu 9.10 x64) |
Fixed in rev 83841 (py3k), rev 83842 (release31-maint), and rev 83843 (release27-maint). Thanks for the patch. |
I found another refcount bug in Python3.x. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: