Open Quuxplusone opened 6 years ago
Please compress and attach the files mentioned here so we can easily reproduce
the crash:
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
c++: note: diagnostic msg: /tmp/as_callfunc_x86-315a7c.cpp
c++: note: diagnostic msg: /tmp/as_callfunc_x86-315a7c.sh
(In reply to Nathan Owens from comment #0)
...
> fatal error: error in backend: No open frame
> c++: error: clang frontend command failed with exit code 70 (use -v to see
> invocation)
> FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512
The bug report title says "clang 6.0.0", but the crash message says clang 3.4.1
(which is the default compiler in FreeBSD 10.x). It's not very likely that
bugs in this old version will be fixed, but you should always save and attach
the generated .cpp and .sh files.
(In reply to Dimitry Andric from comment #2)
> (In reply to Nathan Owens from comment #0)
> ...
> > fatal error: error in backend: No open frame
> > c++: error: clang frontend command failed with exit code 70 (use -v to see
> > invocation)
> > FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512
>
> The bug report title says "clang 6.0.0", but the crash message says clang
> 3.4.1 (which is the default compiler in FreeBSD 10.x). It's not very likely
> that bugs in this old version will be fixed, but you should always save and
> attach the generated .cpp and .sh files.
Yeah sorry, I forgot I got that error from freebsd 10.4, also having issues
with 11.2 clang-6; Will attach both, except 11.2 doesn't generate those error
reports like 10.4 did
Attached freebsd-10-4.tar
(856064 bytes, application/x-tar): 10.4 Files
Attached log
(19233 bytes, text/plain): 11.2 build log; Clang 6
This particular crash is an older issue, which has been "solved" in the mean
time, by making it a non-fatal error. After https://reviews.llvm.org/rL315264
("[MC] Properly diagnose badly scoped .cfi_ directives"), it now prints:
error: this directive must appear between .cfi_startproc and .cfi_endproc
directives
The problem is that angelscript is attempting some sort of workaround for
optimizations messing up its assumptions about stack layout, e.g. it has this:
asm __volatile__(
#ifdef __OPTIMIZE__
// When compiled with optimizations the stack unwind doesn't work properly,
// causing exceptions to crash the application. By adding this prologue
// and the epilogue below, the stack unwind works as it should.
// TODO: runtime optimize: The prologue/epilogue shouldn't be needed if the correct cfi directives are used below
"pushl %%ebp \n"
".cfi_adjust_cfa_offset 4 \n"
".cfi_rel_offset ebp, 0 \n"
"movl %%esp, %%ebp \n"
".cfi_def_cfa_register ebp \n"
#endif
_S(CLEAR_FPU_STACK) "\n"
"pushl %%ebx \n"
"movl %%edx, %%ebx \n"
Before r315264, MCStreamer crashed with a "no open frame" error, if it
encountered such 'naked' .cfi directives. After r315264, it prints a regular
error instead.
The easiest way to work around these errors is to change all the #ifdef
__OPTIMIZE__ lines to:
#if defined(__OPTIMIZE__) && !defined(__clang__)
Btw, this is a very minimal test case:
$ cat pr38649.cpp
// clang -cc1 -triple i386-- -emit-obj pr38649.cpp
void a() { asm(".cfi_restore %ebp\n"); }
$ clang -cc1 -triple i386-- -emit-obj pr38649.cpp
error: this directive must appear between .cfi_startproc and .cfi_endproc
directives
1 error generated.
If you attempt to compile this for x86_64, clang blows up in a different way:
$ clang -cc1 -triple x86_64-- -emit-obj -munwind-tables pr38649.cpp
Assertion failed: ((isUIntN(8 * Size, Value) || isIntN(8 * Size, Value)) &&
"Invalid size"), function EmitIntValue, file
/usr/src/contrib/llvm/lib/MC/MCStreamer.cpp, line 115.
Abort trap
(In reply to Dimitry Andric from comment #7)
> Btw, this is a very minimal test case:
>
> $ cat pr38649.cpp
> // clang -cc1 -triple i386-- -emit-obj pr38649.cpp
> void a() { asm(".cfi_restore %ebp\n"); }
>
> $ clang -cc1 -triple i386-- -emit-obj pr38649.cpp
> error: this directive must appear between .cfi_startproc and .cfi_endproc
> directives
> 1 error generated.
This seems like everything is working as intended. If you want to do your own
CFI, maybe use a standalone .s file or a naked function, or force -funwind-
tables.
> If you attempt to compile this for x86_64, clang blows up in a different way:
>
> $ clang -cc1 -triple x86_64-- -emit-obj -munwind-tables pr38649.cpp
> Assertion failed: ((isUIntN(8 * Size, Value) || isIntN(8 * Size, Value)) &&
> "Invalid size"), function EmitIntValue, file
> /usr/src/contrib/llvm/lib/MC/MCStreamer.cpp, line 115.
> Abort trap
That's lame. :( If you don't make an object, we generate this asm:
_Z1av:
.cfi_startproc
#APP
.cfi_restore -2
#NO_APP
retq
.cfi_endproc
The -2 comes from this line in X86RegisterInfo.td:
def EDI : X86Reg<"edi", 7, [DI, HDI]>, DwarfRegNum<[-2, 7, 7]>;
def EBP : X86Reg<"ebp", 5, [BP, HBP]>, DwarfRegNum<[-2, 4, 5]>;
def ESP : X86Reg<"esp", 4, [SP, HSP]>, DwarfRegNum<[-2, 5, 4]>;
The first entry is the register number used for 32-bit x86, and the second and
third I don't know, maybe x64 and x32. I guess we need to diagnose it.
freebsd-10-4.tar
(856064 bytes, application/x-tar)log
(19233 bytes, text/plain)