[PATCH] D55484: ComputeLineNumbers: delete SSE2 vectorization

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 26 10:58:36 PST 2019


MaskRay added a comment.

In D55484#1760432 <https://reviews.llvm.org/D55484#1760432>, @shi-yan wrote:

> I'm hitting a crash by this code,
>
> getting:
>
>   exception thrown: RuntimeError: unreachable,RuntimeError: unreachable
>       at ComputeLineNumbers(clang::DiagnosticsEngine&, clang::SrcMgr::ContentCache*, llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096ul, 4096ul>&, clang::SourceManager const&, bool&) (wasm-function[21781]:719)
>       at clang::SourceManager::getLineNumber(clang::FileID, unsigned int, bool*) const (wasm-function[21780]:187)
>       at clang::SourceManager::getPresumedLoc(clang::SourceLocation, bool) const (wasm-function[21779]:733)
>       at clang::Preprocessor::HandlePragmaSystemHeader(clang::Token&) (wasm-function[21284]:297)
>       at (anonymous namespace)::PragmaSystemHeaderHandler::HandlePragma(clang::Preprocessor&, clang::PragmaIntroducer, clang::Token&) (wasm-function[21317]:5)
>       at clang::PragmaNamespace::HandlePragma(clang::Preprocessor&, clang::PragmaIntroducer, clang::Token&) (wasm-function[21278]:565)
>       at clang::PragmaNamespace::HandlePragma(clang::Preprocessor&, clang::PragmaIntroducer, clang::Token&) (wasm-function[21278]:565)
>       at clang::Preprocessor::HandlePragmaDirective(clang::PragmaIntroducer) (wasm-function[21279]:142)
>       at clang::Preprocessor::HandleDirective(clang::Token&) (wasm-function[21157]:1721)
>       at clang::Lexer::LexTokenInternal(clang::Token&, bool) (wasm-function[20897]:14349)
>  
>
>
> The reason seems to be that the code appears to expect the Buf is zero ended, but it doesn't seem to be the case. The last character of the Buf was actually \n


ComputeLineNumbers assumes that the buffer has a NUL terminator (`RequiresNullTerminator` in lib/Support/MemoryBuffer.cpp). The function has the assumption both before and after the change (I don't think this patch should be blamed...). That said, a detailed reproducible instruction will be useful, though I think the mostly likely problem is that your code does not set `RequiresNullTerminator` when calling one of the MemoryBuffer creation routines.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55484/new/

https://reviews.llvm.org/D55484





More information about the cfe-commits mailing list