<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 - AArch64 Memory Tagging with setjmp and longjmp crash"
href="https://bugs.llvm.org/show_bug.cgi?id=49169">49169</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>AArch64 Memory Tagging with setjmp and longjmp crash
</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>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>steplong@quicinc.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Hi, I am seeing an issue with running the following code on AArch64 (compiled
with -fsanitize=memtag):
#include <stdint.h>
#include <stdio.h>
#include <setjmp.h>
jmp_buf env;
volatile uint64_t *copy;
__attribute__((noinline))
void call_longjmp(jmp_buf env) {
uint64_t a;
// Assign a to copy so the compiler won't optimize
// out local variable a
copy = &a;
longjmp(env, 1);
}
__attribute__((noinline))
void foo(void) {
if (setjmp(env) == 0) {
call_longjmp(env);
}
}
__attribute__((noinline))
void foo2(void) {
__asm__(
"stp x29, x30, [sp, #-16]!\n\t"
"stp x15, xzr, [sp, #-16]!\n\t"
"stp x13, x14, [sp, #-16]!\n\t"
"stp x11, x12, [sp, #-16]!\n\t"
"stp x9, x10, [sp, #-16]!\n\t"
"ldp x9, x10, [sp], #16\n\t"
"ldp x11, x12, [sp], #16\n\t"
"ldp x13, x14, [sp], #16\n\t"
"ldp x15, xzr, [sp], #16\n\t"
"ldp x29, x30, [sp], #16\n\t"
);
}
int main(void) {
foo();
foo2();
return 0;
}
Since call_longjmp() never returns, it never gets to untag variable a. When
foo2() tries to push to the stack, it will trigger a tag collision when it
tries to write over a. I'm currently using a custom QEMU to run this
executable. The executable runs OK if I add
__attribute__((no_sanitize("memtag"))) to call_longjmp</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>