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: bad asmhdr generation when a const string is too long #50523

Closed
lizthegrey opened this issue Jan 9, 2022 · 1 comment
Closed

Comments

@lizthegrey
Copy link

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

$ go version
go version go1.18beta1 linux/amd64

Does this issue reproduce with the latest release?

Yes, and it's a regression from go1.17.

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/lizf/.cache/go-build"
GOENV="/home/lizf/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/lizf/hny/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/lizf/hny/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/snap/go/current"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/snap/go/current/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18beta1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1152832268=/tmp/go-build -gno-record-gcc-switches"

What did you do?

$ cat badasm.go 
package badasm

const _literalsBlockType_name = "literalsBlockRawliteralsBlockRLEliteralsBlockCompressedliteralsBlockTreeless"
$ cat foo_amd64.s
#include "go_asm.h"
$ GO111MODULE=off go build
# _/tmp/repro
go_asm.h:3:39: literal not terminated
./foo_amd64.s:2: missing newline in definition for macro: const__literalsBlockType_name
$ echo $?
2
$ GO111MODULE=off GOROOT=/snap/go/8839 /snap/go/8839/bin/go build
$ echo $?
0
$ go tool compile -asmhdr out.h badasm.go 
$ cat out.h
// generated by compile -asmhdr from package badasm

#define const__literalsBlockType_name "literalsBlockRawliteralsBlockRLEliteralsBlockCompressedliteralsBlock...

What did you expect to see?

Successful build, with a properly constructed const__literalsBlockType_name value that is not truncated

What did you see instead?

Failed build, because the string value of const__literalsBlockType_name is never terminated.

@gopherbot
Copy link

Change https://golang.org/cl/377074 mentions this issue: cmd/compile: use exact constant in go_asm.h

jproberts pushed a commit to jproberts/go that referenced this issue Jun 21, 2022
Fixes golang#50523

Change-Id: Idab1b44d106250e9301d90ee6571f0ea51242dd9
Reviewed-on: https://go-review.googlesource.com/c/go/+/377074
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Liz Fong-Jones <lizf@honeycomb.io>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
@golang golang locked and limited conversation to collaborators Jun 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants