Answer the question
In order to leave comments, you need to log in
Why does C++ library class method in Debug under Mac OS X and Linux return nullptr?
There were problems using a third-party library. When building a third-party library and my application in Debug mode, the function implemented in the .h file returns nullptr. Everything is fine in Release mode. The problem occurs on Mac OS X and Linux. If you transfer the implementation from .h to .cpp, everything starts working. But there are a lot of such functions in the library and it is not possible to transfer everything to .cpp. As far as I understand, the compiler's build parameters are to blame. A third-party library is built into static library .a, I built it myself - I can change compiler options during build, my application into an executable file.
In .h file:
buzz::XmppClient *client()
{
std::cout << "GET XmppPump.client: " << client_ << std::endl;
return client_;
}
XmppPump::XmppPump(XmppPumpNotify * notify)
{
state_ = buzz::XmppEngine::STATE_NONE;
notify_ = notify;
client_ = new buzz::XmppClient(this); // NOTE: deleted by TaskRunner
std::cout << "CREATE XmppPump.client: " << client_ << std::endl;
}
assert( ! m_pump );
m_pump = new buzz::XmppPump( );
auto xmppClient = m_pump->client( );
assert( xmppClient ); // роковой assert для debug
[ 14%] Building CXX object vcall/CMakeFiles/vcall.dir/v_call_facade.cpp.o
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.2.0
Thread model: posix
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.6.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name v_call_facade.cpp -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 236.3 -v -gdwarf-2 -coverage-file /Users/evgeny/repository/vcall/build-debug/vcall/CMakeFiles/vcall.dir/v_call_facade.cpp.o -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -D POSIX -D nullptr=NULL -D DEBUG_MODE -I /Users/evgeny/libraries/boost-1-53-static-x64/include -I /usr/local/include -I /Users/evgeny/repository/webrtc/trunk -I /Users/evgeny/repository/vcall -Wall -fdeprecated-macro -fdebug-compilation-dir /Users/evgeny/repository/vcall/build-debug/vcall -ferror-limit 19 -fmessage-length 315 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.6.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -vectorize-slp -o CMakeFiles/vcall.dir/v_call_facade.cpp.o -x c++ /Users/evgeny/repository/vcall/vcall/v_call_facade.cpp
clang -cc1 version 5.1 based upon LLVM 3.4svn default target x86_64-apple-darwin13.2.0
CXX(target) out/Debug/obj.target/libjingle/talk/xmpp/xmpppump.o
clang version 3.5.0 (trunk 206824)
Target: x86_64-apple-darwin13.2.0
Thread model: posix
"/Users/evgeny/repository/webrtc/trunk/third_party/llvm-build/Release+Asserts/bin/clang" -cc1 -triple x86_64-apple-macosx10.6.0 -emit-obj -mrelax-all -disable-free -main-file-name xmpplogintask.cc -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -relaxed-aliasing -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 224.1 -v -gdwarf-2 -coverage-file /Users/evgeny/repository/webrtc/trunk/out/Debug/obj.target/libjingle/talk/xmpp/xmpplogintask.o -resource-dir /Users/evgeny/repository/webrtc/trunk/third_party/llvm-build/Release+Asserts/bin/../lib/clang/3.5.0 -dependency-file out/Debug/.deps/out/Debug/obj.target/libjingle/talk/xmpp/xmpplogintask.o.d.raw -MT out/Debug/obj.target/libjingle/talk/xmpp/xmpplogintask.o -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -D V8_DEPRECATION_WARNINGS -D BLINK_SCALE_FILTERS_AT_RECORD_TIME -D EXPAT_RELATIVE_PATH -D FEATURE_ENABLE_VOICEMAIL -D GTEST_RELATIVE_PATH -D JSONCPP_RELATIVE_PATH -D LOGGING=1 -D SRTP_RELATIVE_PATH -D FEATURE_ENABLE_SSL -D FEATURE_ENABLE_PSTN -D HAVE_SRTP -D HAVE_WEBRTC_VIDEO -D HAVE_WEBRTC_VOICE -D USE_WEBRTC_DEV_BRANCH -D CHROMIUM_BUILD -D USE_LIBJPEG_TURBO=1 -D ENABLE_ONE_CLICK_SIGNIN -D ENABLE_REMOTING=1 -D ENABLE_WEBRTC=1 -D ENABLE_PEPPER_CDMS -D ENABLE_CONFIGURATION_POLICY -D ENABLE_INPUT_SPEECH -D ENABLE_NOTIFICATIONS -D ENABLE_HIDPI=1 -D DISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY -D SYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE -D ENABLE_EGLIMAGE=1 -D ENABLE_TASK_MANAGER=1 -D ENABLE_EXTENSIONS=1 -D ENABLE_PLUGIN_INSTALLATION=1 -D ENABLE_PLUGINS=1 -D ENABLE_SESSION_SERVICE=1 -D ENABLE_THEMES=1 -D ENABLE_AUTOFILL_DIALOG=1 -D ENABLE_BACKGROUND=1 -D ENABLE_GOOGLE_NOW=1 -D CLD_VERSION=2 -D ENABLE_FULL_PRINTING=1 -D ENABLE_PRINTING=1 -D ENABLE_SPELLCHECK=1 -D ENABLE_CAPTIVE_PORTAL_DETECTION=1 -D ENABLE_APP_LIST=1 -D ENABLE_SETTINGS_APP=1 -D ENABLE_MANAGED_USERS=1 -D ENABLE_SERVICE_DISCOVERY=1 -D LIBPEERCONNECTION_LIB=1 -D OSX -D HAVE_SCTP -D CARBON_DEPRECATED=YES -D HASH_NAMESPACE=__gnu_cxx -D POSIX -D DISABLE_DYNAMIC_CAST -D _REENTRANT -D SSL_USE_NSS -D HAVE_NSS_SSL_H -D SSL_USE_NSS_RNG " /NSS_PLATFORM_CLIENT_AUTHwebrtc/trunk/third_party/llvm-build/Release+Asserts/bin/clang" -D-NO_N PR_10_SUPPORT --Diple xNSPR_STATIC-macosx10.6.0 --Dit-obj -NSS_STATIC --Dsable-free -NSS_USE_STATIC_ IBS x-Dppump.cc -USE_UTIL_DIRECTLY p-D -XML_STATIC 2- -DYNAMIC_ANNOTATIO S_ENABLED=1 --Dlaxed-aliasing -WTF_USE_DYNAM C_ANNOTATIONS=1 --Dnwind-tables -_DEBUG-cpu c-Ie2 -.arget-linker-version 2-I.1 -. --Iwarf-2 -third_partyle /-Iers/evgeny/repository/webrtc/trunk/out/Debug/obj.target/libjingle/talk/xmpp/xmpppump.o -third_party/w brtc /-Iers/evgeny/repository/webrtc/trunk/third_party/llvm-build/Release+Asserts/bin/../lib/clang/3.5.0 -webrtcency-file o-I/Debug/.deps/out/Debug/obj.target/libjingle/talk/xmpp/xmpppump.o.d.raw -net third_party/nss/ssl o-I/Debug/obj.target/libjingle/talk/xmpp/xmpppump.o -third_par y/nss/nspr/pr/include /-Iplications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -th rd_party/nss/nspr/lib/ds V-IDEPRECATION_WARNINGS -th rd_party/nss/nspr/lib/libc/include B-INK_SCALE_FILTERS_AT_RECORD_TIME -th rd_party/nss/nss/lib/base E-IAT_RELATIVE_PATH -th rd_party/nss/nss/lib/certdb F-ITURE_ENABLE_VOICEMAIL -th rd_party/nss/nss/lib/certhigh G-IST_RELATIVE_PATH -th rd_party/nss/nss/lib/cryptohi J-INCPP_RELATIVE_PATH -th rd_party/nss/nss/lib/dev L-IGING=1 -th rd_party/nss/nss/lib/freebl S-IP_RELATIVE_PATH -th rd_party/nss/nss/lib/freebl/ecl F-ITURE_ENABLE_SSL -th rd_party/nss/nss/lib/nss F-ITURE_ENABLE_PSTN -th rd_party/nss/nss/lib/pk11wrap H-IE_SRTP -th rd_party/nss/nss/lib/pkcs7 H-IE_WEBRTC_VIDEO -th rd_party/nss/nss/lib/pki H-IE_WEBRTC_VOICE -th rd_party/nss/nss/lib/smimeU-I_WEBRTC_DEV_BRANCH -th rd_party/nss/nss/lib/softokenC-IOMIUM_BUILD -th rd_party/nss/nss/lib/util U-I_LIBJPEG_TURBO=1 -th rd_party/expat/files/lib E-IBLE_ONE_CLICK_SIGNIN -th rd_party/jsoncpp/overrides/include E-IBLE_REMOTING=1 -th rd_party/jsoncpp/source/include E-O0LE_WEBRTC=1 --W rror E-Wnewline-eofCDMS --W ndif-labels E-Wno-unused-parameterOLICY --W o-missing-field-initializers E-Wheader-hygieneCH --W o-c++11-narrowing E-Wno-char-subscripts --W o-unneeded-internal-declaration E-Wno-covered-s itch-default --W tring-conversion D-Wno-deprecated-register_SUPPORTED_NATIVELY --W o-absolute-value S-Wno-selector-type-mismatchRY_PRESSURE --s d=gnu++11 E-fdeprecated-macr --f ebug-compilation-dir E/Users/evgeny/reposit ry/webrtc/trunk --f rror-limit ENABLE_EXTENSIONS=1 -D ENABLE_PLUGIN_IN TALLATION=1 0- -ENABLE_PLUGI S=1 h-Dden -ENABLE_SESSION_S RVICE=1 3- -ENABLE_THEMES= --Dlocks -ENABLE_AUTOFILL_DIALOG= --Dbjc-runtime=macosx-10.6.0 -ENABLE_BACKGROUND=1ock-signature --Dxx-exceptions -ENABLE_GOOGL _NOW=1 --Diagnostics-show-option -CLD_VERSION=2 --D oENABLE_FULL_PRINTING=1bjingle/talk/xmpp/xmpplogintask.o --D cENA LE_PRINTING=1 t-Dk/xmpp/xmpplogintask.cc ENABLE_SPELLCHECK=1 -D ENABLE_CAPTIVE_PORTAL_DETECTION=1 -D ENABLE_APP_LIST=1 -D ENABLE_SETTINGS_APP=1 -D ENABLE_MANAGED_USERS=1 -D ENABLE_SERVICE_DISCOVERY=1 -D LIBPEERCONNECTION_LIB=1 -D OSX -D HAVE_SCTP -D CARBON_DEPRECATED=YES -D HASH_NAMESPACE=__gnu_cxx -D POSIX -D DISABLE_DYNAMIC_CAST -D _REENTRANT -D SSL_USE_NSS -D HAVE_NSS_SSL_H -D SSL_USE_NSS_RNG -D NSS_PLATFORM_CLIENT_AUTH -D NO_NSPR_10_SUPPORT -D NSPR_STATIC -D NSS_STATIC -D NSS_USE_STATIC_LIBS -D USE_UTIL_DIRECTLY -D XML_STATIC -D DYNAMIC_ANNOTATIONS_ENABLED=1 -D WTF_USE_DYNAMIC_ANNOTATIONS=1 -D _DEBUG -I . -O0 -Werror -Wnewline-eof -Wendif-labels -Wno-unused-parameter -Wno-missing-field-initializers -Wheader-hygiene -Wno-c++11-narrowing -Wno-char-subscripts -Wno-unneeded-internal-declaration -Wno-covered-switch-default -Wstring-conversion -Wno-deprecated-register -Wno-absolute-value -Wno-selector-type-mismatch -std=gnu++11 -fdeprecated-macro -fdebug-compilation-dir /Users/evgeny/repository/webrtc/trunk -ferror-limit 19 -fmessage-length 0 -fvisibility hidden -stack-protector 3 -mstackrealign -fblocks -fno-threadsafe-statics -fobjc-runtime=macosx-10.6.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fdiagnostics-show-option -vectorize-slp -o out/Debug/obj.target/libjingle/talk/xmpp/xmpppump.o -x c++ talk/xmpp/xmpppump.cc
clang -cc1 version 3.5.0 based upon LLVM 3.5.0svn default target x86_64-apple-darwin13.2.0
based upon LLVM 3.5.0svn default target x86_64-apple-darwin13.2.0
Answer the question
In order to leave comments, you need to log in
There is an opinion that the problem is in the optimization level, more precisely, in the fact that there is optimization with the Release build, but not with the Debug build. For example, try to force Release -O0, look at the result.
Well, in general - the debugger will help you.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question