Skip to content

Commit 14f50f6

Browse files
cuonglmJunyangShao
authored andcommitted
[release-branch.go1.25] cmd/compile: handle propagating an out-of-range jump table index
For an out-of-range jump table index, the constant facts should not be propagated to the destinations. Fixes #76967 Change-Id: Iff29814cb466c7aaa432cec212e5387665c45afc Reviewed-on: https://go-review.googlesource.com/c/go/+/731860 Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-on: https://go-review.googlesource.com/c/go/+/732460 Reviewed-by: Junyang Shao <shaojunyang@google.com> Commit-Queue: Junyang Shao <shaojunyang@google.com> Auto-Submit: Junyang Shao <shaojunyang@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
1 parent 4e531b2 commit 14f50f6

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

src/cmd/compile/internal/ssa/sccp.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,10 @@ func (t *worklist) propagate(block *Block) {
511511
branchIdx = 1 - condLattice.val.AuxInt
512512
} else {
513513
branchIdx = condLattice.val.AuxInt
514+
if branchIdx < 0 || branchIdx >= int64(len(block.Succs)) {
515+
// unreachable code, do nothing then
516+
break
517+
}
514518
}
515519
t.edges = append(t.edges, block.Succs[branchIdx])
516520
} else {

test/fixedbugs/issue76950.go

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// compile
2+
3+
// Copyright 2025 The Go Authors. All rights reserved.
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file.
6+
7+
package p
8+
9+
func MatchLog(input string) bool {
10+
pos := 0
11+
n := len(input)
12+
matchState := -1
13+
var c byte
14+
15+
goto State12
16+
17+
State8:
18+
goto State65
19+
20+
State12:
21+
if pos >= n {
22+
goto End
23+
}
24+
c = input[pos]
25+
switch {
26+
case c >= 0x09 && c <= 0x0A || c >= 0x0C && c <= 0x0D || c == ' ':
27+
case c >= '0' && c <= '9':
28+
case c >= 'A' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'z':
29+
case c == '[':
30+
goto State8
31+
case c == 'a':
32+
default:
33+
goto End
34+
}
35+
36+
State64:
37+
matchState = 179
38+
if pos >= n {
39+
goto End
40+
}
41+
pos = n
42+
goto State64
43+
44+
State65:
45+
46+
State66:
47+
matchState = 181
48+
if pos >= n {
49+
goto End
50+
}
51+
pos = n
52+
goto State66
53+
54+
End:
55+
if matchState != -1 {
56+
switch matchState {
57+
case 178:
58+
case 156:
59+
case 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175:
60+
case 176, 177, 181, 182, 183:
61+
case 179, 184:
62+
case 180:
63+
}
64+
return true
65+
}
66+
return false
67+
}

0 commit comments

Comments
 (0)