undefined symbol: PyExc_SystemError with RTLD_LOCAL
*Created originally on Bitbucket by Anonymous* I'm trying to dlopen() a shared library created by CFFI from demo/embedding.py example: ``` #!/usr/bin/env python import cffi ffi = cffi.FFI() ffi.embedding_api(""" int add(int, int); """) ffi.embedding_init_code(""" from pyembedded import ffi print("preparing") # printed once @ffi.def_extern() def add(x, y): print("adding %d and %d" % (x, y)) return x + y """) ffi.set_source("pyembedded", "") ffi.compile(verbose=True) ``` ``` #include <stdio.h> #include <dlfcn.h> int main(int argc, char *argv) { void *py = dlopen("./pyembedded.so", RTLD_NOW | RTLD_LOCAL); if (py == NULL) { fprintf(stderr, "Failed to load library\n"); return -1; } int (*add)(int, int) = dlsym(py, "add"); if (add == NULL) { fprintf(stderr, "Failed to find 'add' function\n"); dlclose(py); return -1; } int c = add(10, 15); printf("result: %d\n", c); dlclose(py); return 0; } ``` gcc test.c -o test -ldl ``` roman@book:~$ ./test ImportError: /usr/lib/python2.7/dist-packages/_cffi_backend.x86_64-linux-gnu.so: undefined symbol: PyExc_SystemError From: pyembedded compiled with cffi version: 1.6.0 _cffi_backend module: not loaded sys.path: ['/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/home/roman/.local/lib/python2.7/site-packages', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7'] function add() called, but initialization code failed. Returning 0. result: 0 ``` RTLD_LOCAL works properly.
issue