Steel Bank Common Lisp

failed AVER (ZEROP (HASH-TABLE-COUNT (SB-FASL::FASL-OUTPUT-PATCH-TABLE SB-FASL:FASL-OUTPUT))) on COMPILE-FILE

Reported by fizzies on 2010-01-07
24
This bug affects 4 people
Affects Status Importance Assigned to Milestone
SBCL
High
Unassigned

Bug Description

;; The sbcl version is: SBCL 1.0.29.11.debian

;; The value of *features*

;; CL-USER> *features*

;; (:SB-BSD-SOCKETS-ADDRINFO :ASDF :CLC-OS-DEBIAN :COMMON-LISP-CONTROLLER
;; :SB-FUTEX :SB-THREAD :ANSI-CL :COMMON-LISP :SBCL :SB-DOC :SB-TEST :SB-LDB
;; :SB-PACKAGE-LOCKS :SB-UNICODE :SB-EVAL :SB-SOURCE-LOCATIONS
;; :IEEE-FLOATING-POINT :X86 :UNIX :ELF :LINUX :LARGEFILE :GENCGC
;; :STACK-GROWS-DOWNWARD-NOT-UPWARD :C-STACK-IS-CONTROL-STACK
;; :COMPARE-AND-SWAP-VOPS :UNWIND-TO-FRAME-AND-CALL-VOP :RAW-INSTANCE-INIT-VOPS
;; :STACK-ALLOCATABLE-CLOSURES :ALIEN-CALLBACKS :CYCLE-COUNTER :LINKAGE-TABLE
;; :OS-PROVIDES-DLOPEN :OS-PROVIDES-PUTWC :OS-PROVIDES-SUSECONDS-T)

;; The output from the command line of "uname -a" is:
;; Linux meyers-laptop 2.6.31-16-generic-pae #53-Ubuntu SMP Tue Dec 8 05:20:21 UTC 2009 i686 GNU/Linux

