Skip to content

cmd/asm: panic on wrong AVX512 assembly #58822

@wojciech-sneller

Description

@wojciech-sneller

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

$ go version
go version go1.20 linux/amd64

Does this issue reproduce with the latest release?

Don' know

What did you do?

I tried to compile a program having a mistake in asm code:

~/tmp/bug$ cat go.mod 
module main
~/tmp/bug$ cat main.go 
package main

// go:noescape
// go:nosplit
func procedure()

func main() {
    procedure()
}
~/tmp/bug$ cat proc_amd64.s 
#include "textflag.h"
#include "funcdata.h"
#include "go_asm.h"

TEXT ·procedure(SB), NOSPLIT|NOFRAME, $0-8
    VPGATHERDD (BX)(Z0*1), Z2 # missing the second argument (an kreg)

    RET

What did you expect to see?

An error message, like that:

asm: "".procedure: invalid instruction: 00000 (/home/wojtek/tmp/bug/proc_amd64.s:6)	VPADDD	Z2, Z0

What did you see instead?

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x56df73]

goroutine 1 [running]:
cmd/internal/obj/x86.(*AsmBuf).doasm(0xc000111b70, 0xc000104400, 0xc000106180, 0xc00017c0d0)
	/usr/local/go/src/cmd/internal/obj/x86/asm6.go:4245 +0x193
cmd/internal/obj/x86.(*AsmBuf).asmins(0xc000111b70, 0xc000104400, 0xc000106180, 0xc00017c0d0)
	/usr/local/go/src/cmd/internal/obj/x86/asm6.go:5377 +0x46
cmd/internal/obj/x86.span6(0xc000104400, 0xc000106180, 0xc0000522f0?)
	/usr/local/go/src/cmd/internal/obj/x86/asm6.go:2156 +0x991
cmd/internal/obj.Flushplist(0xc000104400, 0xc000111e60, 0x0, {0x7ffe4db85038, 0x4})
	/usr/local/go/src/cmd/internal/obj/plist.go:152 +0x88d
main.main()
	/usr/local/go/src/cmd/asm/main.go:96 +0x6f7

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions