Steel Bank Common Lisp

Structure class alias badness

Reported by Alex Plotnick on 2012-02-25
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Medium
Unassigned

Bug Description

Somewhere along the way, structure classes (or their layouts) are being conflated with their names. This becomes evident if you alias a structure class and then remove that alias. This doesn't happen with classes defined with DEFCLASS, although there is some related funniness I'm still trying to track down in that case.

E.g.: given a file "struct-bug.lisp" containg the following forms:

    (defstruct record)
    (setf (find-class 'alias) (find-class 'record))
    (setf (find-class 'alias) nil)

% sbcl
This is SBCL 1.0.55.1-6548750, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
* (load (compile-file "struct-bug" :verbose nil :print nil))

T
* (compile-file "struct-bug" :verbose nil :print nil)

; file: /home/alex/build/sbcl/struct-bug.lisp
; in: DEFSTRUCT RECORD
; (DEFSTRUCT RECORD)
; --> PROGN DEFUN PROGN EVAL-WHEN
; ==>
; (SB-IMPL::%DEFUN 'MAKE-RECORD
; (SB-INT:NAMED-LAMBDA MAKE-RECORD
; (&KEY)
; (BLOCK MAKE-RECORD
; (SB-KERNEL::%MAKE-STRUCTURE-INSTANCE-MACRO
; #<SB-KERNEL:DEFSTRUCT-DESCRIPTION RECORD> 'NIL)))
; NIL 'NIL (SB-C:SOURCE-LOCATION))
;
; caught ERROR:
; dumping anonymous layout: #<SB-KERNEL:LAYOUT for #<SB-KERNEL:STRUCTURE-CLASSOID anonymous {1004487763}> {10044877E3}>
;
; compilation unit finished
; caught 1 ERROR condition

#P"/home/alex/build/sbcl/struct-bug.fasl"
T
T
* (load *)

debugger invoked on a SB-INT:COMPILED-PROGRAM-ERROR:
  Execution of a form compiled with errors.
Form:
  (%DEFUN 'MAKE-RECORD
        (NAMED-LAMBDA MAKE-RECORD
            (&KEY)
          (BLOCK MAKE-RECORD
            (%MAKE-STRUCTURE-INSTANCE-MACRO #<DEFSTRUCT-DESCRIPTION RECORD>
                                            'NIL)))
        NIL 'NIL (SOURCE-LOCATION))
Compile-time error:
  dumping anonymous layout: #<SB-KERNEL:LAYOUT for #<SB-KERNEL:STRUCTURE-CLASSOID anonymous {1004487763}> {10044877E3}>
restarts (invokable by number or by possibly-abbreviated name):
  0: [ABORT] Exit debugger, returning to top level.

(SB-FASL::LOAD-FASL-GROUP
 #<SB-SYS:FD-STREAM for "file /home/alex/build/sbcl/struct-bug.fasl"
   {1004628E93}>)
0]

Alex Plotnick (shrike) on 2012-02-25
description: updated
Nikodemus Siivola (nikodemus) wrote :

The same issue seems to plague standard-classes as well -- you just don't notice it so easily:

CL-USER> (defclass foo () ())
#<STANDARD-CLASS FOO>
CL-USER> (sb-impl::find-classoid 'foo)
#<SB-KERNEL:STANDARD-CLASSOID FOO>
CL-USER> (setf (find-class 'bar) **)
#<STANDARD-CLASS FOO>
CL-USER> (setf (find-class 'bar) nil)
NIL
CL-USER> (sb-impl::find-classoid 'foo)
#<SB-KERNEL:STANDARD-CLASSOID anonymous {1004E42423}>

Changed in sbcl:
assignee: nobody → Nikodemus Siivola (nikodemus)
status: New → In Progress
importance: Undecided → Medium
Nikodemus Siivola (nikodemus) wrote :

commit 38329dab20845da6964ffc2b03c6a0778c5498a1
Author: Nikodemus Siivola <email address hidden>
Date: Wed Mar 28 16:46:04 2012 +0300

    more conservative classoid-name clearing

      (SETF (FIND-CLASS X) NIL) should not clear the classoid name if X is
      not the proper name of the class.

      lp#941102

Changed in sbcl:
assignee: Nikodemus Siivola (nikodemus) → nobody
status: In Progress → Fix Committed
Nikodemus Siivola (nikodemus) wrote :

in SBCL 1.0.57

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