)]}'
{
  "commit": "7815df19deaadceaa55aaa578361afaebfd3cb87",
  "tree": "753d28f8cc50da9499736a580238d1cb63220680",
  "parents": [
    "d0da85745dac153705bf1e2c465a8f487068085e"
  ],
  "author": {
    "name": "Marco Elver",
    "email": "elver@google.com",
    "time": "Wed Oct 08 16:16:29 2025 +0200"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Wed Oct 08 16:16:29 2025 +0200"
  },
  "message": "[Clang] Fix brittle print-header-json.c test (#162484)\n\nA recent change adding a new sanitizer kind (via Sanitizers.def) was\nreverted in c74fa20c955b (\"Revert \"[Clang][CodeGen] Introduce the\nAllocToken SanitizerKind\" (#162413)\"). The reason was this ASan report,\nwhen running the test cases in\nclang/test/Preprocessor/print-header-json.c:\n\n```\n\u003d\u003dclang\u003d\u003d483265\u003d\u003dERROR: AddressSanitizer: heap-buffer-overflow on address 0x7d82b97e8b58 at pc 0x562cd432231f bp 0x7fff3fad0850 sp 0x7fff3fad0848\nREAD of size 16 at 0x7d82b97e8b58 thread T0\n    #0 0x562cd432231e in __copy_non_overlapping_range\u003cconst unsigned long *, const unsigned long *\u003e zorg-test/libcxx_install_asan_ubsan/include/c++/v1/string:2144:38\n    #1 0x562cd432231e in void std::__1::basic_string\u003cchar, std::__1::char_traits\u003cchar\u003e, std::__1::allocator\u003cchar\u003e\u003e::__init_with_size[abi:nn220000]\u003cunsigned long const*, unsigned long const*\u003e(unsigned long const*, unsigned long const*, unsigned long) zorg-test/libcxx_install_asan_ubsan/include/c++/v1/string:2685:18\n    #2 0x562cd41e2797 in __init\u003cconst unsigned long *, 0\u003e zorg-test/libcxx_install_asan_ubsan/include/c++/v1/string:2673:3\n    #3 0x562cd41e2797 in basic_string\u003cconst unsigned long *, 0\u003e zorg-test/libcxx_install_asan_ubsan/include/c++/v1/string:1174:5\n    #4 0x562cd41e2797 in clang::ASTReader::ReadString(llvm::SmallVectorImpl\u003cunsigned long\u003e const\u0026, unsigned int\u0026) clang/lib/Serialization/ASTReader.cpp:10171:15\n    #5 0x562cd41fd89a in clang::ASTReader::ParseLanguageOptions(llvm::SmallVector\u003cunsigned long, 64u\u003e const\u0026, llvm::StringRef, bool, clang::ASTReaderListener\u0026, bool) clang/lib/Serialization/ASTReader.cpp:6475:28\n    #6 0x562cd41eea53 in clang::ASTReader::ReadOptionsBlock(llvm::BitstreamCursor\u0026, llvm::StringRef, unsigned int, bool, clang::ASTReaderListener\u0026, std::__1::basic_string\u003cchar, std::__1::char_traits\u003cchar\u003e, std::__1::allocator\u003cchar\u003e\u003e\u0026) clang/lib/Serialization/ASTReader.cpp:3069:11\n    #7 0x562cd4204ab8 in clang::ASTReader::ReadControlBlock(clang::serialization::ModuleFile\u0026, llvm::SmallVectorImpl\u003cclang::ASTReader::ImportedModule\u003e\u0026, clang::serialization::ModuleFile const*, unsigned int) clang/lib/Serialization/ASTReader.cpp:3249:15\n    #8 0x562cd42097d2 in clang::ASTReader::ReadASTCore(llvm::StringRef, clang::serialization::ModuleKind, clang::SourceLocation, clang::serialization::ModuleFile*, llvm::SmallVectorImpl\u003cclang::ASTReader::ImportedModule\u003e\u0026, long, long, clang::ASTFileSignature, unsigned int) clang/lib/Serialization/ASTReader.cpp:5182:15\n    #9 0x562cd421ec77 in clang::ASTReader::ReadAST(llvm::StringRef, clang::serialization::ModuleKind, clang::SourceLocation, unsigned int, clang::serialization::ModuleFile**) clang/lib/Serialization/ASTReader.cpp:4828:11\n    #10 0x562cd3d07b74 in clang::CompilerInstance::findOrCompileModuleAndReadAST(llvm::StringRef, clang::SourceLocation, clang::SourceLocation, bool) clang/lib/Frontend/CompilerInstance.cpp:1805:27\n    #11 0x562cd3d0b2ef in clang::CompilerInstance::loadModule(clang::SourceLocation, llvm::ArrayRef\u003cclang::IdentifierLoc\u003e, clang::Module::NameVisibilityKind, bool) clang/lib/Frontend/CompilerInstance.cpp:1956:31\n    #12 0x562cdb04eb1c in clang::Preprocessor::HandleHeaderIncludeOrImport(clang::SourceLocation, clang::Token\u0026, clang::Token\u0026, clang::SourceLocation, clang::detail::SearchDirIteratorImpl\u003ctrue\u003e, clang::FileEntry const*) clang/lib/Lex/PPDirectives.cpp:2423:49\n    #13 0x562cdb042222 in clang::Preprocessor::HandleIncludeDirective(clang::SourceLocation, clang::Token\u0026, clang::detail::SearchDirIteratorImpl\u003ctrue\u003e, clang::FileEntry const*) clang/lib/Lex/PPDirectives.cpp:2101:17\n    #14 0x562cdb043366 in clang::Preprocessor::HandleDirective(clang::Token\u0026) clang/lib/Lex/PPDirectives.cpp:1338:14\n    #15 0x562cdafa84bc in clang::Lexer::LexTokenInternal(clang::Token\u0026, bool) clang/lib/Lex/Lexer.cpp:4512:7\n    #16 0x562cdaf9f20b in clang::Lexer::Lex(clang::Token\u0026) clang/lib/Lex/Lexer.cpp:3729:24\n    #17 0x562cdb0d4ffa in clang::Preprocessor::Lex(clang::Token\u0026) clang/lib/Lex/Preprocessor.cpp:896:11\n    #18 0x562cd77da950 in clang::ParseAST(clang::Sema\u0026, bool, bool) clang/lib/Parse/ParseAST.cpp:163:7\n    [...]\n\n0x7d82b97e8b58 is located 0 bytes after 3288-byte region [0x7d82b97e7e80,0x7d82b97e8b58)\nallocated by thread T0 here:\n    #0 0x562cca76f604 in malloc zorg-test/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:67:3\n    #1 0x562cd1cce452 in safe_malloc llvm/include/llvm/Support/MemAlloc.h:26:18\n    #2 0x562cd1cce452 in llvm::SmallVectorBase\u003cunsigned int\u003e::grow_pod(void*, unsigned long, unsigned long) llvm/lib/Support/SmallVector.cpp:151:15\n    #3 0x562cdbe1768b in grow_pod llvm/include/llvm/ADT/SmallVector.h:139:11\n    #4 0x562cdbe1768b in grow llvm/include/llvm/ADT/SmallVector.h:525:41\n    #5 0x562cdbe1768b in reserve llvm/include/llvm/ADT/SmallVector.h:665:13\n    #6 0x562cdbe1768b in llvm::BitstreamCursor::readRecord(unsigned int, llvm::SmallVectorImpl\u003cunsigned long\u003e\u0026, llvm::StringRef*) llvm/lib/Bitstream/Reader/BitstreamReader.cpp:230:10\n    #7 0x562cd41ee8ab in clang::ASTReader::ReadOptionsBlock(llvm::BitstreamCursor\u0026, llvm::StringRef, unsigned int, bool, clang::ASTReaderListener\u0026, std::__1::basic_string\u003cchar, std::__1::char_traits\u003cchar\u003e, std::__1::allocator\u003cchar\u003e\u003e\u0026) clang/lib/Serialization/ASTReader.cpp:3060:49\n    #8 0x562cd4204ab8 in clang::ASTReader::ReadControlBlock(clang::serialization::ModuleFile\u0026, llvm::SmallVectorImpl\u003cclang::ASTReader::ImportedModule\u003e\u0026, clang::serialization::ModuleFile const*, unsigned int) clang/lib/Serialization/ASTReader.cpp:3249:15\n    #9 0x562cd42097d2 in clang::ASTReader::ReadASTCore(llvm::StringRef, clang::serialization::ModuleKind, clang::SourceLocation, clang::serialization::ModuleFile*, llvm::SmallVectorImpl\u003cclang::ASTReader::ImportedModule\u003e\u0026, long, long, clang::ASTFileSignature, unsigned int) clang/lib/Serialization/ASTReader.cpp:5182:15\n    #10 0x562cd421ec77 in clang::ASTReader::ReadAST(llvm::StringRef, clang::serialization::ModuleKind, clang::SourceLocation, unsigned int, clang::serialization::ModuleFile**) clang/lib/Serialization/ASTReader.cpp:4828:11\n    #11 0x562cd3d07b74 in clang::CompilerInstance::findOrCompileModuleAndReadAST(llvm::StringRef, clang::SourceLocation, clang::SourceLocation, bool) clang/lib/Frontend/CompilerInstance.cpp:1805:27\n    #12 0x562cd3d0b2ef in clang::CompilerInstance::loadModule(clang::SourceLocation, llvm::ArrayRef\u003cclang::IdentifierLoc\u003e, clang::Module::NameVisibilityKind, bool) clang/lib/Frontend/CompilerInstance.cpp:1956:31\n    #13 0x562cdb04eb1c in clang::Preprocessor::HandleHeaderIncludeOrImport(clang::SourceLocation, clang::Token\u0026, clang::Token\u0026, clang::SourceLocation, clang::detail::SearchDirIteratorImpl\u003ctrue\u003e, clang::FileEntry const*) clang/lib/Lex/PPDirectives.cpp:2423:49\n    #14 0x562cdb042222 in clang::Preprocessor::HandleIncludeDirective(clang::SourceLocation, clang::Token\u0026, clang::detail::SearchDirIteratorImpl\u003ctrue\u003e, clang::FileEntry const*) clang/lib/Lex/PPDirectives.cpp:2101:17\n    #15 0x562cdb043366 in clang::Preprocessor::HandleDirective(clang::Token\u0026) clang/lib/Lex/PPDirectives.cpp:1338:14\n    #16 0x562cdafa84bc in clang::Lexer::LexTokenInternal(clang::Token\u0026, bool) clang/lib/Lex/Lexer.cpp:4512:7\n    #17 0x562cdaf9f20b in clang::Lexer::Lex(clang::Token\u0026) clang/lib/Lex/Lexer.cpp:3729:24\n    #18 0x562cdb0d4ffa in clang::Preprocessor::Lex(clang::Token\u0026) clang/lib/Lex/Preprocessor.cpp:896:11\n    #19 0x562cd77da950 in clang::ParseAST(clang::Sema\u0026, bool, bool) clang/lib/Parse/ParseAST.cpp:163:7\n    [...]\n\nSUMMARY: AddressSanitizer: heap-buffer-overflow clang/lib/Serialization/ASTReader.cpp:10171:15 in clang::ASTReader::ReadString(llvm::SmallVectorImpl\u003cunsigned long\u003e const\u0026, unsigned int\u0026)\n```\n\nThe reason is this particular RUN line:\n```\n// RUN: env CC_PRINT_HEADERS_FORMAT\u003djson CC_PRINT_HEADERS_FILTERING\u003ddirect-per-file CC_PRINT_HEADERS_FILE\u003d%t.txt %clang -fsyntax-only -I %S/Inputs/print-header-json -isystem %S/Inputs/print-header-json/system -fmodules -fimplicit-module-maps -fmodules-cache-path\u003d%t %s -o /dev/null\n```\n\nwhich was added in 8df194f6a933 (\"[Clang] Support includes translated to\nmodule imports in -header-include-filtering\u003ddirect-per-file (#156756)\").\n\nThe problem is caused by an incremental build reusing stale cached\nmodule files (.pcm) that are no longer binary-compatible with the\nupdated compiler. Adding a new sanitizer option altered the implicit\nbinary layout of the serialized LangOptions data structure. The build +\ntest system is oblivious to such changes. When the new compiler\nattempted to read the old module file (from the previous test\ninvocation), it misinterpreted the data due to the layout mismatch,\nresulting in a heap-buffer-overflow. Unfortunately Clang\u0027s PCM format\ndoes not encode nor detect version mismatches here; a more graceful\nfailure mode would be preferable.\n\nFor now, fix the test to be more robust with incremental build + test.",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "057dcc27d82386462fa7aabc9fc9bb0df152dc65",
      "old_mode": 33188,
      "old_path": "clang/test/Preprocessor/print-header-json.c",
      "new_id": "e0533cd8f0e4fd33c11c3b78033e0f74a4171b58",
      "new_mode": 33188,
      "new_path": "clang/test/Preprocessor/print-header-json.c"
    }
  ]
}
