abumq / easyloggingpp

C++ logging library. It is extremely powerful, extendable, light-weight, fast performing, thread and type safe and consists of many built-in features. It provides ability to write logs in your own customized format. It also provide support for logging your classes, third-party libraries, STL and third-party containers etc.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue with preloading library that uses easylogging++

easylogging opened this issue · comments

To reproduce this issue do

$ LD_PRELOAD=mylib/libmylib.so ./myapp

from samples/Qt/shared-lib/myapp-build

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...

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)