[jak2] Fix hover-formation decomp (#2971)

I think this is very likely to fix
https://github.com/open-goal/jak-project/issues/2970

We had somebody report a stacktrace from the debugger, and it was
immediately after calling `gen-perms`.
I found that `gen-perms` writes past the end of a stack array during
this mission, and at the same time as the reported freezes.

I was unable to recreate the original freeze after making this change.
This commit is contained in:
water111
2023-09-09 11:18:21 -04:00
committed by GitHub
parent 572efbf9cb
commit 6d46a22d21
3 changed files with 13 additions and 13 deletions
@@ -1887,7 +1887,7 @@
],
"(method 181 bombbot)": [[16, ["array", "collide-shape", 64]]],
"test-gen-perms": [[16, "gen-perms-context"]],
"gen-perms": [[16, "gen-perms-context"]],
"gen-perms": [[16, ["array", "int32", 32]]],
"(method 11 hover-formation-control)": [[16, ["inline-array", "vector", 16]]],
"(method 11 hover-formation)": [[16, "vector"]],
"birth-func-onin-bubble-birth-pop": [[16, "vector"]],
@@ -214,23 +214,23 @@
(arg3 form-search-info)
)
(local-vars (sv-80 int))
(let ((s2-0 (new 'stack-no-clear 'gen-perms-context)))
(let ((s2-0 (new 'stack-no-clear 'array 'int32 32)))
(dotimes (v1-0 arg0)
(set! (-> (the-as (pointer int32) (+ (the-as uint s2-0) (* v1-0 4)))) 0)
(set! (-> s2-0 v1-0) 0)
)
(arg2 arg3)
(let ((s1-0 1))
(while (< s1-0 arg0)
(cond
((>= (-> (the-as (pointer int32) (+ (the-as uint s2-0) (* s1-0 4)))) s1-0)
(set! (-> (the-as (pointer int32) (+ (the-as uint s2-0) (* s1-0 4)))) 0)
((>= (-> s2-0 s1-0) s1-0)
(set! (-> s2-0 s1-0) 0)
0
)
(else
(let ((s0-0 arg1))
(set! sv-80 s1-0)
(let ((a1-1 (if (odd? s1-0)
(-> (the-as (pointer int32) (+ (the-as uint s2-0) (* s1-0 4))))
(-> s2-0 s1-0)
0
)
)
@@ -239,7 +239,7 @@
(s0-0 sv-80 a1-1 a2-1)
)
)
(+! (-> (the-as (pointer int32) (+ (the-as uint s2-0) (* s1-0 4)))) 1)
(+! (-> s2-0 s1-0) 1)
(arg2 arg3)
(set! s1-0 0)
)
@@ -235,23 +235,23 @@
(arg3 form-search-info)
)
(local-vars (sv-80 int))
(let ((s2-0 (new 'stack-no-clear 'gen-perms-context)))
(let ((s2-0 (new 'stack-no-clear 'array 'int32 32)))
(dotimes (v1-0 arg0)
(set! (-> (the-as (pointer int32) (+ (the-as uint s2-0) (* v1-0 4)))) 0)
(set! (-> s2-0 v1-0) 0)
)
(arg2 arg3)
(let ((s1-0 1))
(while (< s1-0 arg0)
(cond
((>= (-> (the-as (pointer int32) (+ (the-as uint s2-0) (* s1-0 4)))) s1-0)
(set! (-> (the-as (pointer int32) (+ (the-as uint s2-0) (* s1-0 4)))) 0)
((>= (-> s2-0 s1-0) s1-0)
(set! (-> s2-0 s1-0) 0)
0
)
(else
(let ((s0-0 arg1))
(set! sv-80 s1-0)
(let ((a1-1 (if (odd? s1-0)
(-> (the-as (pointer int32) (+ (the-as uint s2-0) (* s1-0 4))))
(-> s2-0 s1-0)
0
)
)
@@ -260,7 +260,7 @@
(s0-0 sv-80 a1-1 a2-1)
)
)
(+! (-> (the-as (pointer int32) (+ (the-as uint s2-0) (* s1-0 4)))) 1)
(+! (-> s2-0 s1-0) 1)
(arg2 arg3)
(set! s1-0 0)
)