Check that we have valid process before invoking event-hook (fix jak1 qbert crash) (#4006)

More info in #4005, which this fixes
This commit is contained in:
Matt Dallmeyer
2025-08-22 11:39:03 -07:00
committed by GitHub
parent d825d9dd25
commit bbac33a8ae
3 changed files with 15 additions and 3 deletions
+5 -1
View File
@@ -399,7 +399,11 @@ It type checks the arguments for the entry function.
(defun send-event-function ((proc process-tree) (msg event-message-block))
"Function to send an event to a process. Please use the send-event macros when possible"
(with-pp
(when (and proc (!= (-> proc type) process-tree) (-> (the process proc) event-hook))
;; og:preserve-this check that we have a _valid_ process. originally this just checked
;; that type != process-tree, but sometimes we might get stale process ref (qbert-plat-master)
(when (and (valid? proc process #f #f 0)
(nonzero? (-> (the process proc) pid))
(-> (the process proc) event-hook))
(let ((pp-backup pp))
(set! pp (the process proc))
(let ((result ((-> (the process proc) event-hook) (-> msg from) (-> msg num-params) (-> msg message) msg)))
+5 -1
View File
@@ -501,7 +501,11 @@ It type checks the arguments for the entry function.
(defun send-event-function ((arg0 process-tree) (arg1 event-message-block))
"Send an event block to a process."
(with-pp
(when (and arg0 (!= (-> arg0 type) process-tree) (-> (the-as process arg0) event-hook) (-> arg1 from))
;; og:preserve-this check that we have a _valid_ process. originally this just checked
;; that type != process-tree, but sometimes we might get stale process ref (jak1 qbert-plat-master)
(when (and (valid? arg0 process (the-as string #f) #f 0)
(nonzero? (-> (the-as process arg0) pid))
(-> (the-as process arg0) event-hook) (-> arg1 from))
(let ((gp-0 pp))
(set! pp (the-as process arg0))
(let ((v0-0 ((-> (the-as process arg0) event-hook) (-> arg1 from 0) (-> arg1 num-params) (-> arg1 message) arg1)))
+5 -1
View File
@@ -461,7 +461,11 @@
(defun send-event-function ((arg0 process-tree) (arg1 event-message-block))
(with-pp
(when (and arg0 (!= (-> arg0 type) process-tree) (-> (the-as process arg0) event-hook) (-> arg1 from))
;; og:preserve-this check that we have a _valid_ process. originally this just checked
;; that type != process-tree, but sometimes we might get stale process ref (jak1 qbert-plat-master)
(when (and (valid? arg0 process (the-as string #f) #f 0)
(nonzero? (-> (the-as process arg0) pid))
(-> (the-as process arg0) event-hook) (-> arg1 from))
(let ((gp-0 pp))
(set! pp (the-as process arg0))
(let ((v0-0 ((-> (the-as process arg0) event-hook) (-> arg1 from 0) (-> arg1 num-params) (-> arg1 message) arg1)))