Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: wrong line number for instruction (go-tip) #42801

Closed
aarzilli opened this issue Nov 24, 2020 · 2 comments
Closed

cmd/compile: wrong line number for instruction (go-tip) #42801

aarzilli opened this issue Nov 24, 2020 · 2 comments
Assignees

Comments

@aarzilli
Copy link
Contributor

@aarzilli aarzilli commented Nov 24, 2020

This only applies to go 1.16 built from tip, specifically:

$ go version
go version devel +d902791b50 Mon Nov 23 05:57:35 2020 +0000 linux/amd64

The following function

func sleepytime() { // <- this is line 9
	time.Sleep(5 * time.Millisecond)
}

Compiled with -gcflags='-N -l' results in:

TEXT main.sleepytime(SB) .../delve/_fixtures/testnextprog.go
  testnextprog.go:9	0x4973c0		64488b0c25f8ffffff	MOVQ FS:0xfffffff8, CX			
  testnextprog.go:9	0x4973c9		483b6110		CMPQ 0x10(CX), SP			
  testnextprog.go:9	0x4973cd		7625			JBE 0x4973f4				
  testnextprog.go:9	0x4973cf		4883ec10		SUBQ $0x10, SP				
  testnextprog.go:9	0x4973d3		48896c2408		MOVQ BP, 0x8(SP)			
  testnextprog.go:9	0x4973d8		488d6c2408		LEAQ 0x8(SP), BP			
  testnextprog.go:11	0x4973dd		48c70424404b4c00	MOVQ $0x4c4b40, 0(SP)			
  testnextprog.go:10	0x4973e5		e8f69ffcff		CALL time.Sleep(SB)			
  testnextprog.go:11	0x4973ea		488b6c2408		MOVQ 0x8(SP), BP			
  testnextprog.go:11	0x4973ef		4883c410		ADDQ $0x10, SP				
  testnextprog.go:11	0x4973f3		c3			RET					
  testnextprog.go:9	0x4973f4		e827b2fcff		CALL runtime.morestack_noctxt(SB)	
  testnextprog.go:9	0x4973f9		ebc5			JMP main.sleepytime(SB)			

Instruction 0x4973dd is passing the argument of time.Sleep but get assigned the wrong line of source code (the closing brace) instead of the correct one (10). The is_stmt flag is also set on it (which would be a good thing if the line number was correct).

cc @dr2chase

@mdempsky
Copy link
Member

@mdempsky mdempsky commented Nov 25, 2020

Git bisect identified CL 259203 (f8d8097).

Loading

@dr2chase dr2chase self-assigned this Nov 25, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Nov 26, 2020

Change https://golang.org/cl/273506 mentions this issue: cmd/compile: fix wrong pos for sp, sb

Loading

@gopherbot gopherbot closed this in 0ecf769 Dec 1, 2020
@golang golang locked and limited conversation to collaborators Dec 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants