unwinding info for stg_catch_frame is wrong
Minimized stg_catch_frame
(Small.cmm
):
#define CATCH_FRAME 34
#define SIZEOF_StgCatchFrame (SIZEOF_StgHeader+16)
INFO_TABLE_RET(stg_catch_frame, CATCH_FRAME,
bits64 info_ptr, bits64 exceptions_blocked, gcptr handler)
return (gcptr ret)
{
unwind Sp = Sp + SIZEOF_StgCatchFrame;
return (ret);
}
Compile "inplace/bin/ghc-stage2" -O2 -g -c Small.cmm
using GHC HEAD.
objdump -D
for stg_catch_frame_info
:
0000000000000010 <stg_catch_frame_info>:
10: 48 83 c5 18 add $0x18,%rbp
14: ff 65 00 jmpq *0x0(%rbp)
readelf --debug-dump=frames-interp Small.o
:
Contents of the .debug_frame section:
00000000 0000000000000014 ffffffff CIE "" cf=1 df=-8 ra=16
LOC CFA rbp rsp ra
0000000000000000 rbp+0 v+0 s c+0
00000018 000000000000002c 00000000 FDE cie=00000000 pc=000000000000000f..0000000000000017
LOC CFA rbp rsp ra
000000000000000f rbp+0 v+0 s c+0
000000000000000f rbp+24 v+0 s c+0
0000000000000010 rbp+0 v+0 s c+0
- *How do I know this is wrong?**
http://www.dwarfstd.org/doc/dwarf-2.0.0.pdf has a nice example in Appendix 5 (page 101 of the pdf). The question that I had was if the CFA value at LOC is after or before the instruction at LOC executes. Appendix 5 clearly shows that it's **before**.
Hence for LOC = 0x10 here CFA shouldn't have changed. It can and should change at LOC = 0x14.
For comparison this is what 8.0.2
produced (and it worked more often):
0000000000000010 <stg_catch_frame_info>:
10: 48 83 c5 18 add $0x18,%rbp
14: ff 65 00 jmpq *0x0(%rbp)
Contents of the .debug_frame section:
00000000 0000000000000014 ffffffff CIE "" cf=1 df=-8 ra=16
LOC CFA rbp rsp ra
0000000000000000 rbp+0 v+0 s c+0
00000018 0000000000000024 00000000 FDE cie=00000000 pc=000000000000000f..0000000000000017
LOC CFA rbp rsp ra
000000000000000f rbp+0 v+0 s c+0
000000000000000f rbp+24 v+0 s c+0
Debugging follows in the comments.
Trac metadata
Trac field | Value |
---|---|
Version | |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | bgamari, simonmar |
Operating system | |
Architecture |