]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/asm: don't panic on bad GATHER x86 instructions
authorKeith Randall <khr@golang.org>
Thu, 2 Mar 2023 06:32:46 +0000 (22:32 -0800)
committerKeith Randall <khr@google.com>
Thu, 2 Mar 2023 15:57:24 +0000 (15:57 +0000)
Fixes #58822

Change-Id: I9c44c57dac72884ec3209d87ddb25e7e1675a737
Reviewed-on: https://go-review.googlesource.com/c/go/+/472795
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Rob Pike <r@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@google.com>
src/cmd/internal/obj/x86/asm6.go

index b4419644922cb1d39cfa6b00f92278d17c052595..0e8670c8e5d6f972beb48c9c693ea5bffc1bf42c 100644 (file)
@@ -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) {