Steel Bank Common Lisp

generic-foo assembly routines obscure backtraces

Reported by Ph. Marek on 2011-06-21
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
SBCL
Low
Unassigned

Bug Description

(declaim (optimize (debug 3) (safety 3) (speed 0)))
(defun 3n+1/2 (n)
  (if (= 1 n)
        nil
        (if (evenp n)
          (floor n 2)
          (1+ (* 3 n)))))
(3n+1/2 nil)

gives a stack dump like this:

debugger invoked on a SIMPLE-TYPE-ERROR in thread #<THREAD "initial thread" RUNNING {1002BCACD1}>: Argument X is not a NUMBER: NIL

Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [ABORT] Exit debugger, returning to top level.

(SB-KERNEL:TWO-ARG-= NIL 1)
0] backtrace

0: (SB-KERNEL:TWO-ARG-= NIL 1)
1: ("no debug information for frame")
2: (SB-INT:SIMPLE-EVAL-IN-LEXENV (|3N+1/2| NIL) #<NULL-LEXENV>)
3: (SB-EXT:INTERACTIVE-EVAL (|3N+1/2| NIL) :EVAL NIL)
4: (SB-IMPL::REPL-FUN NIL)
5: ((LAMBDA NIL))
6: (SB-IMPL::%WITH-REBOUND-IO-SYNTAX #<CLOSURE (LAMBDA NIL) {10034BA559}>)
7: (SB-IMPL::TOPLEVEL-REPL NIL)
8: (SB-IMPL::TOPLEVEL-INIT)
9: ((LABELS SB-IMPL::RESTART-LISP))

Now the problem is that the function where "=" is called (3n+1/2) is not listed - all that I see is
    1: ("no debug information for frame")

Paul Khuong (pvk) on 2011-06-25
Changed in sbcl:
status: New → Confirmed
importance: Undecided → Low
summary: - Stack frames hidden in backtrace
+ generic-foo assembly routines obscure backtraces
description: updated
Paul Khuong (pvk) wrote :

The out of line assembly routine looks like (note the lack of any frame pointer setup):

(define-assembly-routine (generic-=
                          (:return-style :none))
                         ((:arg x (descriptor-reg any-reg) rdx-offset)
                          (:arg y (descriptor-reg any-reg) rdi-offset)

                          (:temp rcx unsigned-reg rcx-offset))
  (inst mov rcx x)
  (inst or rcx y)
  (inst test rcx fixnum-tag-mask)
  (inst jmp :nz DO-STATIC-FUN)

  ;; Both fixnums
  (inst cmp x y)
  (inst ret)

  DO-STATIC-FUN
  (inst sub rsp-tn (fixnumize 3))
  (inst mov (make-ea :qword :base rsp-tn
                     :disp (frame-byte-offset
                            (+ sp->fp-offset
                               -3
                               ocfp-save-offset)))
        rbp-tn)
  (inst lea rbp-tn (make-ea :qword :base rsp-tn
                            :disp (frame-byte-offset
                                   (+ sp->fp-offset
                                      -3
                                      ocfp-save-offset))))

  (inst mov rcx (fixnumize 2))
  (inst call (make-ea :qword
                      :disp (+ nil-value (static-fun-offset 'two-arg-=))))
  (load-symbol y t)
  (inst cmp x y)
  (inst ret))

Paul Khuong (pvk) on 2013-04-21
tags: added: arch-x86 easy runtime x86-64
Changed in sbcl:
assignee: nobody → Paul Khuong (pvk)
status: Confirmed → In Progress
Paul Khuong (pvk) wrote :

I'll commit this patch after the freeze.

Paul Khuong (pvk) on 2013-05-18
Changed in sbcl:
status: In Progress → Fix Committed
assignee: Paul Khuong (pvk) → nobody
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers