| Issue |
237874
|
| Summary |
[MachineOutliner] Crash outlining calls which return twice
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
shoniecaplan
|
Was comparing the safety checks my outliner uses against the machine outliner and noticed it doesn't avoid calls to functions which can return twice. Was able to create a case which crashes on trunk AArch64. I am vaguely aware of the `NoReturn` attribute as well, though I have yet to come up with a way to crash by outlining a `_longjmp` call.
https://godbolt.org/z/Kn7z49h7z
```c++
#include <setjmp.h>
#include <stdint.h>
#include <stdlib.h>
static jmp_buf recovery;
static volatile unsigned visits;
static volatile unsigned jumped;
static volatile unsigned markers[4];
__attribute__((noinline, returns_twice)) int checkpoint(jmp_buf env) {
// return _setjmp(env); // either works
[[clang::musttail]] return _setjmp(env);
}
void clobber_stack(void) {
volatile uintptr_t slots[4];
for (unsigned i = 0; i < 4; ++i)
slots[i] = UINT64_C(0x6767676767676767);
}
void first() {
markers[0] = 71;
markers[1] = 79;
markers[2] = 84;
markers[3] = 72;
checkpoint(recovery);
visits++;
if (!jumped) {
jumped = 1;
clobber_stack();
_longjmp(recovery, 1);
}
}
void second() {
markers[0] = 71;
markers[1] = 79;
markers[2] = 84;
markers[3] = 72;
checkpoint(recovery);
visits++;
}
int main() {
first();
second();
}
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs