You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TL;DR: if you have a strange segfault on getenv calls, try to run plumed after export PLUMED_LOAD_DLCLOSE=no (thanks, @GiovanniBussi )
I was working on the interface to plumed for external codes and I found this curious behaviour:
When you check that plumed is available to use and plumed it is not found the next time you call getenv to look for a non-existent environment variable you get a segmentation fault 😨
Luckily this happens only with a determinate software configuration (this is fun) and can be solved by simply exporting export PLUMED_LOAD_DLCLOSE=no before running the plumed-patched program
The minimal code to reproduce the issue is this spoiler
#define__PLUMED_WRAPPER_FORTRAN0
#define__PLUMED_WRAPPER_LINK_RUNTIME1
#define__PLUMED_WRAPPER_EXTERN0
#define__PLUMED_WRAPPER_CXX1
#define__PLUMED_WRAPPER_LIBCXX111
#define__PLUMED_WRAPPER_LIBCXX171
#define__PLUMED_WRAPPER_IMPLEMENTATION1
#define__PLUMED_HAS_DLOPEN
#include"Plumed.h"
#include<cstdlib>
#include<iostream>voidmygetenv(std::string var) {
auto val = getenv(var.c_str());
if (val)
std::cout << var << ": "<< val << "\n";
else
std::cout << var << " not FOUND!!\n";
}
intmain() {
mygetenv("PLUMED_KERNEL");
mygetenv("PLUMED_KERNEL_");
std::cout << "Plumed is " << (PLMD::Plumed::installed()?"":"not ") << "installed\n";
mygetenv("PLUMED_KERNEL");
mygetenv("PLUMED_KERNEL_");
return0;
}
all: test
test: test.o
g++ -o test test.o -ldl
test.o: test.cpp Plumed.h
g++ -c test.cpp
Plumed.h:
wget https://raw.githubusercontent.com/plumed/plumed2/refs/tags/v2.10b/src/wrapper/Plumed.h
clean:
rm -fv *.o test
The text was updated successfully, but these errors were encountered:
Hi all,
TL;DR: if you have a strange segfault on
getenv
calls, try to run plumed afterexport PLUMED_LOAD_DLCLOSE=no
(thanks, @GiovanniBussi )I was working on the interface to plumed for external codes and I found this curious behaviour:
When you check that plumed is available to use and plumed it is not found the next time you call
getenv
to look for a non-existent environment variable you get a segmentation fault 😨Luckily this happens only with a determinate software configuration (this is fun) and can be solved by simply exporting
export PLUMED_LOAD_DLCLOSE=no
before running the plumed-patched programThe minimal code to reproduce the issue is this spoiler
The text was updated successfully, but these errors were encountered: