[llvm-bugs] [Bug 35142] New: Mishandling SEH filters for available_externally functions
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Oct 30 17:01:43 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=35142
Bug ID: 35142
Summary: Mishandling SEH filters for available_externally
functions
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Core LLVM classes
Assignee: unassignedbugs at nondot.org
Reporter: peter at pcc.me.uk
CC: llvm-bugs at lists.llvm.org
$ cat 1.cc
static void try_body(int numerator, int denominator, int *myres) {
*myres = numerator / denominator;
}
inline int safe_div(int numerator, int denominator, int *res) {
int myres = 0;
int success = 1;
__try {
try_body(numerator, denominator, &myres);
} __except (1) {
success = -42;
}
*res = myres;
return success;
}
void *f() { return (void *)&safe_div; }
$ cat 2.cc
static void try_body(int numerator, int denominator, int *myres) {
*myres = numerator / denominator;
}
inline int safe_div(int numerator, int denominator, int *res) {
int myres = 0;
int success = 1;
__try {
try_body(numerator, denominator, &myres);
} __except (1) {
success = -42;
}
*res = myres;
return success;
}
void *g() { return (void *)&safe_div; }
$ clang-cl /c 1.cc 2.cc -flto=thin -m32
$ lld-link 1.obj 2.obj /nodefaultlib /entry:f /opt:lldlto=0 /lldsavetemps
LLVM ERROR: assembler label 'L?safe_div@@YAHHHPAH at Z$parent_frame_offset' can
not be undefined
What's going on here is that the linker is choosing 1.obj's definition of
safe_div as prevailing, and requesting that 2.obj's definition be dropped. It
does this by setting linkage to available_externally. This reveals two bugs.
The first is that the localrecover check in Verifier.cpp is insufficient; under
the current semantics it would need to account for available_externally linkage
by calling isDeclarationForLinker instead of isDeclaration.
Even if we did that, though, we'd still hit a verifier check for this test
case, and the fix for that bug is unclear. At the object file level, 2.obj
contains an SEH filter with information about the non-prevailing definition of
safe_seh. The fix I have in mind is that because it is impossible for there to
be an active stack frame for said non-prevailing definition, the behaviour of
the SEH filter is undefined, and we can simply treat the intrinsic call as
equivalent to unreachable if it refers to an undefined function.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20171031/2cf818a7/attachment.html>
More information about the llvm-bugs
mailing list