Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Flag unbalanced .cfi_adjust_cfa_offset directives at .cfi_endproc as error #26097

Open Quuxplusone opened 8 years ago

Quuxplusone commented 8 years ago
Bugzilla Link PR26098
Status NEW
Importance P enhancement
Reported by Bart Jacobs (bart.jacobs@cs.kuleuven.be)
Reported on 2016-01-09 17:47:22 -0800
Last modified on 2016-11-17 16:48:55 -0800
Version 3.5
Hardware Macintosh MacOS X
CC emaste@freebsd.org, llvm-bugs@lists.llvm.org, rafael@espindo.la
Fixed by commit(s)
Attachments myobj.s (220 bytes, application/octet-stream)
Blocks
Blocked by
See also
Created attachment 15597
Small repro

First: I'm not sure whether I am using gccas or llvm-as. The command I use is
'clang -arch x86_64 -c -v myobj.s'.

This is about .cfi_xxx directives for emitting DWARF CFI (call frame
information) that enables debuggers to generate stack backtraces and
programming language runtimes (specifically C++ and Objective-C) to walk and
unwind the stack.

The assembler currently accepts input where the net CFA offset adjustment at a
.cfi_endproc is nonzero. See small example attached. Its current behavior in
that case is that the adjustment is applied to the next assembly routine
(.cfi_startproc directive) as well. You can see by running 'dwarfdump --eh-
frame myobj.o'. I believe this input is usually/always erroneous and
furthermore the behavior is undesirable.

I would suggest to at least offer an option to have this flagged as an error.
Also, that behavior should probably be the default.

(Context: the OCaml native code compiler currently generates such unbalanced
directives. See http://caml.inria.fr/mantis/view.php?id=7120 and
http://caml.inria.fr/mantis/view.php?id=7118 and
https://github.com/ocaml/ocaml/pull/408 . In this case, it is definitely an
error. It caused my application to crash randomly. Especially during demos ;-) )
Quuxplusone commented 8 years ago

Attached myobj.s (220 bytes, application/octet-stream): Small repro