llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.02k stars 11.96k forks source link

clang segfault in `ComputeLineNumbers` #39180

Closed llvmbot closed 3 months ago

llvmbot commented 5 years ago
Bugzilla Link 39833
Version trunk
OS Linux
Attachments backtrace & other logging from when the segfault happened, run script (Unified_cpp_layout_base1-d4583a.sh)
Reporter LLVM Bugzilla Contributor

Extended Description

Just hit a clang segfault, with locally-built recent-SVN-trunk clang revision 346691. Backtrace attached - if I'm understanding it correctly, it looks like the segfault was in ComputeLineNumbers.

llvmbot commented 5 years ago

We are getting a similar backtrace. Using a modified version of clang, we traced the problem to mmap not filling the memory past the end of file with zeroes. Our files are on a proprietary networked file system, so there is probably a bug in the implementation of mmap in that file system.

llvmbot commented 5 years ago

backtrace2-clang8.txt

llvmbot commented 5 years ago

backtrace1-clang8.txt

llvmbot commented 5 years ago

Hello. I am experiencing a similar bug with Clang 8.0.0.

I am adding two backtraces as attachments to this bug. The two backtraces have different function call stacks, which also differ from the function call stack in the backtrace attached to this bug on 2018-11-28.

llvmbot commented 5 years ago

I'm seeing a SEGFAULT that looks to match this backtrace. It is intermittent, around 1% of compiles, but completely repeatable because I am running at a large scale with around two thousand compiler invocations per "test".

My use case is complicated because clang is invoked by the Portable Compute Language (pocl) library for OpenCL.

I'm using: clang+llvm-7.0.0-x86_64-linux-sles12.3 and the November 12th master branch of POCL.

I could try again with an instrumented or debug build of clang+llvm if that would help illuminate the root issue. Please let me know what would be helpful.

Also reported to the POCL mailing list, but the backtrace and this related Bug lead me to think the root issue is in clang.

SEGFAULT Backtrace

 WmResidentPatchProcessor::WmResidentPatchProcessor(WmComputeProgram*, boost::shared_ptr<WmComputeAssignment const>, std::vector<boost::shared_ptr<WmSubDomain const>, std::allocator<boost::shared_ptr<WmSubDomain const> > > const&, WmComputeMachine&)@wmresidentpatchprocessor.cc:358
 POclBuildProgram@clBuildProgram.c:37
 compile_and_link_program@pocl_build.c:624
 pocl_llvm_build_program@pocl_llvm_build.cc:489
 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)@0x2aaaabebfd07
 clang::FrontendAction::Execute()@0x2aaaabf1c106
 clang::PrintPreprocessedAction::ExecuteAction()@0x2aaaabf22328
 clang::DoPrintPreprocessedInput(clang::Preprocessor&, llvm::raw_ostream*, clang::PreprocessorOutputOptions const&)@0x2aaaabf51226
 clang::Preprocessor::EnterMainSourceFile()@0x2aaaacc1cabc
 clang::Preprocessor::EnterSourceFile(clang::FileID, clang::DirectoryLookup const*, clang::SourceLocation)@0x2aaaacbf7407
 (anonymous namespace)::PrintPPOutputPPCallbacks::FileChanged(clang::SourceLocation, clang::PPCallbacks::FileChangeReason, clang::SrcMgr::CharacteristicKind, clang::FileID)@0x2aaaabf5212d
 clang::SourceManager::getPresumedLoc(clang::SourceLocation, bool) const@0x2aaaacc4e00e
 clang::SourceManager::getLineNumber(clang::FileID, unsigned int, bool*) const@0x2aaaacc4e43a
 ComputeLineNumbers(clang::DiagnosticsEngine&, clang::SrcMgr::ContentCache*, llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096ul, 4096ul>&, clang::SourceManager const&, bool&)@0x2aaaacc4e683
llvmbot commented 5 years ago

Note: this may not be a reliable crasher... at least, I ran the "run script" a few times (in my /tmp directory), and it seems to run without printing any crash/error output.

cor3ntin commented 3 months ago

Closing this as there is no reproducer attached and it's been a while. Feel free to reopen

llvmbot commented 3 months ago

@llvm/issue-subscribers-clang-frontend

Author: None (llvmbot)

| | | | --- | --- | | Bugzilla Link | [39833](https://llvm.org/bz39833) | | Version | trunk | | OS | Linux | | Attachments | [backtrace & other logging from when the segfault happened](https://user-images.githubusercontent.com/60944935/143758395-3a0d843a-0266-4085-ab86-c4d0cba50a40.gz), [run script (Unified_cpp_layout_base1-d4583a.sh)](https://user-images.githubusercontent.com/60944935/143758396-c86c8edc-94b9-411a-a300-9699a84dd809.gz) | | Reporter | LLVM Bugzilla Contributor | ## Extended Description Just hit a clang segfault, with locally-built recent-SVN-trunk clang revision 346691. Backtrace attached - if I'm understanding it correctly, it looks like the segfault was in ComputeLineNumbers.