DELETE-PACKAGE or MAKE-PACKAGE do not work correctly with LOAD in fasls

Bug #2000004 reported by Charles
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Fix Released
Undecided
Charles

Bug Description

The following bug was reported on sbcl-bugs (unmangled here):

Consider the sequence of operations defined by FOO:

(in-package :cl-user)
(defun foo ()
  (let ((package (find-package :bar)))
    (if package
        (progn
          (print (list 'package-exists package))
          (describe package)
          (print (list 'deleting-package package)) (delete-package (find-package :bar))
          (print (list 'package-has-been-deleted (find-package :bar))))
        (progn
          (print (list 'package-does-not-exist package)))))
  (print (list 'creating-package-using-make-package))
  (make-package "BAR" :use ())
  (let ((package (find-package :bar)))
    (print (list 'package-has-been-created package))
    (describe package)
    (print (list 'interning-two-symbols-now package))
    (eval (read-from-string
           "(progn (defun bar::a ()) (defun bar::b ()))"))))

And a file tmp.lisp with only the single line:
(foo)

Then, consider the following sequence of operations at the REPL:

CL-USER> (if (find-package "BAR") (delete-package "BAR"))
T
CL-USER> (compile-file "~/ram-disk/tmp.lisp")
=snip=

CL-USER> (load "~/ram-disk/tmp.fasl")
(PACKAGE-DOES-NOT-EXIST NIL)
(CREATING-PACKAGE-USING-MAKE-PACKAGE)
(PACKAGE-HAS-BEEN-CREATED #<PACKAGE "BAR">)
#<PACKAGE "BAR">
[package] 0 internal symbols.
(INTERNING-TWO-SYMBOLS-NOW #<PACKAGE "BAR">)
T
CL-USER> (load "~/ram-disk/tmp.fasl")
(PACKAGE-EXISTS #<PACKAGE "BAR">)
#<PACKAGE "BAR">
[package] 2 internal symbols.
(DELETING-PACKAGE #<PACKAGE "BAR">)
(PACKAGE-HAS-BEEN-DELETED NIL)
(CREATING-PACKAGE-USING-MAKE-PACKAGE)
(PACKAGE-HAS-BEEN-CREATED #<PACKAGE "BAR">)
#<PACKAGE "BAR">
[package] 2 internal symbols.
(INTERNING-TWO-SYMBOLS-NOW #<PACKAGE "BAR">)
WARNING: redefining BAR::A in DEFUN
WARNING: redefining BAR::B in DEFUN
T

The issue is in what is happening in the last (LOAD "~/ram-disk/tmp.fasl"). The package BAR has two internal symbols inspite of being freshly created. Note that according to the sequence of operations in FOO, the two symbols should only exist after (INTERNING-TWO-SYMBOLS-NOW #<PACKAGE "BAR">) but not before it. Indeed, loading the lisp file rather than the fasl results in expected behavior:
CL-USER> (load "~/ram-disk/tmp.lisp")

(PACKAGE-EXISTS #<PACKAGE "BAR">)
#<PACKAGE "BAR">
[package] 2 internal symbols.
(DELETING-PACKAGE #<PACKAGE "BAR">)
(PACKAGE-HAS-BEEN-DELETED NIL)
(CREATING-PACKAGE-USING-MAKE-PACKAGE)
(PACKAGE-HAS-BEEN-CREATED #<PACKAGE "BAR">)
#<PACKAGE "BAR">
[package] 0 internal symbols.
(INTERNING-TWO-SYMBOLS-NOW #<PACKAGE "BAR">)
T

I'm able to reproduce this with both SBCL 2.2.5 and 2.2.6.
- Shubhamkar

Charles (karlosz)
Changed in sbcl:
status: New → Confirmed
assignee: nobody → Charles (karlosz)
Charles (karlosz)
Changed in sbcl:
status: Confirmed → Fix Committed
Charles (karlosz)
Changed in sbcl:
status: Fix Committed → Confirmed
Charles (karlosz)
Changed in sbcl:
status: Confirmed → Fix Committed
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.