<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 can crash (or freeze) after static_assert() has failed"
href="https://bugs.llvm.org/show_bug.cgi?id=48246">48246</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Clang can crash (or freeze) after static_assert() has failed
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</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>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>ripper37@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=24190" name="attach_24190" title="Contains autogenerated reproduction-7c6556.sh and reproduction-7c6556.cpp files">attachment 24190</a> <a href="attachment.cgi?id=24190&action=edit" title="Contains autogenerated reproduction-7c6556.sh and reproduction-7c6556.cpp files">[details]</a></span>
Contains autogenerated reproduction-7c6556.sh and reproduction-7c6556.cpp files
During my work on side-project, I've reproduced clang crashes which were
preceded by freeze of my PC machine (up to the point where I couldn't even move
my cursor). I've managed to find a minimal reproduction scenario by compiling
this code:
#include <cstddef>
#include <type_traits>
#include <utility>
int main() {
constexpr size_t x = 1;
constexpr size_t y = 2;
static_assert(x >= y, "|x| must not be smaller than |y|");
using type = std::void_t<std::make_index_sequence<x-y>>;
return 0;
}
with a command like this:
clang++ -std=c++17 reproduction.cpp
which gives me this error:
reproduction.cpp:9:3: error: static_assert failed due to requirement 'x >= y'
"|x| must not be smaller than |y|"
static_assert(x >= y, "|x| must not be smaller than |y|");
^ ~~~~~~
clang: error: unable to execute command: Killed
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 10.0.0-4ubuntu1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang: note: diagnostic msg: PLEASE submit a bug report to
<a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> and include the crash backtrace, preprocessed source,
and associated run script.
clang: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/reproduction-7c6556.cpp
clang: note: diagnostic msg: /tmp/reproduction-7c6556.sh
clang: note: diagnostic msg:
********************
----------------------------------------------------
I've tested this on multiple clang versions and they all fail, on the other
hand GCC and ICC just report error and don't crash/freeze machine.
For the context in which I've found it - I was writing my own std::bind()-like
implementation which deduced number of function arguments and number of bounded
arguments and computed how many (and which ones) are left. In this case, the
bug reproduced if I provided more arguments for binding than the function took,
even though there were 2 static_asserts for this along the way.
As for the severity, I think that due to how it can freeze the machine and the
fact that some IDEs (e.g. QtCretor) use clang as a backend for understanding
code ("Clang Code Model") which constantly respawns after a crash leading to
complete machine freeze (nothing but to reboot, just by opening a file with
such code), the severity should be high.
Best regards,
Damian Dyńdo.</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>