vle-forge / vle

Virtual Laboratory Environment
http://www.vle-project.org
GNU General Public License v3.0
21 stars 22 forks source link

vle : undefined reference to pthread #374

Closed rtrepos closed 5 years ago

rtrepos commented 5 years ago

Some of the vle packages can be compiled on genotoul. Error is due to undefined reference to pthread.

Eg. vle.discrete-time_test :

/home/rtrepos/save/install/vledev/lib64/libvle-2.1.a(Coordinator.cpp.o): dans la fonction « std::thread::thread<void (vle::devs::SimulatorProcessParallel::)(), vle::devs::SimulatorProcessParallel>(void (vle::devs::SimulatorProcessParallel::&&)(), vle::devs::SimulatorProcessParallel&&) »: /tools/compilers/gcc/5.3.0/include/c++/5.3.0/thread:137: référence indéfinie vers « pthread_create »

quesnel commented 5 years ago

Why vle.discrete-time link with the archive libvle-2.1?

An archive can not include any dependency. If you Link with static archive, you need to link to all dependencies of libvle (expat + pthread‎).

rtrepos commented 5 years ago

Indeed the vle.discrete-time archive is linked to vle libraries, and it looks like it is working if we remove the link. So maybe we have to remove the link for all the vle extensions. But for this specific bug, this is the compilation of the test executable from vle.discrete-time_test that does not work. And actually it is working on my computer (ubuntu 16.04) and not on genotool (CentOS).

rtrepos commented 5 years ago

By forcing the linking to both dl and pthreads (I modified the script VleBuildTest in VleUtilsConfig.cmake), linking works.

Are dl and pthreads missing in the vle-2.1.pc file ?

Yet, tests do not work since the ModuleManager cannot find the vle.output libraries : see bug #373

rtrepos commented 5 years ago

New updates on this bug (still on genologin cluster) :

With these 2 temporary fixes, there is segmentaion fault on the vle.examples test_manager when we set more that 1 thread.

quesnel commented 5 years ago

Can you give a gdb trace of this segfault?

rtrepos commented 5 years ago

0x0000000000460aec in isMatrix (this=0x7ffff000b770) at /home/rtrepos/save/vledev/vle/include/vle/value/Value.hpp:206 206 return getType() == Value::MATRIX; Missing separate debuginfos, use: debuginfo-install expat-2.1.0-8.el7.x86_64 glibc-2.17-157.el7.x86_64 (gdb) bt

0 0x0000000000460aec in isMatrix (this=0x7ffff000b770) at /home/rtrepos/save/vledev/vle/include/vle/value/Value.hpp:206

1 vle::value::Value::toMatrix (this=0x7ffff000b770) at /home/rtrepos/save/vledev/vle/src/vle/value/Value.cpp:274

2 0x0000000000453047 in vle::value::Map::getMatrix (this=this@entry=0x7ffff00039b0, name=...) at /home/rtrepos/save/vledev/vle/src/vle/value/Map.cpp:239

3 0x000000000041dc1a in manager_thread_result_access () at /save/rtrepos/vle-packages/packages/vle.examples/test/testmanager.cpp:233

4 0x0000000000416528 in main () at /save/rtrepos/vle-packages/packages/vle.examples/test/testmanager.cpp:353

rtrepos commented 5 years ago

On genologin, using module cmake-3.5, a static library is built despite the default BUILD_SHARED_LIBS=ON (and CMakeCache value ON) And if you reverse these two lines in src/vle/CMakelists.txt :

add_library(libvle ${libvle_sources}) option(BUILD_SHARED_LIBS "Build shared library" ON)

It will build a shared lib.

@quesnel can you confirm this please ?