Trevor Harmon
2010-Jul-16 22:20 UTC
[LLVMdev] Function::getName in CallGraphSCCPass causes bus error
Hi, I'm trying to use CallGraphSCCPass, but I keep getting a bus error. I can reproduce the problem quite easily using the lib/Transforms/Hello example. I simply mix in these changes: #include "llvm/CallGraphSCCPass.h" ... struct Hello : public CallGraphSCCPass { static char ID; // Pass identification, replacement for typeid Hello() : CallGraphSCCPass(&ID) {} virtual bool runOnSCC(std::vector<CallGraphNode *> &SCC) { CallGraphNode *node = SCC.front(); Function *function = node->getFunction(); StringRef str = function->getName(); return false; } }; And when I run the pass with opt, I get: 0 libLLVM-2.7.dylib 0xe0b33d28 llvm::sys::RWMutexImpl::writer_release() + 424 1 libLLVM-2.7.dylib 0xe0b34607 llvm::sys::RemoveFileOnSignal(llvm::sys::Path const&, std::string*) + 1143 2 libSystem.B.dylib 0x002632bb _sigtramp + 43 3 libSystem.B.dylib 0xffffffff _sigtramp + 18446744073707048303 4 LLVMHello.dylib 0x0002eba8 (anonymous namespace)::Hello::runOnSCC(std::vector<llvm::CallGraphNode*, std::allocator<llvm::CallGraphNode*> >&) + 24 5 libLLVM-2.7.dylib 0xe0cbff44 (anonymous namespace)::CGPassManager::RunPassOnSCC(llvm::Pass*, std::vector<llvm::CallGraphNode*, std::allocator<llvm::CallGraphNode*> >&, llvm::CallGraph&, bool&) + 340 6 libLLVM-2.7.dylib 0xe0cc07b2 (anonymous namespace)::CGPassManager::runOnModule(llvm::Module&) + 770 7 libLLVM-2.7.dylib 0xe055597d llvm::MPPassManager::runOnModule(llvm::Module&) + 477 8 libLLVM-2.7.dylib 0xe0555b54 llvm::PassManagerImpl::run(llvm::Module&) + 148 9 libLLVM-2.7.dylib 0xe0555bfb llvm::PassManager::run(llvm::Module&) + 27 10 opt 0x0000dbbe main + 3566 11 opt 0x000022d6 start + 54 Stack dump: 0. Program arguments: ../../../Release/bin/opt -load ../../../Release/ lib/LLVMHello.dylib -hello 1. Running pass 'CallGraph Pass Manager' on module '<stdin>'. Bus error Removing the function->getName() statement causes the error to go away. This is with the stock LLVM 2.7 release on Mac OS X 10.5.8. Am I doing something wrong, or is this a bug in LLVM? Thanks, Trevor
Duncan Sands
2010-Jul-19 11:55 UTC
[LLVMdev] Function::getName in CallGraphSCCPass causes bus error
Hi Trevor,> struct Hello : public CallGraphSCCPass { > static char ID; // Pass identification, replacement for typeid > Hello() : CallGraphSCCPass(&ID) {} > virtual bool runOnSCC(std::vector<CallGraphNode *> &SCC) { > CallGraphNode *node = SCC.front(); > Function *function = node->getFunction(); > StringRef str = function->getName();maybe function is NULL? This is the case for the "external node". Ciao, Duncan.> return false; > } > }; > > And when I run the pass with opt, I get: > > 0 libLLVM-2.7.dylib 0xe0b33d28 > llvm::sys::RWMutexImpl::writer_release() + 424 > 1 libLLVM-2.7.dylib 0xe0b34607 > llvm::sys::RemoveFileOnSignal(llvm::sys::Path const&, std::string*) + > 1143 > 2 libSystem.B.dylib 0x002632bb _sigtramp + 43 > 3 libSystem.B.dylib 0xffffffff _sigtramp + 18446744073707048303 > 4 LLVMHello.dylib 0x0002eba8 (anonymous > namespace)::Hello::runOnSCC(std::vector<llvm::CallGraphNode*, > std::allocator<llvm::CallGraphNode*> >&) + 24 > 5 libLLVM-2.7.dylib 0xe0cbff44 (anonymous > namespace)::CGPassManager::RunPassOnSCC(llvm::Pass*, > std::vector<llvm::CallGraphNode*, std::allocator<llvm::CallGraphNode*> > >&, llvm::CallGraph&, bool&) + 340 > 6 libLLVM-2.7.dylib 0xe0cc07b2 (anonymous > namespace)::CGPassManager::runOnModule(llvm::Module&) + 770 > 7 libLLVM-2.7.dylib 0xe055597d > llvm::MPPassManager::runOnModule(llvm::Module&) + 477 > 8 libLLVM-2.7.dylib 0xe0555b54 > llvm::PassManagerImpl::run(llvm::Module&) + 148 > 9 libLLVM-2.7.dylib 0xe0555bfb llvm::PassManager::run(llvm::Module&) > + 27 > 10 opt 0x0000dbbe main + 3566 > 11 opt 0x000022d6 start + 54 > Stack dump: > 0. Program arguments: ../../../Release/bin/opt -load ../../../Release/ > lib/LLVMHello.dylib -hello > 1. Running pass 'CallGraph Pass Manager' on module '<stdin>'. > Bus error > > Removing the function->getName() statement causes the error to go away. > > This is with the stock LLVM 2.7 release on Mac OS X 10.5.8. > > Am I doing something wrong, or is this a bug in LLVM? Thanks, > > Trevor > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Trevor Harmon
2010-Jul-19 20:26 UTC
[LLVMdev] Function::getName in CallGraphSCCPass causes bus error
On Jul 19, 2010, at 4:55 AM, Duncan Sands wrote:> Hi Trevor, > >> struct Hello : public CallGraphSCCPass { >> static char ID; // Pass identification, replacement for typeid >> Hello() : CallGraphSCCPass(&ID) {} >> virtual bool runOnSCC(std::vector<CallGraphNode *> &SCC) { >> CallGraphNode *node = SCC.front(); >> Function *function = node->getFunction(); >> StringRef str = function->getName(); > > maybe function is NULL? This is the case for the "external node".Hrmph, could have sworn I checked for that already. Indeed, I was crashing on external nodes. Thanks for your help, Trevor
Apparently Analagous Threads
- [LLVMdev] Function::getName in CallGraphSCCPass causes bus error
- [LLVMdev] CallGraphSCCPass
- [LLVMdev] llvm-g++: Internal error
- [LLVMdev] Can CallGraphSCCPass distinguish different function pointer types in CallGraphNode?
- [LLVMdev] use LLVM to convert C++ code to C code