<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - clang-format --dry-run segfault on a binary file"
href="https://bugs.llvm.org/show_bug.cgi?id=45441">45441</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang-format --dry-run segfault on a binary file
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>10.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Formatter
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>sylvestre@debian.org
</td>
</tr>
<tr>
<th>CC</th>
<td>djasper@google.com, klimek@google.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=23313" name="attach_23313" title="binary file as example">attachment 23313</a> <a href="attachment.cgi?id=23313&action=edit" title="binary file as example">[details]</a></span>
binary file as example
Not a big deal as it should not be done but clang-format should not crash.
With the binary file as attachment, running clang-format crashes with:
$ clang-format-10 --dry-run a.i
Stack dump:
0. Program arguments: clang-format-10 --dry-run a.i
#0 0x00007f60d81956df llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/lib/x86_64-linux-gnu/libLLVM-10.so.1+0xa626df)
#1 0x00007f60d8193990 llvm::sys::RunSignalHandlers()
(/usr/lib/x86_64-linux-gnu/libLLVM-10.so.1+0xa60990)
#2 0x00007f60d8195ca5 (/usr/lib/x86_64-linux-gnu/libLLVM-10.so.1+0xa62ca5)
#3 0x00007f60deaa6110 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x14110)
#4 0x00007f60d8135af5 llvm::SourceMgr::GetMessage(llvm::SMLoc,
llvm::SourceMgr::DiagKind, llvm::Twine const&, llvm::ArrayRef<llvm::SMRange>,
llvm::ArrayRef<llvm::SMFixIt>) const
(/usr/lib/x86_64-linux-gnu/libLLVM-10.so.1+0xa02af5)
#5 0x00000000004095fd (/usr/lib/llvm-10/bin/clang-format+0x4095fd)
#6 0x0000000000406ff4 (/usr/lib/llvm-10/bin/clang-format+0x406ff4)
#7 0x00007f60d7268e0b __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x26e0b)
#8 0x00000000004069ba (/usr/lib/llvm-10/bin/clang-format+0x4069ba)
removing --dry-run doesn't crash</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>