From 6edb8a286f4788c2f6bceee019bb475b20ebfbc7 Mon Sep 17 00:00:00 2001 From: pierre Date: Tue, 27 Mar 2012 15:34:00 +0000 Subject: [PATCH] Avoid SEGV in signal handler as second parameter is only a code, not a pointer git-svn-id: trunk@20642 - --- rtl/netbsd/i386/sighnd.inc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/rtl/netbsd/i386/sighnd.inc b/rtl/netbsd/i386/sighnd.inc index 2809586ad8..155accb142 100644 --- a/rtl/netbsd/i386/sighnd.inc +++ b/rtl/netbsd/i386/sighnd.inc @@ -38,6 +38,7 @@ const procedure SignalToRunerror(Sig: longint;info : PSigInfo;SigContext: PSigContextRec); public name '_FPC_DEFAULTSIGHANDLER'; cdecl; var + code : ptruint; res,fpustate : word; begin res:=0; @@ -49,14 +50,20 @@ begin end; {$endif cpui386} {$endif BSD} +{$ifdef DEBUG} + Writeln(stderr,'Info is 0x',hexstr(ptruint(info),8)); +{$endif} case sig of SIGFPE : begin { this is not allways necessary but I don't know yet how to tell if it is or not PM } res:=200; - if assigned(info) then - fpustate:=info^._info.si_code + { In netbsd, the second parameter is a code, not a pointer to a siginfo structure + at least as long as we use sigaction14 } + code:=ptruint(info); + if code < high(fpustate) then + fpustate:=code else fpustate:=FPE_IntDiv;