From: Keith Randall Date: Thu, 2 Mar 2023 06:32:46 +0000 (-0800) Subject: cmd/asm: don't panic on bad GATHER x86 instructions X-Git-Tag: go1.21rc1~1390 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=b958d4a597a599e22c78d25d83d803ab2a1f2c52;p=gostls13.git cmd/asm: don't panic on bad GATHER x86 instructions Fixes #58822 Change-Id: I9c44c57dac72884ec3209d87ddb25e7e1675a737 Reviewed-on: https://go-review.googlesource.com/c/go/+/472795 Reviewed-by: Cuong Manh Le Reviewed-by: Rob Pike TryBot-Result: Gopher Robot Run-TryBot: Keith Randall Reviewed-by: Dmitri Shuralyov Reviewed-by: Keith Randall --- diff --git a/src/cmd/internal/obj/x86/asm6.go b/src/cmd/internal/obj/x86/asm6.go index b441964492..0e8670c8e5 100644 --- a/src/cmd/internal/obj/x86/asm6.go +++ b/src/cmd/internal/obj/x86/asm6.go @@ -4242,6 +4242,11 @@ func (ab *AsmBuf) doasm(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog) { AVPGATHERQD, AVPGATHERDQ, AVPGATHERQQ: + if p.GetFrom3() == nil { + // gathers need a 3rd arg. See issue 58822. + ctxt.Diag("need a third arg for gather instruction: %v", p) + return + } // AVX512 gather requires explicit K mask. if p.GetFrom3().Reg >= REG_K0 && p.GetFrom3().Reg <= REG_K7 { if !avx512gatherValid(ctxt, p) {