go: runtime: runtime.Breakpoint() generates illegal instruction on windows/arm64

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

go version go1.19rc1 windows/arm64

Does this issue reproduce with the latest release?

Yes

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

go env Output
set GO111MODULE=
set GOARCH=arm64
set GOBIN=
set GOCACHE=C:\Users\qmuntaldiaz\AppData\Local\go-build
set GOENV=C:\Users\qmuntaldiaz\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=arm64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\qmuntaldiaz\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\qmuntaldiaz\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_arm64
set GOVCS=
set GOVERSION=go1.19rc1
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\qmuntaldiaz\code\netabort\go.mod
set GOWORK=
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
set GOGCCFLAGS=-mthreads -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=C:\Users\QMUNTA~1\AppData\Local\Temp\go-build3550564676=/tmp/go-build -gno-record-gcc-switches

What did you do?

package main

import "runtime"

func main() {
	runtime.Breakpoint()
        println("Hello World!")
}

go run .

What did you expect to see?

Edited: exit status 0xc0000409 Hello World!

What did you see instead?

Program crashes due to an ilegal instruction:

fatal error: fault
[signal 0xc000001d code=0x0 addr=0x0 pc=0x7ff70c383180]

goroutine 1 [running]:
runtime.throw({0x7ff70c399235?, 0x0?})
        C:/Program Files/Go/src/runtime/panic.go:1047 +0x40 fp=0x4000049f00 sp=0x4000049ed0 pc=0x7ff70c35f3b0
runtime.sigpanic()
        C:/Program Files/Go/src/runtime/signal_windows.go:273 +0x1a0 fp=0x4000049f50 sp=0x4000049f00 pc=0x7ff70c371830
runtime.breakpoint()
        C:/Program Files/Go/src/runtime/asm_arm64.s:111 fp=0x4000049f60 sp=0x4000049f60 pc=0x7ff70c383180
runtime.Breakpoint(...)
        C:/Program Files/Go/src/runtime/proc.go:4359
main.main()
        C:/Users/qmuntaldiaz/code/netabort/main.go:6 +0x20 fp=0x4000049f70 sp=0x4000049f60 pc=0x7ff70c38b860
runtime.main()
        C:/Program Files/Go/src/runtime/proc.go:250 +0x234 fp=0x4000049fd0 sp=0x4000049f70 pc=0x7ff70c361884
runtime.goexit()
        C:/Program Files/Go/src/runtime/asm_arm64.s:1155 +0x4 fp=0x4000049fd0 sp=0x4000049fd0 pc=0x7ff70c385834

goroutine 2 [force gc (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        C:/Program Files/Go/src/runtime/proc.go:363 +0xe4 fp=0x4000045fa0 sp=0x4000045f80 pc=0x7ff70c361c34
runtime.goparkunlock(...)
        C:/Program Files/Go/src/runtime/proc.go:369
runtime.forcegchelper()
        C:/Program Files/Go/src/runtime/proc.go:302 +0xb4 fp=0x4000045fd0 sp=0x4000045fa0 pc=0x7ff70c361ac4
runtime.goexit()
        C:/Program Files/Go/src/runtime/asm_arm64.s:1155 +0x4 fp=0x4000045fd0 sp=0x4000045fd0 pc=0x7ff70c385834
created by runtime.init.6
        C:/Program Files/Go/src/runtime/proc.go:290 +0x24

goroutine 3 [GC sweep wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        C:/Program Files/Go/src/runtime/proc.go:363 +0xe4 fp=0x4000047f70 sp=0x4000047f50 pc=0x7ff70c361c34
runtime.goparkunlock(...)
        C:/Program Files/Go/src/runtime/proc.go:369
runtime.bgsweep(0x0?)
        C:/Program Files/Go/src/runtime/mgcsweep.go:278 +0xa4 fp=0x4000047fb0 sp=0x4000047f70 pc=0x7ff70c34de64
runtime.gcenable.func1()
        C:/Program Files/Go/src/runtime/mgc.go:178 +0x28 fp=0x4000047fd0 sp=0x4000047fb0 pc=0x7ff70c342598
runtime.goexit()
        C:/Program Files/Go/src/runtime/asm_arm64.s:1155 +0x4 fp=0x4000047fd0 sp=0x4000047fd0 pc=0x7ff70c385834
created by runtime.gcenable
        C:/Program Files/Go/src/runtime/mgc.go:178 +0x70

goroutine 4 [GC scavenge wait]:
runtime.gopark(0x40000180e0?, 0x7ff70c3b0358?, 0x1?, 0x0?, 0x0?)
        C:/Program Files/Go/src/runtime/proc.go:363 +0xe4 fp=0x4000055f50 sp=0x4000055f30 pc=0x7ff70c361c34
runtime.goparkunlock(...)
        C:/Program Files/Go/src/runtime/proc.go:369
runtime.(*scavengerState).park(0x7ff70c3f3200)
        C:/Program Files/Go/src/runtime/mgcscavenge.go:389 +0x5c fp=0x4000055f80 sp=0x4000055f50 pc=0x7ff70c34be5c
runtime.bgscavenge(0x0?)
        C:/Program Files/Go/src/runtime/mgcscavenge.go:617 +0x44 fp=0x4000055fb0 sp=0x4000055f80 pc=0x7ff70c34c3c4
runtime.gcenable.func2()
        C:/Program Files/Go/src/runtime/mgc.go:179 +0x28 fp=0x4000055fd0 sp=0x4000055fb0 pc=0x7ff70c342538
runtime.goexit()
        C:/Program Files/Go/src/runtime/asm_arm64.s:1155 +0x4 fp=0x4000055fd0 sp=0x4000055fd0 pc=0x7ff70c385834
created by runtime.gcenable
        C:/Program Files/Go/src/runtime/mgc.go:179 +0xb4
exit status 2

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 20 (18 by maintainers)

Commits related to this issue

Most upvoted comments

https://developer.arm.com/documentation/ddi0602/2022-06/Base-Instructions/BRK--Breakpoint-instruction-?lang=en

The BRK instructions needs an immediate 16 bits argument.

It seems like the operating system could inspect the immediate set by BRK and then send a different signal to the process depending on the value. BRK without the immediate would then become a shorthand for BRK 0.