From b4e4480d755aff4e6b2d8fa51f7cc8736396c936 Mon Sep 17 00:00:00 2001 From: Daniel Collins Date: Thu, 27 Jun 2024 23:26:17 +0100 Subject: [PATCH] Skip profiling when disabled in stubs with unknown arguments. The profiling code normally harmlessly no-ops in this case, but it can crash when the profiling code hasn't bee initialised. --- mkstubs.pl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mkstubs.pl b/mkstubs.pl index db84ce1..90e3ea8 100644 --- a/mkstubs.pl +++ b/mkstubs.pl @@ -271,10 +271,17 @@ END $func->{name}_go: + ; Bypass the profiling code and jump straight into the taget + ; function when not profiling. + cmp byte [_stubs_enable_profile], 0 + je $func->{name}_skip + ; Record that we were called push dword $func->{name}_fstats call _fprof_record_untimed + $func->{name}_skip: + ; Jump into target function. We have left the stack as we found it ; so it can take over our frame. jmp [$func->{name}_addr]