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/asm: crash when encountering wrong character before name of function #23580

Closed
dpinela opened this issue Jan 27, 2018 · 1 comment
Closed
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@dpinela
Copy link
Contributor

dpinela commented Jan 27, 2018

What did you do?

Create a package named "asmcrash" with the following two files:

proc.go

package asmcrash

func B() uintptr

proc.s

#include "textflag.h"

TEXT @B(SB),NOSPLIT,$0
	MOVQ (TLS), AX
	MOVQ AX, ret+0(FP)
	RET

(You can replace the @ with other non-alphanumeric characters other than U+00B7 MIDDLE DOT. I originally encountered the bug with U+2022 BULLET.)

Then try to go build the package.

What did you expect to see?

A syntax error message, followed by the go tool exiting cleanly.

What did you see instead?

# github.com/dpinela/asmcrash
./proc.s:3: expected '(', found B
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x60 pc=0x1153970]

goroutine 1 [running]:
cmd/asm/internal/asm.(*Parser).asmText(0xc420045e98, 0xc420014254, 0x4, 0xc420045c58, 0x3, 0x3)
	/usr/local/go/src/cmd/asm/internal/asm/asm.go:176 +0x5d0
cmd/asm/internal/asm.(*Parser).pseudo(0xc420045e98, 0xc420014254, 0x4, 0xc420045c58, 0x3, 0x3, 0x3)
	/usr/local/go/src/cmd/asm/internal/asm/parse.go:230 +0x9a
cmd/asm/internal/asm.(*Parser).line(0xc420045e98, 0xc42004e390)
	/usr/local/go/src/cmd/asm/internal/asm/parse.go:190 +0xa04
cmd/asm/internal/asm.(*Parser).Parse(0xc420045e98, 0xc42004e390, 0x11d7080)
	/usr/local/go/src/cmd/asm/internal/asm/parse.go:93 +0x2b
main.main()
	/usr/local/go/src/cmd/asm/main.go:69 +0x6ef

Does this issue reproduce with the latest release (go1.9.3)?

Yes. It also reproduces with 1.10rc1. (The error and stack trace are identical on both versions)

System details

go version go1.10rc1 darwin/amd64
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/dpinela/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/dpinela/dev/go"
GORACE=""
GOROOT="/Users/dpinela/sdk/go1.10rc1"
GOTMPDIR=""
GOTOOLDIR="/Users/dpinela/sdk/go1.10rc1/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
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"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/41/2xpv_r1j5n5bnflwb7s1hv580000gp/T/go-build994132333=/tmp/go-build -gno-record-gcc-switches -fno-common"
GOROOT/bin/go version: go version go1.10rc1 darwin/amd64
GOROOT/bin/go tool compile -V: compile version go1.10rc1
uname -v: Darwin Kernel Version 17.3.0: Thu Nov  9 18:09:22 PST 2017; root:xnu-4570.31.3~1/RELEASE_X86_64
ProductName:	Mac OS X
ProductVersion:	10.13.2
BuildVersion:	17C88
lldb --version: lldb-900.0.64
  Swift-4.0
@robpike robpike self-assigned this Jan 27, 2018
@robpike robpike added this to the Go1.11 milestone Jan 27, 2018
@ianlancetaylor ianlancetaylor added the NeedsFix The path to resolution is known, but the work has not been done. label Jan 28, 2018
@gopherbot
Copy link

Change https://golang.org/cl/90398 mentions this issue: cmd/asm: fix crash on bad symbol for TEXT

@golang golang locked and limited conversation to collaborators Feb 13, 2019
@rsc rsc unassigned robpike Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants