* bug fix: using RESTRICT-COMPILER-POLICY with DEBUG 3 could cause
PROGV miscompilation. (reported by Matthias Benkard, patch by Juho
Snellman)
+ * bug fix: on x86 and x86-64 backtraces were sometimes truncated
+ after alien stack frames.
changes in sbcl-1.0.21 relative to 1.0.20:
* new feature: the compiler is able to track the effective type of a
((not (frame-p frame)))
(setf (frame-number frame) number)))
+(defun find-saved-frame-down (fp up-frame)
+ (multiple-value-bind (saved-fp saved-pc) (sb!c:find-saved-fp-and-pc fp)
+ (when saved-fp
+ (compute-calling-frame (descriptor-sap saved-fp) saved-pc up-frame))))
+
;;; Return the frame immediately below FRAME on the stack; or when
;;; FRAME is the bottom of the stack, return NIL.
(defun frame-down (frame)
(when (control-stack-pointer-valid-p fp)
#!+(or x86 x86-64)
(multiple-value-bind (ok ra ofp) (x86-call-context fp)
- (and ok
- (compute-calling-frame ofp ra frame)))
+ (if ok
+ (compute-calling-frame ofp ra frame)
+ (find-saved-frame-down fp frame)))
#!-(or x86 x86-64)
(compute-calling-frame
#!-alpha
`(lambda (function ,@names)
(alien-funcall (deref function) ,@names))))
+;;; A per-thread list of frame pointer, program counter conses.
+(defvar *saved-fp-and-pcs* ())
+
+#!+:c-stack-is-control-stack
+(declaim (inline invoke-with-saved-fp-and-pc))
+#!+:c-stack-is-control-stack
+(defun invoke-with-saved-fp-and-pc (fn)
+ (let* ((fp-and-pc (multiple-value-bind (fp pc)
+ (%caller-frame-and-pc)
+ (cons fp pc)))
+ (*saved-fp-and-pcs* (cons fp-and-pc *saved-fp-and-pcs*)))
+ (declare (truly-dynamic-extent fp-and-pc *saved-fp-and-pcs*))
+ (funcall fn)))
+
+(defun find-saved-fp-and-pc (fp)
+ (dolist (x *saved-fp-and-pcs*)
+ (when (#!+:stack-grows-downward-not-upward
+ sap>
+ #!-:stack-grows-downward-not-upward
+ sap<
+ (int-sap (get-lisp-obj-address (car x))) fp)
+ (return (values (car x) (cdr x))))))
+
(deftransform alien-funcall ((function &rest args) * * :important t)
(let ((type (lvar-type function)))
(unless (alien-type-type-p type)
`(multiple-value-bind ,(temps) ,body
(values ,@(results)))))
(setf body `(naturalize ,body ',return-type)))
+ ;; Remember this frame to make sure that we can get back
+ ;; to it later regardless of how the foreign stack looks
+ ;; like.
+ #!+:c-stack-is-control-stack
+ (setf body `(invoke-with-saved-fp-and-pc (lambda () ,body)))
(/noshow "returning from DEFTRANSFORM ALIEN-FUNCALL" (params) body)
`(lambda (function ,@(params))
,body)))))))