Clang crash with -fsanitize=hwaddress -flto=thin -ffat-lto-objects
The crash is caused when using -ffat-lto-objects together with -fsanitize=hwaddress.
$ cat test.c
int main(int argc, char* argv[])
{ (void)argv; return argc-1;}
$ clang -c test.c -fsanitize=hwaddress -flto=thin
// no crash
$ clang -c test.c -fsanitize=hwaddress -flto=thin -ffat-lto-objects
clang: /usr/local/google/work/llvm-monorepo/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:897: void clang::BackendConsumer::DiagnosticHandlerImpl(const DiagnosticInfo &): Assertion `CurLinkModule && "CurLinkM
odule must be set for linker diagnostics"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: ../release/bin/clang -c test.c -fsanitize=hwaddress -flto=thin -ffat-lto-objects
1. <eof> parser at end of file
2. Optimizer 3. Running pass "hwasan<>" on module "test.c"
(cc: @ZijunZhaoCCK )
@llvm/issue-subscribers-clang-codegen
Author: None (pirama-arumuga-nainar)
$ clang -c test.c -fsanitize=hwaddress -flto=thin -ffat-lto-objects
clang: /usr/local/google/work/llvm-monorepo/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:897: void clang::BackendConsumer::DiagnosticHandlerImpl(const DiagnosticInfo &): Assertion `CurLinkModule && "CurLinkM
odule must be set for linker diagnostics"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: ../release/bin/clang -c test.c -fsanitize=hwaddress -flto=thin -ffat-lto-objects
-
<eof> parser at end of file -
Optimizer 3. Running pass "hwasan<>" on module "test.c"
</details>
(cc: @fmayer )
On my end, this error can be reproduced by cherrypicking this change https://github.com/llvm/llvm-project/pull/99439/files
cc: @skc7 @vitalybuka
Raised PR #106356 which should fix the issue.