From baffdf3e65d99c96abce44965abb69c694c9db92 Mon Sep 17 00:00:00 2001 From: Thomas Tsou Date: Thu, 28 Apr 2011 18:04:44 +0100 Subject: [PATCH] uhd: fix seg fault at startup On the E100, and possibly other systems, OpenBTS seg faults at startup. The cause is a null reference to the global logging file descriptor occuring due to an initializer order dependency, which is not guaranteed across compilation units. When this occurs, check for for null and set the output to stdout. Signed-off-by: Thomas Tsou --- public-trunk/CommonLibs/Logger.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/public-trunk/CommonLibs/Logger.cpp b/public-trunk/CommonLibs/Logger.cpp index ef1b48c..3abb4f9 100644 --- a/public-trunk/CommonLibs/Logger.cpp +++ b/public-trunk/CommonLibs/Logger.cpp @@ -170,6 +170,10 @@ Log::~Log() // So just log. gLogLock.lock(); mStream << std::endl; + + if (gLoggingFile == NULL) + gLoggingFile = stdout; + fprintf(gLoggingFile, "%s", mStream.str().c_str()); fflush(gLoggingFile); gLogLock.unlock();