Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ASan to debug builds #316

Closed
blipper opened this issue Apr 16, 2021 · 1 comment
Closed

Add ASan to debug builds #316

blipper opened this issue Apr 16, 2021 · 1 comment
Assignees

Comments

@blipper
Copy link
Contributor

blipper commented Apr 16, 2021

Is your feature request related to a problem? Please describe.
There appear to be a bunch of memory corruption bugs with Phasar.

Describe the solution you'd like
https://github.com/google/sanitizers/wiki/AddressSanitizer

Describe alternatives you've considered
Msan?

Additional context
Example of attempting to run alias on an intrinsic

0x00007fb451b1924000:01:36.605221 - [DEBUG] Analyzing alias function: llvm.lifetime.start.p0i8

==2662243==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60700252cff8 at pc 0x7fb5c185bf32 bp 0x7ffd4682fb80 sp 0x7ffd4682fb78
READ of size 1 at 0x60700252cff8 thread T0
#0 0x7fb5c185bf31 in getValueID third_party/llvm/llvm-project/llvm/include/llvm/IR/Value.h:532:12
#1 0x7fb5c185bf31 in getOpcode third_party/llvm/llvm-project/llvm/include/llvm/IR/Instruction.h:160:39
#2 0x7fb5c185bf31 in isTerminator third_party/llvm/llvm-project/llvm/include/llvm/IR/Instruction.h:163:51
#3 0x7fb5c185bf31 in llvm::BasicBlock::getTerminator() const third_party/llvm/llvm-project/llvm/lib/IR/BasicBlock.cpp:149:44
#4 0x7fb5c1a449d2 in getTerminator third_party/llvm/llvm-project/llvm/include/llvm/IR/BasicBlock.h:125:48
#5 0x7fb5c1a449d2 in succ_begin third_party/llvm/llvm-project/llvm/include/llvm/IR/CFG.h:268:28
#6 0x7fb5c1a449d2 in child_begin third_party/llvm/llvm-project/llvm/include/llvm/IR/CFG.h:304:60
#7 0x7fb5c1a449d2 in children<llvm::BasicBlock > third_party/llvm/llvm-project/llvm/include/llvm/ADT/GraphTraits.h:122:21
#8 0x7fb5c1a449d2 in llvm::SmallVector<llvm::BasicBlock
, 8u> llvm::DomTreeBuilder::SemiNCAInfo<llvm::DominatorTreeBase<llvm::BasicBlock, false> >::getChildren(llvm::BasicBlock*) third_party/llvm/llvm-project/llvm/include/llvm/Support/GenericDomTreeConstruction.h:118:14
#9 0x7fb5c1a41349 in getChildren third_party/llvm/llvm-project/llvm/include/llvm/Support/GenericDomTreeConstruction.h:111:12
#10 0x7fb5c1a41349 in unsigned int llvm::DomTreeBuilder::SemiNCAInfo<llvm::DominatorTreeBase<llvm::BasicBlock, false> >::runDFS<false, bool ()(llvm::BasicBlock, llvm::BasicBlock*)>(llvm::BasicBlock*, unsigned int, bool ()(llvm::BasicBlock, llvm::BasicBlock*), unsigned int, llvm::DenseMap<llvm::BasicBlock*, unsigned int, llvm::DenseMapInfollvm::BasicBlock*, llvm::detail::DenseMapPair<llvm::BasicBlock*, unsigned int> > const*) third_party/llvm/llvm-project/llvm/include/llvm/Support/GenericDomTreeConstruction.h:197:25
#11 0x7fb5c1a3de00 in void llvm::DomTreeBuilder::SemiNCAInfo<llvm::DominatorTreeBase<llvm::BasicBlock, false> >::doFullDFSWalk<bool ()(llvm::BasicBlock, llvm::BasicBlock*)>(llvm::DominatorTreeBase<llvm::BasicBlock, false> const&, bool ()(llvm::BasicBlock, llvm::BasicBlock*)) third_party/llvm/llvm-project/llvm/include/llvm/Support/GenericDomTreeConstruction.h:551:7
#12 0x7fb5c1a1fec6 in llvm::DomTreeBuilder::SemiNCAInfo<llvm::DominatorTreeBase<llvm::BasicBlock, false> >::CalculateFromScratch(llvm::DominatorTreeBase<llvm::BasicBlock, false>&, llvm::DomTreeBuilder::SemiNCAInfo<llvm::DominatorTreeBase<llvm::BasicBlock, false> >::BatchUpdateInfo*) third_party/llvm/llvm-project/llvm/include/llvm/Support/GenericDomTreeConstruction.h:579:10
#13 0x7fb5c1a0bf48 in Calculate<llvm::DominatorTreeBase<llvm::BasicBlock, false> > third_party/llvm/llvm-project/llvm/include/llvm/Support/GenericDomTreeConstruction.h:1563:3
#14 0x7fb5c1a0bf48 in recalculate third_party/llvm/llvm-project/llvm/include/llvm/Support/GenericDomTree.h:780:5
#15 0x7fb5c1a0bf48 in llvm::DominatorTreeAnalysis::run(llvm::Function&, llvm::AnalysisManagerllvm::Function&) third_party/llvm/llvm-project/llvm/lib/IR/Dominators.cpp:363:6
#16 0x7fb5d18e90c8 in llvm::detail::AnalysisPassModel<llvm::Function, llvm::DominatorTreeAnalysis, llvm::PreservedAnalyses, llvm::AnalysisManagerllvm::Function::Invalidator>::run(llvm::Function&, llvm::AnalysisManagerllvm::Function&) third_party/llvm/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:315:14
#17 0x7fb5c1c4b1d1 in llvm::AnalysisManagerllvm::Function::getResultImpl(llvm::AnalysisKey*, llvm::Function&) third_party/llvm/llvm-project/llvm/include/llvm/IR/PassManagerImpl.h:75:35
#18 0x7fb5c4bacc04 in getResultllvm::DominatorTreeAnalysis third_party/llvm/llvm-project/llvm/include/llvm/IR/PassManager.h:789:9
#19 0x7fb5c4bacc04 in llvm::BasicAA::run(llvm::Function&, llvm::AnalysisManagerllvm::Function&) third_party/llvm/llvm-project/llvm/lib/Analysis/BasicAliasAnalysis.cpp:1758:18
#20 0x7fb5d18f5983 in llvm::detail::AnalysisPassModel<llvm::Function, llvm::BasicAA, llvm::PreservedAnalyses, llvm::AnalysisManagerllvm::Function::Invalidator>::run(llvm::Function&, llvm::AnalysisManagerllvm::Function&) third_party/llvm/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:315:14
#21 0x7fb5c1c4b1d1 in llvm::AnalysisManagerllvm::Function::getResultImpl(llvm::AnalysisKey*, llvm::Function&) third_party/llvm/llvm-project/llvm/include/llvm/IR/PassManagerImpl.h:75:35
#22 0x7fb5d2df8dc6 in getResultllvm::BasicAA third_party/llvm/llvm-project/llvm/include/llvm/IR/PassManager.h:789:9
#23 0x7fb5d2df8dc6 in void llvm::AAManager::getFunctionAAResultImplllvm::BasicAA(llvm::Function&, llvm::AnalysisManagerllvm::Function&, llvm::AAResults&) third_party/llvm/llvm-project/llvm/include/llvm/Analysis/AliasAnalysis.h:1248:39
#24 0x7fb5c4b47147 in llvm::AAManager::run(llvm::Function&, llvm::AnalysisManagerllvm::Function&) third_party/llvm/llvm-project/llvm/lib/Analysis/AliasAnalysis.cpp:927:5
#25 0x7fb5d2dff115 in llvm::detail::AnalysisPassModel<llvm::Function, llvm::AAManager, llvm::PreservedAnalyses, llvm::AnalysisManagerllvm::Function::Invalidator>::run(llvm::Function&, llvm::AnalysisManagerllvm::Function&) third_party/llvm/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:315:14
#26 0x7fb5c1c4b1d1 in llvm::AnalysisManagerllvm::Function::getResultImpl(llvm::AnalysisKey*, llvm::Function&) third_party/llvm/llvm-project/llvm/include/llvm/IR/PassManagerImpl.h:75:35
#27 0x7fb5d2def0ef in getResultllvm::AAManager third_party/llvm/llvm-project/llvm/include/llvm/IR/PassManager.h:789:9
#28 0x7fb5d2def0ef in psr::LLVMBasedPointsToAnalysis::computePointsToInfo(llvm::Function&) third_party/phasar/lib/PhasarLLVM/Pointer/LLVMBasedPointsToAnalysis.cpp:92:30
#29 0x7fb5d2e2e5d9 in getAAResults third_party/phasar/include/phasar/PhasarLLVM/Pointer/LLVMBasedPointsToAnalysis.h:55:7
#30 0x7fb5d2e2e5d9 in psr::LLVMPointsToSet::LLVMPointsToSet(psr::ProjectIRDB&, bool, psr::PointerAnalysisType) third_party/phasar/lib/PhasarLLVM/Pointer/LLVMPointsToSet.cpp:49:20
#31 0x7fb5d36c09e5 in psr::AnalysisController::AnalysisController(psr::ProjectIRDB&, std::__u::vector<std::__u::variant<psr::DataFlowAnalysisType, std::__u::unique_ptr<psr::IDETabulationProblemPlugin, std::__u::default_deletepsr::IDETabulationProblemPlugin > ()(psr::ProjectIRDB const, psr::LLVMTypeHierarchy const*, psr::LLVMBasedICFG const*, psr::LLVMPointsToInfo*, std::__u::set<std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator >, std::__u::less<std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator > >, std::__u::allocator<std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator > > >), std::__u::unique_ptr<psr::IFDSTabulationProblemPlugin, std::__u::default_deletepsr::IFDSTabulationProblemPlugin > ()(psr::ProjectIRDB const, psr::LLVMTypeHierarchy const*, psr::LLVMBasedICFG const*, psr::LLVMPointsToInfo*, std::__u::set<std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator >, std::__u::less<std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator > >, std::__u::allocator<std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator > > >), std::__u::unique_ptr<psr::IntraMonoProblemPlugin, std::__u::default_deletepsr::IntraMonoProblemPlugin > ()(psr::ProjectIRDB const, psr::LLVMTypeHierarchy const*, psr::LLVMBasedCFG const*, psr::LLVMPointsToInfo*, std::__u::set<std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator >, std::__u::less<std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator > >, std::__u::allocator<std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator > > >), std::__u::unique_ptr<psr::InterMonoProblemPlugin, std::__u::default_deletepsr::InterMonoProblemPlugin > ()(psr::ProjectIRDB const, psr::LLVMTypeHierarchy const*, psr::LLVMBasedICFG const*, psr::LLVMPointsToInfo*, std::__u::set<std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator >, std::__u::less<std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator > >, std::__u::allocator<std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator > > >)>, std::__u::allocator<std::__u::variant<psr::DataFlowAnalysisType, std::__u::unique_ptr<psr::IDETabulationProblemPlugin, std::__u::default_deletepsr::IDETabulationProblemPlugin > ()(psr::ProjectIRDB const, psr::LLVMTypeHierarchy const*, psr::LLVMBasedICFG const*, psr::LLVMPointsToInfo*, std::__u::set<std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator >, std::__u::less<std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator > >, std::__u::allocator<std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator > > >), std::__u::unique_ptr<psr::IFDSTabulationProblemPlugin, std::__u::default_deletepsr::IFDSTabulationProblemPlugin > ()(psr::ProjectIRDB const, psr::LLVMTypeHierarchy const*, psr::LLVMBasedICFG const*, psr::LLVMPointsToInfo*, std::__u::set<std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator >, std::__u::less<std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator > >, std::__u::allocator<std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator > > >), std::__u::unique_ptr<psr::IntraMonoProblemPlugin, std::__u::default_deletepsr::IntraMonoProblemPlugin > ()(psr::ProjectIRDB const, psr::LLVMTypeHierarchy const*, psr::LLVMBasedCFG const*, psr::LLVMPointsToInfo*, std::__u::set<std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator >, std::__u::less<std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator > >, std::__u::allocator<std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator > > >), std::__u::unique_ptr<psr::InterMonoProblemPlugin, std::__u::default_deletepsr::InterMonoProblemPlugin > ()(psr::ProjectIRDB const, psr::LLVMTypeHierarchy const*, psr::LLVMBasedICFG const*, psr::LLVMPointsToInfo*, std::__u::set<std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator >, std::__u::less<std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator > >, std::__u::allocator<std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator > > >)> > >, std::__u::vector<std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator >, std::__u::allocator<std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator > > >, psr::PointerAnalysisType, psr::CallGraphAnalysisType, psr::Soundness, std::__u::set<std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator >, std::__u::less<std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator > >, std::__u::allocator<std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator > > > const&, psr::AnalysisStrategy, psr::AnalysisControllerEmitterOptions, std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator > const&, std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator > const&) third_party/phasar/lib/Controller/AnalysisController.cpp:87:7
#32 0x7fb5d440bbae in main third_party/phasar/tools/phasar-llvm/phasar-llvm.cpp:431:22
#33 0x7fb451ba9bbc in __libc_start_main (/usr/grte/v4/lib64/libc.so.6+0x38bbc)
#34 0x55c5da567aa8 in _start /usr/grte/v4/debug-src/src/csu/../sysdeps/x86_64/start.S:108

