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: "offset too large" error #21655

Closed
runner-mei opened this issue Aug 28, 2017 · 19 comments

Comments

Projects
None yet
8 participants
@runner-mei
Copy link

commented Aug 28, 2017

What version of Go are you using (go version)?

go version go1.9 windows/amd64

Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?

go env
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=d:\dev\go\meijing;d:\dev\tpt_vendor;d:\dev\Godeps_workspace
set GORACE=
set GOROOT=d:\tools\go_amd64
set GOTOOLDIR=d:\tools\go_amd64\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\xxxx\AppData\Local\Temp\go-build851261075=/tmp/go-build -gno-record-gcc-switches
set CXX=g++
set CGO_ENABLED=1
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config

What did you do?

I compile my app, it is ok on go1.8 or go1.7
code is:

default

What did you expect to see?

it is compile ok.

What did you see instead?

cn/com/hengwei/poller

.\alert_action.go:448:2: offset too large in 02217 (d:\dev\meijing\src\cn\com\hengwei\poller\alert_action.go:428) MOVQ -17179868768(BX)(AX8),BX
.\alert_action.go:448:2: offset too large in 03783 (d:\dev\meijing\src\cn\com\hengwei\poller\alert_action.go:430) MOVQ -17179868768(DX)(CX
8),DX
FAIL cn/com/hengwei/poller [build failed]

@dsnet

This comment has been minimized.

Copy link
Member

commented Aug 28, 2017

Hi. We're going to need something more than a screenshot to help debug this. At least paste a minimal reproduction of the problem.

\cc @randall77 @josharian

@dsnet dsnet changed the title compile error on go1.9 cmd/compile: "offset too large" error Aug 28, 2017

@dsnet dsnet added this to the Go1.9.1 milestone Aug 28, 2017

@runner-mei

This comment has been minimized.

Copy link
Author

commented Aug 28, 2017

@dsnet this code is private, if you can promise not to spread it, nor use it elsewhere, and delete it after finding out the problem, I can send this code to your mail.

@dsnet

This comment has been minimized.

Copy link
Member

commented Aug 28, 2017

Please don't send me anything. I have reported on compiler bugs before. You should be able to use process of elimination to eventually trim the problem down to a snippet that is safe to share. For example, #20333.

@runner-mei

This comment has been minimized.

Copy link
Author

commented Aug 28, 2017

package abc

import (
	"math"
)

const current_status_internal_start = math.MaxInt32 - 50

func gen_message(ss []*string, current int) string {
	s := ss[current-current_status_internal_start]
	if nil != s {
		return ""
	}

	switch current {
	case 0:
		return "a"
	default:
		return "b"
	}
}

main.zip

D:\developing\go\meijing\src\abc>go build
# abc
.\main.go:15:2: offset too large in 00039 (d:\developing\go\meijing\src\abc\main.go:10) MOVQ    -17179868776(CX)(AX*8), CX

it is ok on the linux.

@opennota

This comment has been minimized.

Copy link

commented Aug 28, 2017

it is ok on the linux.

It's not, on my machine.

$ go build 
# github.com/opennota/a
./main.go:15:2: offset too large in 00039 (/home/opennota/gocode/src/github.com/opennota/a/main.go:10)       MOVQ    -17179868776(CX)(AX*8), CX

$ go version
go version go1.9 linux/amd64

$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/opennota/gocode"
GORACE=""
GOROOT="/home/opennota/go"
GOTOOLDIR="/home/opennota/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build906297495=/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"
@runner-mei

This comment has been minimized.

Copy link
Author

commented Aug 28, 2017

@opennota yes, I made a mistake, it is fail also on the linux.

@randall77 randall77 self-assigned this Aug 28, 2017

@randall77 randall77 added NeedsFix and removed WaitingForInfo labels Aug 28, 2017

@dsnet

This comment has been minimized.

Copy link
Member

commented Aug 28, 2017

@runner-mei, thank you for producing a minimal repro.

@gopherbot

This comment has been minimized.

Copy link

commented Aug 28, 2017

Change https://golang.org/cl/59630 mentions this issue: cmd/compile: avoid generating large offsets

@gopherbot gopherbot closed this in 053840d Aug 28, 2017

@randall77

This comment has been minimized.

Copy link
Contributor

commented Aug 28, 2017

Reopening for cherry pick for 1.9.1.

@randall77 randall77 reopened this Aug 28, 2017

@rsc rsc modified the milestones: Go1.9.1, Go1.9.2 Oct 4, 2017

@rsc

This comment has been minimized.

Copy link
Contributor

commented Oct 13, 2017

CL 59630 OK for Go 1.9.2.
CL 70981 OK for Go 1.9.2. (resolved merge conflicts in cherry-pick)

@gopherbot

This comment has been minimized.

Copy link

commented Oct 15, 2017

Change https://golang.org/cl/70981 mentions this issue: [release-branch.go1.9] cmd/compile: avoid generating large offsets

gopherbot pushed a commit that referenced this issue Oct 25, 2017

[release-branch.go1.9] cmd/compile: avoid generating large offsets
The assembler barfs on large offsets. Make sure that all the
instructions that need to have their offsets in an int32
  1) check on any rule that computes offsets for such instructions
  2) change their aux fields so the check builder checks it.

The assembler also silently misassembled offsets between 1<<31
and 1<<32. Add a check in the assembler to barf on those as well.

Fixes #21655

Change-Id: Iebf24bf10f9f37b3ea819ceb7d588251c0f46d7d
Reviewed-on: https://go-review.googlesource.com/59630
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-on: https://go-review.googlesource.com/70981
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
@rsc

This comment has been minimized.

Copy link
Contributor

commented Oct 26, 2017

go1.9.2 has been packaged and includes:

The release is posted at golang.org/dl.

— golang.org/x/build/cmd/releasebot, Oct 26 21:09:10 UTC

@rsc rsc closed this Oct 26, 2017

@runner-mei

This comment has been minimized.

Copy link
Author

commented Dec 7, 2017

This bug is still exists in the go 1.9.2 on windows/386

C:\tpt_programs\src> go version
go1.9.2 windows/386

C:\tpt_programs\src>go build
# _/C_/tpt_programs/src
.\main.go:15:2: offset too large in 00040 (C:\tpt_programs\src\main.go:10)      MOVL    -8589934388(CX)(AX*4), CX
@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Dec 7, 2017

Still happens on tip too, with GOARCH=386. Reopening.

@ianlancetaylor ianlancetaylor reopened this Dec 7, 2017

@ianlancetaylor ianlancetaylor modified the milestones: Go1.9.2, Go1.9.3 Dec 7, 2017

@gopherbot

This comment has been minimized.

Copy link

commented Dec 7, 2017

Change https://golang.org/cl/82675 mentions this issue: cmd/compile: fix large load/store offsets on 386

@gopherbot gopherbot closed this in 4c800f0 Dec 8, 2017

@randall77

This comment has been minimized.

Copy link
Contributor

commented Dec 8, 2017

Reopening for go 1.9.3.

@andybons

This comment has been minimized.

Copy link
Member

commented Jan 18, 2018

CL 82675 OK for Go 1.9.3.

@gopherbot

This comment has been minimized.

Copy link

commented Jan 18, 2018

Change https://golang.org/cl/88324 mentions this issue: [release-branch.go1.9] cmd/compile: fix large load/store offsets on 386

gopherbot pushed a commit that referenced this issue Jan 22, 2018

[release-branch.go1.9] cmd/compile: fix large load/store offsets on 386
Pointer arithemetic is done mod 2^32 on 386, so we can just
drop the high bits of any large constant offsets.

The bounds check will make sure wraparounds are never observed.

Fixes #21655

Change-Id: I68ae5bbea9f02c73968ea2b21ca017e5ecb89223
Reviewed-on: https://go-review.googlesource.com/82675
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-on: https://go-review.googlesource.com/88324
Run-TryBot: Andrew Bonventre <andybons@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
@andybons

This comment has been minimized.

Copy link
Member

commented Jan 22, 2018

go1.9.3 has been packaged and includes:

  • CL 82675 cmd/compile: fix large load/store offsets on 386

The release is posted at golang.org/dl.

— golang.org/x/build/cmd/releasebot, Jan 22 21:02:53 UTC

@andybons andybons closed this Jan 22, 2018

@golang golang locked and limited conversation to collaborators Jan 22, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.