Raymond Toy pushed to branch issue-355-solaris-x86-fp-trap-handler at cmucl / cmucl
Commits: 65b92932 by Raymond Toy at 2024-09-05T07:02:52-07:00 Include limits.h to get PATH_MAX for elf.c
- - - - - ea86bd7c by Raymond Toy at 2024-09-05T07:03:22-07:00 More debugging prints and code.
With these changes we get:
``` * (* 1d300 1d300) ***Enter Handler*** os_sigcontext_x87 cw, sw = #x0072 #x0020 os_sigcontext_sse2 mxcsr = #x00001928 Current modes: 00000000000000000000011010101000 Current HW x87 modes: 00000000010011010000000000100000 Current HW sse2 modes: 00000000000000000000011010101000 sigcontext x87: 00000000011100100000000000100000 sigcontext sse2: 00000000000000000001100100101000 fpe code = 4
Arithmetic error FLOATING-POINT-OVERFLOW signalled. Operation was *, operands (1.0d300 NIL). [Condition of type FLOATING-POINT-OVERFLOW]
Restarts: 0: [ABORT] Return to Top-Level.
Debug (type H for help)
(X86:SIGFPE-HANDLER #<unused-arg> 4 #.(SYSTEM:INT-SAP #x3FFFC124)) Source: ; File: target:code/float-trap.lisp (ERROR FPE-INFO :OPERATION FOP :OPERANDS ...) 0] 0 ***Cleanup*** Trap bit: 8 Current modes: 00000000000000000000011010101000 Current HW x87 modes: 00000000010011010000000000100000 Current HW sse2 modes: 00000000000000000000011010101000 New x87 modes: 00000000010011010000000000100000 New sse2 modes: 00000000000000000000011010100000 Setting new sse2 modes New sse2 sigcontext: 00000000000000000001100100100000 os_set_sigcontext_sse2 mxcsr = #x00001920 Setting new x87 modes New x87 sigcontext: 00000000011100100000000000100000 ***Enter Handler*** os_sigcontext_x87 cw, sw = #x0072 #x0000 os_sigcontext_sse2 mxcsr = #x00001920 Current modes: 00000000000000000000011010100000 Current HW x87 modes: 00000000010011010000000000000000 Current HW sse2 modes: 00000000000000000000011010100000 sigcontext x87: 00000000011100100000000000000000 sigcontext sse2: 00000000000000000001100100100000 fpe code = 4 ***Cleanup*** Trap bit: 8 Current modes: 00000000000000000000011010100000 Current HW x87 modes: 00000000010011010000000000000000 Current HW sse2 modes: 00000000000000000000011010100000 New x87 modes: 00000000010011010000000000000000 New sse2 modes: 00000000000000000000011010100000 Setting new sse2 modes New sse2 sigcontext: 00000000000000000001100100100000 os_set_sigcontext_sse2 mxcsr = #x00001920 Setting new x87 modes New x87 sigcontext: 00000000011100100000000000000000 os_set_sigcontext_x87 modes = #x00720000 os_set_sigcontext_x87 cw, sw = #x0072 #x0000 new x87 modes: 00000000010011010000000000000000 new sse2 modes: 00000000000000000000011010100000 new x87 modes: 00000000010011010000000000000000 new sse2 modes: 00000000000000000000011010100000 ```
- - - - -
2 changed files:
- src/code/float-trap.lisp - src/lisp/elf.c
Changes:
===================================== src/code/float-trap.lisp ===================================== @@ -483,15 +483,20 @@ (defun sigfpe-handler (signal code scp) (declare (ignore signal) (type system-area-pointer scp)) + (format t "***Enter Handler***~%") (let* ((modes (sigcontext-floating-point-modes - (alien:sap-alien scp (* unix:sigcontext))))) + (alien:sap-alien scp (* unix:sigcontext)))) + (sigcontext-x87-modes (sigcontext-floating-point-modes-x87 + (alien:sap-alien scp (* unix:sigcontext)))) + (sigcontext-sse2-modes (sigcontext-floating-point-modes-sse2 + (alien:sap-alien scp (* unix:sigcontext)))) + (current-x87-modes (vm::x87-floating-point-modes)) + (current-sse2-modes (vm::sse2-floating-point-modes))) (format t "Current modes: ~32,'0b~%" modes) - (format t "sigcontext x87: ~32,'0b~%" - (sigcontext-floating-point-modes-x87 - (alien:sap-alien scp (* unix:sigcontext)))) - (format t "sigcontext sse2: ~32,'0b~%" - (sigcontext-floating-point-modes-sse2 - (alien:sap-alien scp (* unix:sigcontext)))) + (format t "Current HW x87 modes: ~32,'0b~%" current-x87-modes) + (format t "Current HW sse2 modes: ~32,'0b~%" current-sse2-modes) + (format t "sigcontext x87: ~32,'0b~%" sigcontext-x87-modes) + (format t "sigcontext sse2: ~32,'0b~%" sigcontext-sse2-modes)
(multiple-value-bind (fop operands) (let ((sym (find-symbol "GET-FP-OPERANDS" "VM"))) @@ -515,38 +520,47 @@ ;; ;; Clear out the status for any enabled traps. If we don't ;; then when we return, the exception gets signaled again. - #+nil + ;;#+nil (let* ((trap-bit (third (assoc code +fpe-code-info-alist+))) - (current-x87-modes (vm::x87-floating-point-modes)) - (current-sse2-modes (vm::sse2-floating-point-modes)) (new-x87-modes - (dpb (logandc2 (ldb float-exceptions-byte current-sse2-modes) - trap-bit) - float-exceptions-byte current-sse2-modes)) + (logandc2 current-x87-modes trap-bit)) (new-sse2-modes - (dpb (logandc2 (ldb float-exceptions-byte current-x87-modes) - trap-bit) - float-exceptions-byte current-x87-modes))) + (logandc2 current-sse2-modes trap-bit))) + (format t "***Cleanup***~%") (format t "Trap bit: ~D~%" trap-bit) (format t "Current modes: ~32,'0b~%" (vm::floating-point-modes)) - (format t "Current x87 modes: ~32,'0b~%" current-x87-modes) - (format t "Current sse2 modes: ~32,'0b~%" current-sse2-modes) - (format t "Setting sse2 modes to: ~32,'0b~%" new-x87-modes) - (format t "Setting x87 modes to: ~32,'0b~%" new-sse2-modes) + (format t "Current HW x87 modes: ~32,'0b~%" current-x87-modes) + (format t "Current HW sse2 modes: ~32,'0b~%" current-sse2-modes) + (format t "New x87 modes: ~32,'0b~%" new-x87-modes) + (format t "New sse2 modes: ~32,'0b~%" new-sse2-modes) (ignore-errors - (setf (vm::sse2-floating-point-modes) new-sse2-modes) - (setf (vm::x87-floating-point-modes) new-x87-modes)) + (format t "Setting new sse2 modes~%") + (let ((new-context (logandc2 sigcontext-sse2-modes trap-bit))) + (format t "New sse2 sigcontext: ~32,'0b~%" new-context) + (setf (vm::sse2-floating-point-modes) new-sse2-modes) + (%set-sigcontext-floating-point-modes-sse2 + (alien:sap-alien scp (* unix:sigcontext)) + new-context))) + (ignore-errors + (format t "Setting new x87 modes~%") + (let ((new-context (logandc2 sigcontext-x87-modes trap-bit))) + (format t "New x87 sigcontext: ~32,'0b~%" new-context) + (setf (vm::x87-floating-point-modes) new-x87-modes) + (%set-sigcontext-floating-point-modes-x87 + (alien:sap-alien scp (* unix:sigcontext)) + new-context)))
(format t "new x87 modes: ~32,'0b~%" (vm::x87-floating-point-modes)) (format t "new sse2 modes: ~32,'0b~%" (vm::sse2-floating-point-modes))) + #+nil (let* ((trap-bit (third (assoc code +fpe-code-info-alist+))) (x87-modes (sigcontext-floating-point-modes-x87 (alien:sap-alien scp (* unix:sigcontext)))) (sse2-modes (sigcontext-floating-point-modes-sse2 (alien:sap-alien scp (* unix:sigcontext))))) (format t "Trap bit: ~D~%" trap-bit) - (format t "New sigcontext x87: ~32,'0b~%" (logandc2 x87-modes trap-bit)) - (format t "New sigcontext sse2: ~32,'0b~%" (logandc2 sse2-modes trap-bit)) + (format t "New sigcontext x87: ~32,'0b~%" (logandc2 x87-modes trap-bit)) + (format t "New sigcontext sse2: ~32,'0b~%" (logandc2 sse2-modes trap-bit)) (%set-sigcontext-floating-point-modes-x87 (alien:sap-alien scp (* unix:sigcontext)) (logandc2 x87-modes trap-bit))
===================================== src/lisp/elf.c ===================================== @@ -18,6 +18,7 @@ #include <fcntl.h> #include <sys/types.h> #include <unistd.h> +#include <limits.h>
#include "os.h" #include "core.h"
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/f0bd9f3e8ce398b2e5719c8...