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
Embedding python into shared library crash on AIX #50991
Comments
Hi there, #include <Python.h>
#include <iostream>
extern "C"
void allocate()
{
std::cout << " am i ok = " << Py_IsInitialized() << std::endl;
Py_InitializeEx(0);
std::cout << " am i ok 1 = " << Py_IsInitialized() << std::endl;
PyRun_SimpleString("from time import time, datetime, ctime\n"
"print 'Today is',ctime(time())\n");
Py_Finalize();
}
my main application is also very simple
#include <iostream>
#include <iomanip>
#include <dlfcn.h>
//#include <link.h>
#include <Python.h>
typedef void (*ALLOCATE)();
int main (int argc, char ** argv)
{
// parse params to load shared object
if (argc < 2)
{
std::cerr << "Usage: " << argv[0] << " sharedObject(s)" << std::endl;
return 0;
}
// Py_Initialize();
for (int i = 1; i < argc; ++i)
{
void * handle = ::dlopen(argv[i], RTLD_LAZY);
if (!handle)
{
std::cerr << dlerror() << argv[i] << std::endl;
return 0;
}
// Use that handle to locate the symbol. The symbol must be
// demangled so it has to be compiled with extern "C".
ALLOCATE dlmAllocate = (ALLOCATE) ::dlsym(handle, "allocate");
if (!dlmAllocate)
{
std::cerr << dlerror() << std::endl;
return 0;
}
dlmAllocate();
}
return 0;
} here is my makefile CXX := g++ default: DLOpenTest mypython.so DLOpenTest: DLOpen.C mypython.so: mypython.C clean: Can someone help me out? Or has anyone even tried same thing on AIX? NOTE, the issue is not like bpo-4434 or 1332869. Please don't reply Thanks a log |
If you get differing results from Py_IsInitialized, my guess is that you An AIX expert would be required to diagnose this in more detail; |
You may want to take a look at bpo-941346 in order to compile libpython2.6.so on AIX. I also embed python in my AIX application, and I had no problem once python was compiled as share thanks to the patch provided in the other issue. |
This issue has been fixed as part of bpo-941346 and should be closed in my opinion. |
msg192851 states that this should be closed. If somebody agrees with that statement would they please do the honours. |
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: