plumed / plumed2

Development version of plumed 2
https://www.plumed.org
GNU Lesser General Public License v3.0
345 stars 278 forks source link

gromacs-5 linked statically with plumed 2.1 doesn't work due to some molfiles conflict #110

Closed carlocamilloni closed 9 years ago

carlocamilloni commented 9 years ago

I have just found that by linking statically gmx5 with plumed2.1 the code crashes immediately (while in runtime linking works fine) by doing some debugging I have found that it works if one compiles plumed without the internal molfile plugin.

GiovanniBussi commented 9 years ago

@carlocamilloni In branch fix-110 I tried to introduce a separate namespace for molfile to avoid clashes. Can you check if branch fix-110 solves the issue and, in case, merge it to v2.1? Thanks! Giovanni

carlocamilloni commented 9 years ago

@giovannibussi, unfortunately it doesn’t fix the problem,

this is the GDB output (that is not changed upon the fix)

3 0x0000000100063580 in PLMD::cltools::register_cb (v=<value temporarily unavailable, due to optimizations>, p=0x100301178) at map:1873

4 0x0000000100147e90 in molfile_dcdplugin_register (v=0x102a05250, cb=<value temporarily unavailable, due to optimizations>) at dcdplugin.cpp:1209

5 0x000000010006aa62 in PLMD::cltools::Driver::registerKeywords (keys=@0x7fff5fbfe030) at Driver.cpp:163

6 0x0000000101ec5978 in PLMD::CLToolRegister::add (this=0x10222c648, key={std::1::basic_string_common = {}, r_ = {<std::1::libcpp_compressed_pair_imp<std::1::basic_string<char, std::1::char_traits, std::1::allocator >::rep, std::1::allocator, 2>> = {std::1::allocator = {}, _first = {{l = {cap_ = 32199706594665484, _size = 140733193388034, data = 0x101e54bc0 "UH??H?w\b]??\032"}, s = {{size = 12 '\f', lx = 12 '\f'}, data_ = "driver\000\002\000\000\000?\000\000?K?\001\001\000\000"}, r = {words = {32199706594665484, 140733193388034, 4326771648}}}}}, }, static npos = }, f=<value temporarily unavailable, due to optimizations>, kf=<value temporarily unavailable, due to optimizations>) at CLToolRegister.cpp:59

7 0x0000000101e5b4c4 in PLMD::cltools::DriverDoubleRegisterMe::DriverDoubleRegisterMe (this=0x102a05250) at DriverDouble.cpp:33

Carlo

On 29 Sep 2014, at 19:25, Giovanni notifications@github.com wrote:

@carlocamilloni In branch fix-110 I tried to introduce a separate namespace for molfile to avoid clashes. Can you check if branch fix-110 solves the issue and, in case, merge it to v2.1? Thanks! Giovanni

— Reply to this email directly or view it on GitHub.

GiovanniBussi commented 9 years ago

@carlocamilloni Is PLUMED configured with the internal plugins (--enable-external-molfile-plugins) or with the external ones?

carlocamilloni commented 9 years ago

@giovannibussi

I am using the internal ones.

./configure --disable-mpi --enable-debug

configure:4980: WARNING: using internal molfile_plugins, which only support dcd and xtc/trr/trj

On 30 Sep 2014, at 11:22, Giovanni notifications@github.com wrote:

@carlocamilloni Is PLUMED configured with the internal plugins (--enable-external-molfile-plugins) or with the external ones?

— Reply to this email directly or view it on GitHub.

GiovanniBussi commented 9 years ago

@carlocamilloni I double checked and I found a few other global identifiers. I hope I fixed it now, but before merging it is better if @tonigi double checks also. Thanks!

Giovanni

carlocamilloni commented 9 years ago

@giovannibussi

nope

3 0x0000000100063580 in PLMD::cltools::register_cb (v=<value temporarily unavailable, due to optimizations>, p=0x100301178) at map:1873

4 0x0000000100147e90 in plumed_molfile_dcdplugin_register (v=0x102a05250, cb=<value temporarily unavailable, due to optimizations>) at dcdplugin.cpp:1209

5 0x000000010006aa62 in PLMD::cltools::Driver::registerKeywords (keys=@0x7fff5fbfe030) at Driver.cpp:163

6 0x0000000101ec5978 in PLMD::CLToolRegister::add (this=0x10222c648, key={std::1::basic_string_common = {}, r_ = {<std::1::libcpp_compressed_pair_imp<std::1::basic_string<char, std::1::char_traits, std::1::allocator >::rep, std::1::allocator, 2>> = {std::1::allocator = {}, _first = {{l = {cap_ = 32199706594665484, _size = 140733193388034, data = 0x101e54bc0 "UH??H?w\b]??\032"}, s = {{size = 12 '\f', lx = 12 '\f'}, data_ = "driver\000\002\000\000\000?\000\000?K?\001\001\000\000"}, r = {words = {32199706594665484, 140733193388034, 4326771648}}}}}, }, static npos = }, f=<value temporarily unavailable, due to optimizations>, kf=<value temporarily unavailable, due to optimizations>) at CLToolRegister.cpp:59

7 0x0000000101e5b4c4 in PLMD::cltools::DriverDoubleRegisterMe::DriverDoubleRegisterMe (this=0x102a05250) at DriverDouble.cpp:33

On 30 Sep 2014, at 11:35, Giovanni notifications@github.com wrote:

@carlocamilloni I double checked and I found a few other global identifiers. I hope I fixed it now, but before merging it is better if @tonigi double checks also. Thanks!

Giovanni

— Reply to this email directly or view it on GitHub.

tonigi commented 9 years ago

Hi @carlocamilloni @GiovanniBussi , here's another attempt in branch fix-110-tg. I removed the "extern C" so the internal functions should completely live in the plumed namespace (thus no more a need to rename the functions).

carlocamilloni commented 9 years ago

@giovannibussi @tonigi

still doesn't work

I don’t know if it has something to do with the problem, but clang gives this warning upon compiling driver.cpp, while the warning is not there when it compiles DriverDouble or DriverFloat

Driver.cpp:117:12: warning: function 'register_cb' is not needed and will not be emitted [-Wunneeded-internal-declaration] static int register_cb(void v, vmdplugin_t p)

3 0x00000001000635a0 in PLMD::cltools::register_cb (v=<value temporarily unavailable, due to optimizations>, p=0x1003011b0) at map:1873

4 0x0000000100147e10 in PLMD::molfile::molfile_dcdplugin_register (v=0x102a05250, cb=<value temporarily unavailable, due to optimizations>) at dcdplugin.cpp:1209

5 0x000000010006aa32 in PLMD::cltools::Driver::registerKeywords (keys=@0x7fff5fbfe030) at Driver.cpp:163

6 0x0000000101ec58f8 in PLMD::CLToolRegister::add (this=0x10222c690, key={std::1::basic_string_common = {}, r_ = {<std::1::libcpp_compressed_pair_imp<std::1::basic_string<char, std::1::char_traits, std::1::allocator >::rep, std::1::allocator, 2>> = {std::1::allocator = {}, _first = {{l = {cap_ = 32199706594665484, _size = 140733193388034, data = 0x101e54920 "UH??H?w\b]?n?\032"}, s = {{size = 12 '\f', lx = 12 '\f'}, data_ = "driver\000\002\000\000\000?\000\000 I?\001\001\000\000"}, r = {words = {32199706594665484, 140733193388034, 4326770976}}}}}, }, static npos = }, f=<value temporarily unavailable, due to optimizations>, kf=<value temporarily unavailable, due to optimizations>) at CLToolRegister.cpp:59

7 0x0000000101e5b494 in PLMD::cltools::DriverDoubleRegisterMe::DriverDoubleRegisterMe (this=0x102a05250) at DriverDouble.cpp:33

On 30 Sep 2014, at 12:14, Toni G notifications@github.com wrote:

Hi @carlocamilloni @GiovanniBussi , here's another attempt in branch fix-110-tg. I removed the "extern C" so the internal functions should completely live in the plumed namespace (thus no more a need to rename the functions).

— Reply to this email directly or view it on GitHub.

tonigi commented 9 years ago

@giovannibussi @carlocamilloni Odd - there does not seem to be other symbols outside of the namespace defined in molfile plugins any more (checking with nm -C *.o).

The warning might be a confusing way to indicate that the code for register_cb is being inlined - it must be somewhere because it is referenced in Driver.cpp , unless there is some ifdef mixup. I'll check later if I can get something similar with clang under linux (have no OSX unfortunately).

tonigi commented 9 years ago

@giovannibussi @carlocamilloni I could build and run a gmx5 statically with plumed and clang... nm -C build/bin/gmx only shows molfile stuff once, in their namespace. Can you try to recompile after setting VMD_PLUGIN_PATH to some meaningless value? Also, I needed to delete the build directory every time, otherwise it was picking the wrong compiler and giving "duplicate symbol" error.

tonigi commented 9 years ago

@carlocamilloni not sure if you want to try yet once again... I removed the "extern" qualifiers

carlocamilloni commented 9 years ago

@giovannibussi @tonigi

Probably it is a bug specific of OSX with clang. I have recompiled everything from scratch with no success, as soon as I run gmx -h I get the usual Segmentation fault: 11 Giovanni have you had any chance to reproduce it? I will try to compile everything with gcc later

GiovanniBussi commented 9 years ago

@carlocamilloni @tonigi not yet I never compiled gromacs 5 :-)

carlocamilloni commented 9 years ago

@giovannibussi @tonigi

I compiled everything with gcc-4.8 and it works fine with and without the new patches, so it is probably a bug of clang for osx.

tonigi commented 9 years ago

@carlocamilloni @GiovanniBussi I'd suggest to merge the changes anyway, because it's logical that plumed's specific molfiles stay segregated in plumed's namespace (may avoid future problems).

GiovanniBussi commented 9 years ago

I merged the branch fix-110. In principle this is not closing the issue, but since it appears to be a compiler bug I mark this issue as closed.