I'm sorry, but I'm not sure what to do to test the modification.
I have Emacs 29.2 installed via snap. I suppose I would need to
install the modified version by downloading it from the repo.
This is something I've never done before.
If necessary, I could try doing it on a virtual machine.
If you want a lightweight approximation to the real test, you could add
the following to the beginning of your init file:
(with-eval-after-load 'comp-run
(require 'cl-lib)
(defun comp-subr-trampoline-install (subr-name)
"Make SUBR-NAME effectively advice-able when called from native code."
(when (memq subr-name comp-warn-primitives)
(warn "Redefining `%s' might break native compilation of
trampolines."
subr-name))
(let ((subr (symbol-function subr-name)))
(unless (or (not (string= subr-name (subr-name subr))) ;; (bug#69573)
(null native-comp-enable-subr-trampolines)
(memq subr-name native-comp-never-optimize-functions)
(gethash subr-name comp-installed-trampolines-h))
(cl-assert (subr-primitive-p subr))
(when-let ((trampoline (or (comp-trampoline-search subr-name)
(comp-trampoline-compile subr-name))))
(comp--install-trampoline subr-name trampoline))))))
and then try and reproduce the problem.
Stefan