我正在運行OS X 10.8.5;我已經通過homebrew(鏗鏘聲3.4版(tags/RELEASE_34/final))安裝了llvm 3.4,並且我正在使用-fsanitize = address構建。我可以得到阿三用簡單的演示程序工作,但對我們的代碼庫建立的時候,我有幾個問題(雖然我真的就像一個答案#1):如何使AddressSanitizer在發生一個錯誤(和其他問題)後不停止
第三方庫生成峨山錯誤,asan正在終止我的應用程序的第一次出現。我認爲會有某種(運行時/編譯時)選項告訴asan在發現錯誤後繼續前進。具體而言,我看到:
bash-3.2$ ASAN_SYMBOLIZER_PATH=/usr/local/Cellar/llvm34/3.4/lib/llvm-3.4/bin/llvm-symbolizer ./unit_test Start testing of PathTrieTest Config: Using QTest library 4.8.2, Qt 4.8.2 PASS : PathTrieTest::initTestCase() PASS : PathTrieTest::pathTrieNodeTest() ================================================================= ==76647==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x61600019e588 at pc 0x10891ddd3 bp 0x11312ba90 sp 0x11312ba58 WRITE of size 48830 at 0x61600019e588 thread T3 #0 0x10891ddd2 in wrap_readdir_r (/usr/local/lib/llvm-3.4/lib/clang/3.4/lib/darwin/libclang_rt.asan_osx_dynamic.dylib+0x11dd2) #1 0x10ac23571 in QFileSystemIterator::advance(QFileSystemEntry&, QFileSystemMetaData&) (/Volumes/ToolChain/qt-4.8/lib/QtCore.framework/Versions/4/QtCore+0xef571) #2 0x10abd86d3 in QDirIteratorPrivate::advance() (/Volumes/ToolChain/qt-4.8/lib/QtCore.framework/Versions/4/QtCore+0xa46d3) #3 0x10abd7a7f in QDirIteratorPrivate::QDirIteratorPrivate(QFileSystemEntry const&, QStringList const&, QFlags<QDir::Filter>, QFlags<QDirIterator::IteratorFlag>, bool) (/Volumes/ToolChain/qt-4.8/lib/QtCore.framework/Versions/4/QtCore+0xa3a7f) #4 0x10abd8b68 in QDirIterator::QDirIterator(QDir const&, QFlags<QDirIterator::IteratorFlag>) (/Volumes/ToolChain/qt-4.8/lib/QtCore.framework/Versions/4/QtCore+0xa4b68) #5 0x10abd7609 in QDirPrivate::initFileLists(QDir const&) const (/Volumes/ToolChain/qt-4.8/lib/QtCore.framework/Versions/4/QtCore+0xa3609) #6 0x10abd5394 in QDir::count() const (/Volumes/ToolChain/qt-4.8/lib/QtCore.framework/Versions/4/QtCore+0xa1394) #7 0x1084c205d in get_count(QFileInfo&) /Users/stebro/dev_vm/ui/ui/fsinfoprovider.cpp:36 ...
此錯誤不會導致應用程序在運行unsanitized時終止。
當使用-fsanitize = undefined(或-fsanitize = address,undefined)選項時,我無法獲取代碼鏈接。我包括雙方的-fsanitize =未定義線我編譯&鏈接命令,但我得到鏈接錯誤,如:
Undefined symbols for architecture x86_64: "typeinfo for __cxxabiv1::__class_type_info", referenced from: __ubsan::checkDynamicType(void*, void*, unsigned long) in libclang_rt.ubsan_osx.a(ubsan_type_hash.o) isDerivedFromAtOffset(__cxxabiv1::__class_type_info const*, __cxxabiv1::__class_type_info const*, long) in libclang_rt.ubsan_osx.a(ubsan_type_hash.o) findBaseAtOffset(__cxxabiv1::__class_type_info const*, long) in libclang_rt.ubsan_osx.a(ubsan_type_hash.o) "typeinfo for __cxxabiv1::__si_class_type_info", referenced from: isDerivedFromAtOffset(__cxxabiv1::__class_type_info const*, __cxxabiv1::__class_type_info const*, long) in libclang_rt.ubsan_osx.a(ubsan_type_hash.o) findBaseAtOffset(__cxxabiv1::__class_type_info const*, long) in libclang_rt.ubsan_osx.a(ubsan_type_hash.o) "typeinfo for __cxxabiv1::__vmi_class_type_info", referenced from: isDerivedFromAtOffset(__cxxabiv1::__class_type_info const*, __cxxabiv1::__class_type_info const*, long) in libclang_rt.ubsan_osx.a(ubsan_type_hash.o) findBaseAtOffset(__cxxabiv1::__class_type_info const*, long) in libclang_rt.ubsan_osx.a(ubsan_type_hash.o)
我不能讓黑名單工作,並-mllvm -asan-全局= 0或-mllvm -asan-stack = 0似乎不像我所期望的那樣工作。例如,後者不抑制上述#1列出的錯誤的產生,並創造一個黑名單看起來像一個下面不抑制任一錯誤:
fun:QDirPrivate::initFileLists fun:get_count fun:*opendir2*
最後,生成的可執行文件這些asan選項會導致lldb崩潰。我正在使用XCode 5工具附帶的lldb;沒有使用homebew llvm軟件包部署lldb,我無法弄清楚如何構建它。構建指令enter link description here有一個死鏈接,指向您應該使用的源代碼;直接從svn倉庫中拉取源代碼,使用:
svn co http://llvm.org/svn/llvm-project/lldb/tags/RELEASE_34/final lldb
導致代碼無法編譯(根據請求提供的錯誤)。
我找到了解決Qt堆溢出問題的方法。我把它作爲下面的答案發布。 – rryan