<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 - LLVM 13 Regression: __builtin_longjmp not working with -Oz"
href="https://bugs.llvm.org/show_bug.cgi?id=51729">51729</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>LLVM 13 Regression: __builtin_longjmp not working with -Oz
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</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>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>xtkoba@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=25224" name="attach_25224" title="Repro">attachment 25224</a> <a href="attachment.cgi?id=25224&action=edit" title="Repro">[details]</a></span>
Repro
Tested with 13.0.0-rc2 and 12.0.1. The repro could be made shorter.
Note that this issue is not necessarily specific to X86_64. A segfault is also
observed for ARM.
$ cat bsjlj.c
void foo(void **jb, int n);
void bar(int n);
void
bsj(void **jb, volatile int n)
{
if (__builtin_setjmp(jb) == 0) {
foo(jb, n);
} else {
bar(n);
}
}
void
blj(void **jb)
{
__builtin_longjmp(jb, 1);
}
int printf (const char *__restrict __format, ...);
void
foo(void **jb, int n)
{
printf("foo: n = %d\n", n);
blj(jb);
}
void
bar(int n)
{
printf("bar: n = %d\n", n);
}
int
main(int argc, char *argv[] __attribute__((unused)))
{
void *jb[5];
bsj(jb, argc);
bsj(jb, argc+1);
return 0;
}
$ /usr/lib/llvm/12/bin/clang --target=x86_64-linux-gnu bsjlj.c -Oz -Wall
-Wextra -Wundef
$ ./a.out
foo: n = 1
bar: n = 1
foo: n = 2
bar: n = 2
$ /usr/lib/llvm/13/bin/clang --target=x86_64-linux-gnu bsjlj.c -Oz -Wall
-Wextra -Wundef
$ ./a.out
foo: n = 1
bar: n = 32764
Segmentation fault</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>