Issue 87759
Summary clang-format 17 segmentation fault
Labels clang-format
Assignees
Reporter randombit
    I encountered a segmentation fault from `clang-format 17.0.6`. This is the version included in Arch Linux.

```
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: clang-format -i src/lib/asn1/asn1_obj.h
 #0 0x000076e9c1975933 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/libLLVM-17.so+0x775933)
 #1 0x000076e9c1972bcf llvm::sys::RunSignalHandlers() (/usr/lib/libLLVM-17.so+0x772bcf)
 #2 0x000076e9c1972d1d (/usr/lib/libLLVM-17.so+0x772d1d)
 #3 0x000076e9c0c5a770 (/usr/lib/libc.so.6+0x3c770)
 #4 0x000076e9cb8ebde1 (/usr/lib/libclang-cpp.so.17+0x24ebde1)
 #5 0x000076e9cb82d7f0 (/usr/lib/libclang-cpp.so.17+0x242d7f0)
 #6 0x000076e9cb82d9c4 (/usr/lib/libclang-cpp.so.17+0x242d9c4)
 #7 0x000076e9cb849afa clang::format::internal::reformat(clang::format::FormatStyle const&, llvm::StringRef, llvm::ArrayRef<clang::tooling::Range>, unsigned int, unsigned int, unsigned int, llvm::StringRef, clang::format::FormattingAttemptStatus*) (/usr/lib/libclang-cpp.so.17+0x2449afa)
 #8 0x000076e9cb84cf70 clang::format::reformat(clang::format::FormatStyle const&, llvm::StringRef, llvm::ArrayRef<clang::tooling::Range>, llvm::StringRef, clang::format::FormattingAttemptStatus*) (/usr/lib/libclang-cpp.so.17+0x244cf70)
 #9 0x0000569d63ffb088 (/usr/bin/clang-format+0xe088)
#10 0x0000569d63ff4079 (/usr/bin/clang-format+0x7079)
#11 0x000076e9c0c43cd0 (/usr/lib/libc.so.6+0x25cd0)
#12 0x000076e9c0c43d8a __libc_start_main (/usr/lib/libc.so.6+0x25d8a)
#13 0x0000569d63ff4535 (/usr/bin/clang-format+0x753)
```

To reproduce:

1) Checkout `76f78e108ac710822862203d879d825dbd805b1c` from https://github.com/randombit/botan

2) Apply the following patch:

```
diff --git a/.clang-format b/.clang-format
index 5c887c301..712fd0e7f 100644
--- a/.clang-format
+++ b/.clang-format
@@ -33,6 +33,9 @@ IncludeCategories:

 AttributeMacros: ['BOTAN_FUNC_ISA', 'BOTAN_FUNC_ISA_INLINE', 'BOTAN_FORCE_INLINE']

+Macros:
+ - BOTAN_PUBLIC_API(x,y)=
+
 BinPackArguments: false
 BreakStringLiterals: false
 AllowAllArgumentsOnNextLine: true
```

3) Run `clang-format -i src/lib/asn1/asn1_obj.h`

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to