0x60700252cff8 is located 8 bytes to the left of 80-byte region [0x60700252d000,0x60700252d050)
allocated by thread T0 here:
#0 0x55c5da61b9dd in operator new(unsigned long) third_party/llvm/llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp:99:3
#1 0x7fb5c1ab0c1f in __libcpp_operator_new third_party/crosstool/v18/stable/toolchain/bin/../include/c++/v1/new:235:10
#2 0x7fb5c1ab0c1f in __libcpp_allocate third_party/crosstool/v18/stable/toolchain/bin/../include/c++/v1/new:261:10
#3 0x7fb5c1ab0c1f in allocate third_party/crosstool/v18/stable/toolchain/bin/../include/c++/v1/memory:784:38
#4 0x7fb5c1ab0c1f in llvm::Function::BuildLazyArguments() const third_party/llvm/llvm-project/llvm/lib/IR/Function.cpp:396:44
#5 0x7fb5c1cd61ed in CheckLazyArguments third_party/llvm/llvm-project/llvm/include/llvm/IR/Function.h:113:7
#6 0x7fb5c1cd61ed in arg_begin third_party/llvm/llvm-project/llvm/include/llvm/IR/Function.h:784:5
#7 0x7fb5c1cd61ed in args third_party/llvm/llvm-project/llvm/include/llvm/IR/Function.h:807:23
#8 0x7fb5c1cd61ed in visitFunction third_party/llvm/llvm-project/llvm/lib/IR/Verifier.cpp:2436:32
#9 0x7fb5c1cd61ed in llvm::InstVisitor<(anonymous namespace)::Verifier, void>::visit(llvm::Function&) third_party/llvm/llvm-project/llvm/include/llvm/IR/InstVisitor.h:100:35
#10 0x7fb5c1cbf449 in (anonymous namespace)::Verifier::verify(llvm::Function const&) third_party/llvm/llvm-project/llvm/lib/IR/Verifier.cpp:363:5
#11 0x7fb5c1cc27f4 in llvm::verifyModule(llvm::Module const&, llvm::raw_ostream*, bool*) third_party/llvm/llvm-project/llvm/lib/IR/Verifier.cpp:5698:18
#12 0x7fb5c183c036 in llvm::UpgradeDebugInfo(llvm::Module&) third_party/llvm/llvm-project/llvm/lib/IR/AutoUpgrade.cpp:4022:9
#13 0x7fb5c34e3f20 in (anonymous namespace)::BitcodeReader::materializeModule() third_party/llvm/llvm-project/llvm/lib/Bitcode/Reader/BitcodeReader.cpp:5651:3
#14 0x7fb5c1c0951b in llvm::Module::materializeAll() third_party/llvm/llvm-project/llvm/lib/IR/Module.cpp:449:13
#15 0x7fb5c34cabb7 in llvm::BitcodeModule::getModuleImpl(llvm::LLVMContext&, bool, bool, bool, llvm::function_ref<llvm::Optional<std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator > > (llvm::StringRef)>) third_party/llvm/llvm-project/llvm/lib/Bitcode/Reader/BitcodeReader.cpp:6810:24
#16 0x7fb5c34d9c80 in parseModule third_party/llvm/llvm-project/llvm/lib/Bitcode/Reader/BitcodeReader.cpp:6992:10
#17 0x7fb5c34d9c80 in llvm::parseBitcodeFile(llvm::MemoryBufferRef, llvm::LLVMContext&, llvm::function_ref<llvm::Optional<std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator > > (llvm::StringRef)>) third_party/llvm/llvm-project/llvm/lib/Bitcode/Reader/BitcodeReader.cpp:7004:14
#18 0x7fb5cb6fdd7d in llvm::parseIR(llvm::MemoryBufferRef, llvm::SMDiagnostic&, llvm::LLVMContext&, llvm::function_ref<llvm::Optional<std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator > > (llvm::StringRef)>) third_party/llvm/llvm-project/llvm/lib/IRReader/IRReader.cpp:77:9
#19 0x7fb5cb6fec83 in llvm::parseIRFile(llvm::StringRef, llvm::SMDiagnostic&, llvm::LLVMContext&, llvm::function_ref<llvm::Optional<std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator > > (llvm::StringRef)>) third_party/llvm/llvm-project/llvm/lib/IRReader/IRReader.cpp:102:10
#20 0x7fb5d2b4488f in psr::ProjectIRDB::ProjectIRDB(std::__u::vector<std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator >, std::__u::allocator<std::__u::basic_string<char, std::__u::char_traits, std::__u::allocator > > > const&, psr::IRDBOptions) third_party/phasar/lib/DB/ProjectIRDB.cpp:69:41
#21 0x7fb5d4408203 in main third_party/phasar/tools/phasar-llvm/phasar-llvm.cpp:306:15
#22 0x7fb451ba9bbc in __libc_start_main (/usr/grte/v4/lib64/libc.so.6+0x38bbc)
#23 0x55c5da567aa8 in _start /usr/grte/v4/debug-src/src/csu/../sysdeps/x86_64/start.S:108

@pdschubert
Copy link
Member

PhASAR now enables users to build in debug + sanitizers mode using -DCMAKE_BUILD_TYPE=DebugSan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants