for a research topic, I am using a C++ program to translate a SQL query into a C++ program. After translation, the c++ query source-code is compiled into a shared library:
g++ -O0 -g3 -fPIC -std=c++0x GeneratedQuery.cpp ../type/Types.cpp -shared -o lib.so
Everything works fine and the library is compiled correctly. In a second program, I try to implement a read-eval-print-loop which takes a query from the user, translates and compiles it, loads the shared library with dlopen and dlsym, and finally executes it. Before I used Intel TBB in the query-code everything worked fine, but now I get a segmentation fault for the second query I enter (fist query works perfectly, but second query that is loaded in the loop fails).
Source (read-eval-print-loop): http://pastebin.com/pWkRN7Dx
Sample Query-Code: http://pastebin.com/A1pBZC3d
If I do not have a join in my query and thus a single parallel_for occurs in the query source-code, there is no problem. But if there are multiple parallel_fors, I get a segmentation fault for the second query I enter (compilation is successful and dlopen works, but dlsym fails).
Here is the gdb output
0x00007ffff7de394b in ?? () from /lib64/ld-linux-x86-64.so.2
0x00007ffff7de429e in ?? () from /lib64/ld-linux-x86-64.so.2
0x00007ffff7de4523 in ?? () from /lib64/ld-linux-x86-64.so.2
0x00007ffff6cc612a in ?? () from /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff7bd7044 in ?? () from /lib/x86_64-linux-gnu/libdl.so.2
0x00007ffff7de9176 in ?? () from /lib64/ld-linux-x86-64.so.2
0x00007ffff7bd752f in ?? () from /lib/x86_64-linux-gnu/libdl.so.2
0x00007ffff7bd709a in dlsym () from /lib/x86_64-linux-gnu/libdl.so.2
0x000000000041fd58 in main (argc=1, argv=0x7fffffffe1d8) at ../src/tpcc.cpp:141
I really don't understand what fails for the second query. I tried different flags for dlopen, but it didn't work for any combination.
Hope someone can help me, as I am very unexperienced in shared libraries.
Regards
Try to replace
to
See explanation in the great http://www.isotton.com/devel/docs/C++-dlopen-mini-HOWTO/C++-dlopen-mini-HOWTO.html paper.