;; input to all-caps-no-vowel-fix
;; are lists like: (JJ ABC 4)
;; (RB XYZ 3) (VBZ XC/Z 4)
;; When the second item in the list meets a test,
;; the first item in the list should be changed to
;; NNP
;; For example:
;; CL-USER> (all-caps-no-vowels-fix '(JJ ABC 4))
;; NIL
;; CL-USER> (all-caps-no-vowels-fix '(RB XYZ 3))
;; (NNP XYZ 3)
;; CL-USER> (all-caps-no-vowels-fix '(VBZ XC/Z 4))
;; (NNP XC/Z 4)
;; CL-USER>
;; [Note the above uses lisp in SLIME, but the same thing
;; happens if I fire up lisp using sbcl from the shell]
;; There are two versions of this function below. The first version
;; is commented out, but works fine in all respects (if the commenting
;; is removed). The second version causes an error when it is compiled
;; using the "compile-file" command. It can be interpretted at the command
;; line just fine. It seems that using the function "every" to apply
;; a lambda expression to a string causes compile error, but mapping a
;; function defined using "defun" does not.

;; The error I get looks like this:

;; debugger invoked on a SB-INT:BUG in thread #<THREAD "initial thread" RUNNING {AA5E639}>:
;; failed AVER:
;; (ZEROP (HASH-TABLE-COUNT (FASL-OUTPUT-PATCH-TABLE FASL-OUTPUT)))
;; This is probably a bug in SBCL itself. (Alternatively, SBCL might have been
;; corrupted by bad user code, e.g. by an undefined Lisp operation like
;; (FMAKUNBOUND 'COMPILE), or by stray pointers from alien code or from unsafe
;; Lisp code; or there might be a bug in the OS or hardware that SBCL is running
;; on.) If it seems to be a bug in SBCL itself, the maintainers would like to
;; know about it. Bug reports are welcome on the SBCL mailing lists, which you
;; can find at <http://sbcl.sourceforge.net/>.

(defvar *language* 'english)

(defvar *unit-punctuation* '(|$| |%| |#| US$ C$ A$ $A AU$ FFr ))

(defun char2 (string index)
  (and (< index (length string))
       (char string index)))

(defun alpha-symbol (symbol)
  (and (symbolp symbol)
  (alpha-char-p (char2 (symbol-name symbol) 0))))

(defun punctuation-pos (pos)
  (or (member pos '(pos pu hyph ls lst su))
      (and (not (alpha-symbol pos))
    (not (member pos *unit-punctuation*)))
      (member pos '(rm rs)) ;; disfluency punctuation
      (and (eq pos 'ip)
    (eq *language* 'english))
      ;; ip is disfluency punctuation for english
      ;; and a clausal category for chinese
      ))

(defun name-character (char)
  (or (and (upper-case-p char)
    (not (member char (list #\A #\E #\I #\O #\U))))
      (member char (list #\. #\- #\/
    ))
      )
  )

;; (defun all-caps-no-vowels-fix (S)
;; (when (and (not (member (car S) '(NN NNS NNP NNPS UH LS SYM)))
;; (not (punctuation-pos (car S)))
;; (symbolp (second S))
;; (some #'upper-case-p
;; (symbol-name (second S)))
;; (every #'name-character (symbol-name (second S)))
;; )
;; (cons 'nnp (cdr S)))
;; )

(defun all-caps-no-vowels-fix (S)
  (when (and (not (member (car S) '(NN NNS NNP NNPS UH LS SYM)))
      (not (punctuation-pos (car S)))
      (symbolp (second S))
      (some #'upper-case-p
     (symbol-name (second S)))
      (every #'(lambda (char)
   (or (and (upper-case-p char)
     (not (member char (list #\A #\E #\I #\O #\U))))
       (member char (list #\. #\- #\/
             ))
       )
   )
      (symbol-name (second S)))
      )
    (cons 'nnp (cdr S)))
  )

fizzies <email address hidden> writes:

 status confirmed
 important high
 tag compiler
 done

> ;; The sbcl version is: SBCL 1.0.29.11.debian

Confirmed in sbcl 1.0.34. Compiling a file containing

  (defun all-caps-no-vowels-fix (S)
    (when (and (some #'upper-case-p (symbol-name (second S)))
               (every #'(lambda (char) (upper-case-p char))
                      (symbol-name (second S))))
      (cons 'nnp (cdr S))))

is sufficient to trigger the bug.

Christophe

Changed in sbcl:
status: New → Confirmed
Changed in sbcl:
importance: Undecided → High
status: Confirmed → Triaged

Reduced to

(defun all-caps-no-vowels-fix (S)
    (and (some #'upper-case-p S)
            (every #'(lambda (char) (upper-case-p char))
                      S)))

The weirdness is that it works when replacing AND with OR.

The bug itself is that UPPER-CASE-P entry is not dumped:

(maphash #'(lambda (k v) (print k) (print v)) (sb-fasl::fasl-output-patch-table (sb-debug:arg 0)))

#S(SB-C::ENTRY-INFO
   :CLOSURE-TN NIL
   :OFFSET NIL
   :NAME UPPER-CASE-P
   :ARGUMENTS NIL
   :TYPE FUNCTION
   :INFO NIL)

NIL((44 . 6))

Does anybody have an idea why AND -> OR replacement hides the bug?

Roman Marynchak <email address hidden> writes:

> Reduced to
>
> (defun all-caps-no-vowels-fix (S)
> (and (some #'upper-case-p S)
> (every #'(lambda (char) (upper-case-p char))
> S)))
>
> The weirdness is that it works when replacing AND with OR.
>
> The bug itself is that UPPER-CASE-P entry is not dumped:
>
> Does anybody have an idea why AND -> OR replacement hides the bug?

Well, your ALL-CAPS-NO-VOWELS function seems to be an REALLY-ALL-CAPS
function (you're calling upper-case-p twice)

Speculating, probably the OR variant is sufficiently smart to know that
if not (some #'upper-case-p s) -- the only case where the second
condition is checked -- then (every #'upper-case-p s) cannot possibly be
true.

Christophe

summary: - compile error when "every" applies lambda expression
+ failed AVER (ZEROP (HASH-TABLE-COUNT (SB-FASL::FASL-OUTPUT-PATCH-TABLE
+ SB-FASL:FASL-OUTPUT))) on COMPILE-FILE
Nikodemus Siivola (nikodemus) wrote :

Further reduction of the test case:

(defun foocaps (s)
  (let ((p1 #'upper-case-p))
    (funcall
     (lambda (g)
       (funcall p1 g))))
  (let ((p2 #'(lambda (char) (upper-case-p char))))
    (funcall p2 s)))

Paul Khuong (pvk) wrote :

What happens is that (funcall (lambda (g) ...)) is marked as an error combination, so the reference to upper-case-p is dead. However, we need (lambda (g) ...) to call it and get an arg count error at runtime… but we know that code to be dead, and badness ensues (in this case, the reference to upper-case-p is never patched in). Maybe :error combination should change their FUN field to call into a dummy function?

Paul Khuong (pvk) wrote :

So far, the simplest way to make error handling more robust that I see is to do like the patch does, and the same for hairy lambdas.

Paul Khuong (pvk) on 2013-05-18
Changed in sbcl:
status: Triaged → Fix Committed
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.

Duplicates of this bug

Other bug subscribers