The value NIL is not of type SB-KERNEL:CTYPE when binding TYPE (in IR1)

Bug #1728074 reported by Paul F. Dietz on 2017-10-27
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
High
Unassigned

Bug Description

The random tester isn't finished yet, it seems.

(defun foo ()
  (tagbody
     (complex
      (dotimes (iv2 0 0)
        (loop for lv4 below 1
           count (oddp
                  (multiple-value-prog1 (progv nil nil (go 0))
                    0
                    (catch 'ct5 (go tag1))))))
      0)
   tag1)
  0)

==>

The value
  NIL
is not of type
  SB-KERNEL:CTYPE
when binding TYPE
   [Condition of type TYPE-ERROR]

Restarts:
 0: [ABORT] Exit debugger, returning to top level.

Backtrace:
  0: (SB-KERNEL:CTYPEP 0 NIL) [external]
  1: ((SB-C:DEFTRANSFORM LOGTEST) #<SB-C::COMBINATION :FUN #<SB-C::REF :LEAF #<SB-C::GLOBAL-VAR :%SOURCE-NAME LOGTEST :TYPE #1=#<SB-KERNEL:FUN-TYPE #> :DEFINED-TYPE #1# :WHERE-FROM :DECLARED :KIND :GLOBAL..
  2: (SB-C::IR1-TRANSFORM #<SB-C::COMBINATION :FUN #<SB-C::REF :LEAF #<SB-C::GLOBAL-VAR :%SOURCE-NAME LOGTEST :TYPE #1=#<SB-KERNEL:FUN-TYPE #> :DEFINED-TYPE #1# :WHERE-FROM :DECLARED :KIND :GLOBAL-FUNCTIO..
  3: (SB-C::IR1-OPTIMIZE-COMBINATION #<SB-C::COMBINATION :FUN #<SB-C::REF :LEAF #<SB-C::GLOBAL-VAR :%SOURCE-NAME LOGTEST :TYPE #1=#<SB-KERNEL:FUN-TYPE #> :DEFINED-TYPE #1# :WHERE-FROM :DECLARED :KIND :GLO..
  4: (SB-C::IR1-OPTIMIZE-BLOCK #<SB-C::CBLOCK 78 :START c1 {10051789E3}>)
  5: (SB-C::IR1-OPTIMIZE #<SB-C:COMPONENT :NAME (FLET "CLEANUP-FUN-6" :IN FOO) {1005180873}> NIL)
  6: (SB-C::IR1-OPTIMIZE-UNTIL-DONE #<SB-C:COMPONENT :NAME (FLET "CLEANUP-FUN-6" :IN FOO) {1005180873}>)
  7: (SB-C::IR1-PHASES #<SB-C:COMPONENT :NAME (FLET "CLEANUP-FUN-6" :IN FOO) {1005180873}>)

Paul F. Dietz (paul-f-dietz) wrote :

That test is actually defective (I broke it when I simplified it); there was supposed to be a 0 tag after tag1. It still fails like that though.

Paul F. Dietz (paul-f-dietz) wrote :

Simplified:

(defun foo ()
  (dotimes (iv2 0 0)
    (loop for lv4 below 1
       count (oddp
              (multiple-value-prog1 (progv nil nil (return nil))
                0
                (catch 'ct5 (return nil)))))))

Paul F. Dietz (paul-f-dietz) wrote :

Simplified more:

(defun foo ()
  (block nil
    (oddp
     (multiple-value-prog1 (progv nil nil (return))
       (catch 'ct5 (return))))))

Stas Boukarev (stassats) wrote :

Will be fixed after the freeze.

Changed in sbcl:
assignee: nobody → Stas Boukarev (stassats)
status: New → Triaged
importance: Undecided → High
Stas Boukarev (stassats) wrote :

In 39122eaee21ac78bbfe33b3e933dd23cbdaf9a93

Changed in sbcl:
status: Triaged → Fix Committed
assignee: Stas Boukarev (stassats) → nobody
Douglas Katzman (dougk) wrote :

new failure as a result of that commit.

(declaim (inline to-boolean))
(defun to-boolean (x) (/= x 0))

(declaim (inline foo))
(defun foo (storage key converter)
  (labels ((value (entry)
             (funcall converter (ash entry -17)))
           (insert (start key new)
             (when (baz)
               (return-from insert (value (aref storage start))))
             (let ((entry (aref storage start)))
               (let* ((okey (logand entry #xf00))
                      (ostart (logand okey #xf)))
                 (unless (= ostart start)
                   (insert ostart okey entry)))))
           (probe (index)
             (let ((entry (aref storage index)))
               (when (= key (logand #xf00 entry))
                 (value entry)))))
    (declare (inline value))
    (probe (logand key #xf))))

(defun %access-cache (cache key) (foo cache key #'to-boolean))

#<THREAD "main thread" RUNNING {10019C0083}>:
  The value
    NIL
  is not of type
    SB-C::NODE

Changed in sbcl:
status: Fix Committed → In Progress
Douglas Katzman (dougk) on 2017-11-01
Changed in sbcl:
assignee: nobody → Stas Boukarev (stassats)
Douglas Katzman (dougk) wrote :

Problem started earlier than that commit. I'll re-close and open a different bug.

Changed in sbcl:
status: In Progress → Fix Committed
Stas Boukarev (stassats) on 2017-11-02
Changed in sbcl:
assignee: Stas Boukarev (stassats) → nobody
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers