Issue with preloading library that uses easylogging++
easylogging opened this issue · 2 comments
easylogging commented
To reproduce this issue do
$ LD_PRELOAD=mylib/libmylib.so ./myapp
from samples/Qt/shared-lib/myapp-build
easylogging commented
Problem seem to be in getEnvironmentVariable() function, if we comment it out for test purposes, it works fine
static std::string getEnvironmentVariable(const char* variableName, const char* defaultVal, const char* alternativeBashCommand = nullptr) {
/*#if _ELPP_OS_UNIX
const char* val = getenv(variableName);
#elif _ELPP_OS_WINDOWS
const char* val = getWindowsEnvironmentVariable(variableName);
#endif // _ELPP_OS_UNIX
if ((val == nullptr) || ((strcmp(val, "") == 0))) {
#if _ELPP_OS_UNIX
/// Try harder on unix-based systems
std::string valBash = base::utils::OS::getBashOutput(alternativeBashCommand);
if (valBash.empty()) {
return std::string(defaultVal);
} else {
return valBash;
}
#elif _ELPP_OS_WINDOWS
_ELPP_UNUSED(alternativeBashCommand);
return std::string(defaultVal);
#endif // _ELPP_OS_WINDOWS
}
return std::string(val);*/
return std::string();
}
Looking further...
easylogging commented
Looked even further so issue is in getBashOut() since it tries to open process so i believe it runs into stack overflow (keep trying to open process)