python_hu <nari...@163.com> added the comment: Thank Amaury,you are right. So python2.7 share library compile finished,and python2.7 works,and then I write a test program,to test libpython2.7.so share library,but it dumped!
code: ----------------------- #include <stdio.h>^M #include "Python.h"^M #include <dlfcn.h> ^M ^M int main( int argc, char **argv )^M {^M Py_Initialize(); if(!Py_IsInitialized()) { printf("py initialized fail!"); return -1; } void* handle = dlopen("/usr/local/lib/python2.6/lib-dynload/time.so", 2); if (handle == NULL) { const char *error = dlerror(); if (error == NULL) error = "unknown dlopen() error"; printf("erro=%s\n",error); return NULL; } if(!Py_IsInitialized()) { printf("py initialized fail!"); return -1; } printf("hi,python!\n"); PyRun_SimpleString("from time import time,ctime\nprint 'Today is',ctime(time())\n"); Py_Finalize(); } ---------------------------------------------------- This code can compile sucess,but run core dump: ibm1:mmi>pytest hi,python! Fatal Python error: Interpreter not initialized (version mismatch?) The core dump file: --------------------------------------------------------- IOT/Abort trap in pthread_kill at 0x900000000e23450 ($t1) 0x900000000e23450 (pthread_kill+0xb0) e8410028 ld r2,0x28(r1) (dbx) run hi,python! Fatal Python error: Interpreter not initialized (version mismatch?) IOT/Abort trap in pthread_kill at 0x900000000e23450 ($t1) 0x900000000e23450 (pthread_kill+0xb0) e8410028 ld r2,0x28(r1) (dbx) where pthread_kill(??, ??) at 0x900000000e23450 _p_raise(??) at 0x900000000e22cc8 raise.raise(??) at 0x90000000002b10c abort() at 0x900000000094544 pythonrun.Py_FatalError(msg = "init%.200s"), line 1675 in "pythonrun.c" modsupport.Py_InitModule4_64(name = (nil), methods = 0x09001000a0b467d8, doc = (invalid char ptr (0x2f7573722f6c6f63)), passthrough = 0x616c2f6c69622f70, module_api_version = 0), line 38 in "modsupport.c" inittime(), line 825 in "timemodule.c" importdl._PyImport_LoadDynamicModule(name = (nil), pathname = "", fp = 0x0000000000000004), line 53 in "importdl.c" import.load_module(name = "", fp = 0x0fffffffffffd8d8, buf = "^O\377\377\377\377\377\316p^I", type = 150994944, loader = 0x0000000110016e90), line 1830 in "import.c" import.import_submodule(mod = 0x0900000005d0ebc4, subname = "", fullname = "^I"), line 2592 in "import.c" import.load_next(mod = 0x0000000000000005, altmod = (nil), p_name = 0x0900000005dcba27, buf = "", p_buflen = 0x09001000a0b2f9d0), line 2412 in "import.c" import.import_module_level(name = (nil), globals = 0x000000011008c328, locals = 0x000000011008c328, fromlist = 0x000000011013d608, level = -1), line 2133 in "import.c" import.PyImport_ImportModuleLevel(name = "", globals = (nil), locals = 0x0900000005dcba20, fromlist = 0x09001000a0b2f9d0, level = 268435455), line 2185 in "import.c" bltinmodule.builtin___import__(self = 0x0fffffffffffd970, args = 0x0000000000000060, kwds = 0x0fffffffffffd980), line 48 in "bltinmodule.c" methodobject.PyCFunction_Call(func = 0x0fffffffffffd9f0, arg = 0x09001000a0b467d8, kw = 0x0fffffffffffda00), line 85 in "methodobject.c" abstract.PyObject_Call(func = 0x0900000005cb9ae4, arg = 0x09001000a0b467d8, kw = 0x0fffffffffffda90), line 2492 in "abstract.c" ceval.PyEval_CallObjectWithKeywords(func = 0x0000000000000004, arg = 0x00000001100992d0, kw = 0x000000011008c328), line 3619 in "ceval.c" ceval.PyEval_EvalFrameEx(f = 0x0fffffffffffdda0, throwflag = 0), line 2159 in "ceval.c" ceval.PyEval_EvalCodeEx(co = (nil), globals = 0x000000011000ca50, locals = 0x0fffffffffffdee4, args = 0x000000011019a740, argcount = 1, kws = 0x09001000a0075420, kwcount = -1159983106, defs = 0xbadc0ffee0ddf00d, defcount = 0, closure = (nil)), line 3000 in "ceval.c" ceval.PyEval_EvalCode(co = 0x0900000005d578cc, globals = 0x488842281006e148, locals = (nil)), line 541 in "ceval.c" pythonrun.run_mod(mod = 0x0fffffffffffdff0, filename = "^I\377\377\377\360", globals = 0x0900000000028c20, locals = 0x09001000a0b467d8, flags = 0xbadc0ffee0ddf00d, arena = 0x09001000a0075420), line 1351 in "pythonrun.c" pythonrun.PyRun_StringFlags(str = "\350A", start = -1159983106, globals = 0xbadc0ffee0ddf00d, locals = 0xbadc0ffee0ddf00d, flags = 0xbadc0ffee0ddf00d), line 1314 in "pythonrun.c" pythonrun.PyRun_SimpleStringFlags(command = "sucess!", flags = 0x0000000000000001), line 967 in "pythonrun.c" main.main(argc = 1, argv = 0x0fffffffffffe190), line 42 in "main.cpp" (dbx) --------------------------------------- the line 38 in "modsupport.c": if (!Py_IsInitialized()) Py_FatalError("Interpreter not initialized (version mismatch?)"); it looks like "Py_IsInitialized()" is false,but in my main(),the "Py_IsInitialized()" return true. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue13493> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com