golang/go

runtime/cgo: bad debug_frame entry for crosscall2

Open

#21,569 opened on Aug 23, 2017

View on GitHub
 (14 comments) (0 reactions) (0 assignees)Go (19,008 forks)batch import
DebuggingNeedsFixcompiler/runtimehelp wanted

Repository metrics

Stars
 (133,883 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

go version go1.9rc1 linux/amd64
go env:
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/a/n/go/"
GORACE=""
GOROOT="/usr/local/go19rc1"
GOTOOLDIR="/usr/local/go19rc1/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build839946921=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

The debug_frame entry for crosscall2 is wrong in any cgo program.

This is crosscall2:

  asm_amd64.s:12	0x457cc0		4883ec58		SUBQ $0x58, SP		
  asm_amd64.s:16	0x457cc4		48895c2418		MOVQ BX, 0x18(SP)	
  asm_amd64.s:17	0x457cc9		48896c2420		MOVQ BP, 0x20(SP)	
  asm_amd64.s:18	0x457cce		4c89642428		MOVQ R12, 0x28(SP)	
  asm_amd64.s:19	0x457cd3		4c896c2430		MOVQ R13, 0x30(SP)	
  asm_amd64.s:20	0x457cd8		4c89742438		MOVQ R14, 0x38(SP)	
  asm_amd64.s:21	0x457cdd		4c897c2440		MOVQ R15, 0x40(SP)	
  asm_amd64.s:57	0x457ce2		48893424		MOVQ SI, 0(SP)		
  asm_amd64.s:58	0x457ce6		4889542408		MOVQ DX, 0x8(SP)	
  asm_amd64.s:59	0x457ceb		48894c2410		MOVQ CX, 0x10(SP)	
  asm_amd64.s:61	0x457cf0		ffd7			CALL DI			
  asm_amd64.s:64	0x457cf2		488b5c2418		MOVQ 0x18(SP), BX	
  asm_amd64.s:65	0x457cf7		488b6c2420		MOVQ 0x20(SP), BP	
  asm_amd64.s:66	0x457cfc		4c8b642428		MOVQ 0x28(SP), R12	
  asm_amd64.s:67	0x457d01		4c8b6c2430		MOVQ 0x30(SP), R13	
  asm_amd64.s:68	0x457d06		4c8b742438		MOVQ 0x38(SP), R14	
  asm_amd64.s:69	0x457d0b		4c8b7c2440		MOVQ 0x40(SP), R15	
  asm_amd64.s:72	0x457d10		4883c458		ADDQ $0x58, SP		
  asm_amd64.s:76	0x457d14		c3			RET			

The debug_info entry:

 <1><169bb>: Abbrev Number: 2 (DW_TAG_subprogram)
    <169bc>   DW_AT_name        : crosscall2
    <169c7>   DW_AT_low_pc      : 0x457cc0
    <169cf>   DW_AT_high_pc     : 0x457d15
    <169d7>   DW_AT_frame_base  : 1 byte block: 9c      (DW_OP_call_frame_cfa)
    <169d9>   DW_AT_external    : 1
 <2><169da>: Abbrev Number: 0

the debug_frame CIE:

00000000 0000000000000010 ffffffff CIE
  Version:               3
  Augmentation:          ""
  Code alignment factor: 1
  Data alignment factor: -4
  Return address column: 16

  DW_CFA_def_cfa: r7 (rsp) ofs 8
  DW_CFA_offset_extended: r16 (rip) at cfa-8
  DW_CFA_nop

and the debug_frame entry for crosscall2:

0000b4d4 000000000000001c 00000000 FDE cie=00000000 pc=0000000000457cc0..0000000000457d15
  DW_CFA_def_cfa_offset_sf: 8
  DW_CFA_advance_loc1: 84 to 0000000000457d14
  DW_CFA_nop
  DW_CFA_nop
  DW_CFA_nop
  DW_CFA_nop

the cfa offset is 8, it should be 0x58 + 0x8 after the first instruction.

Contributor guide