Skip to content

[llvm-lit] FileCheck crashing when checking an empty file #101582

@connieyzhu

Description

@connieyzhu

When piping an empty file into FileCheck and using the CHECK-EMPTY directive, FileCheck crashes.

The crash occurred when running the following lines:

# RUN: touch %t
# RUN: cat %t | FileCheck %s --allow-empty

# CHECK-EMPTY:

The crash gives this error message:

# | check:24'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            62: # | FileCheck: /usr/local/google/home/connieyzhu/llvm-fork/llvm/lib/FileCheck/FileCheck.cpp:1848: bool llvm::FileCheck::readCheckFile(SourceMgr &, StringRef, std::pair<unsigned int, unsigned int> *): Assertion `AfterSuffix.data() >= Buffer.data() && AfterSuffix.data() < Buffer.data() + Buffer.size() && "Parsing after suffix doesn't start inside of buffer!"' failed. 
# | check:24'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            63: # | PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace. 
# | check:24'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            64: # | Stack dump: 
# | check:24'0     ~~~~~~~~~~~~~~~~
# |            65: # | 0. Program arguments: FileCheck /usr/local/google/home/connieyzhu/llvm-fork/build/utils/lit/tests/Inputs/shtest-cat/cat-empty.txt --allow-empty 
# | check:24'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            66: # | #0 0x000055abcd1c5078 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /usr/local/google/home/connieyzhu/llvm-fork/llvm/lib/Support/Unix/Signals.inc:723:13 
# | check:24'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            67: # `----------------------------- 
# | check:24'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            68: # error: command failed with exit status: -6 

Metadata

Metadata

Assignees

No one assigned

    Labels

    crashPrefer [crash-on-valid] or [crash-on-invalid]llvm-lit

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions