Failed AVER in subtypep

Bug #1916233 reported by Paul F. Dietz
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Fix Released
Undecided
Unassigned

Bug Description

(subtypep '(cons (or (simple-array ratio) simple-array) nil) nil)

==>

failed AVER: (NOT (EQ SB-KERNEL::TYPE2 SB-KERNEL:*WILD-TYPE*))
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/>.
   [Condition of type SB-INT:BUG]

Restarts:
 0: [RETRY] Retry SLIME REPL evaluation request.
 1: [*ABORT] Return to SLIME's top level.
 2: [REMOVE-FD-HANDLER] Remove #<SB-IMPL::HANDLER INPUT on descriptor 4: #<FUNCTION (LABELS SWANK/SBCL::RUN :IN SWANK/BACKEND:ADD-FD-HANDLER) {104571A4DB}>>
 3: [ABORT] Exit debugger, returning to top level.

Backtrace:
  0: (SB-KERNEL::NAMED-COMPLEX-SUBTYPEP-ARG2-TYPE-METHOD #<SB-KERNEL:NUMERIC-TYPE RATIONAL> #<SB-KERNEL:NAMED-TYPE *>)
  1: (SB-KERNEL:CSUBTYPEP #<SB-KERNEL:NUMERIC-TYPE RATIONAL> #<SB-KERNEL:NAMED-TYPE *>)
  2: (SB-KERNEL::HIERARCHICAL-INTERSECTION2 #<SB-KERNEL:NUMERIC-TYPE RATIONAL> #<SB-KERNEL:NAMED-TYPE *>)
  3: (SB-KERNEL::%TYPE-INTERSECTION2 #<SB-KERNEL:NAMED-TYPE *> #<SB-KERNEL:NUMERIC-TYPE RATIONAL>)
  4: (SB-KERNEL:TYPE-INTERSECTION2 #<SB-KERNEL:NAMED-TYPE *> #<SB-KERNEL:NUMERIC-TYPE RATIONAL>)
  5: (SB-KERNEL::INTERSECTION-COMPLEX-=-TYPE-METHOD #<SB-KERNEL:NAMED-TYPE *> #<SB-KERNEL:INTERSECTION-TYPE RATIO>)
  6: (SB-KERNEL::INVOKE-COMPLEX-=-OTHER-METHOD #<SB-KERNEL:INTERSECTION-TYPE RATIO> #<SB-KERNEL:NAMED-TYPE *>)
  7: (SB-KERNEL:TYPE= #<SB-KERNEL:INTERSECTION-TYPE RATIO> #<SB-KERNEL:NAMED-TYPE *>)
  8: (SB-KERNEL::UNITE-ARRAY-TYPES-ELEMENT-TYPES #<SB-KERNEL:ARRAY-TYPE (SIMPLE-ARRAY RATIO)> #<SB-KERNEL:ARRAY-TYPE SIMPLE-ARRAY>)
  9: (SB-KERNEL::ARRAY-SIMPLE-UNION2-TYPE-METHOD #<SB-KERNEL:ARRAY-TYPE (SIMPLE-ARRAY RATIO)> #<SB-KERNEL:ARRAY-TYPE SIMPLE-ARRAY>)
 10: (SB-KERNEL::%TYPE-UNION2 #<SB-KERNEL:ARRAY-TYPE (SIMPLE-ARRAY RATIO)> #<SB-KERNEL:ARRAY-TYPE SIMPLE-ARRAY>)
 11: (SB-KERNEL::TYPE-UNION2 #<SB-KERNEL:ARRAY-TYPE (SIMPLE-ARRAY RATIO)> #<SB-KERNEL:ARRAY-TYPE SIMPLE-ARRAY>)
 12: (SB-KERNEL::SIMPLIFY-UNIONS (#<SB-KERNEL:ARRAY-TYPE (SIMPLE-ARRAY RATIO)> #<SB-KERNEL:ARRAY-TYPE SIMPLE-ARRAY>))
 13: (SB-KERNEL::%TYPE-UNION (#<SB-KERNEL:ARRAY-TYPE (SIMPLE-ARRAY RATIO)> #<SB-KERNEL:ARRAY-TYPE SIMPLE-ARRAY>))
 14: (SB-KERNEL::PARSE-<OR> #S(SB-KERNEL::TYPE-CONTEXT :SPEC (CONS (OR # SIMPLE-ARRAY) NIL) :PROTO-CLASSOID NIL :CACHEABLE T) (OR (SIMPLE-ARRAY RATIO) SIMPLE-ARRAY))
 15: (SB-KERNEL::%PARSE-TYPE (OR (SIMPLE-ARRAY RATIO) SIMPLE-ARRAY) #S(SB-KERNEL::TYPE-CONTEXT :SPEC (CONS (OR # SIMPLE-ARRAY) NIL) :PROTO-CLASSOID NIL :CACHEABLE T))
 16: (SB-KERNEL::BASIC-PARSE-TYPESPEC (OR (SIMPLE-ARRAY RATIO) SIMPLE-ARRAY) #S(SB-KERNEL::TYPE-CONTEXT :SPEC (CONS (OR # SIMPLE-ARRAY) NIL) :PROTO-CLASSOID NIL :CACHEABLE T))
 17: (SB-KERNEL:SPECIFIER-TYPE (OR (SIMPLE-ARRAY RATIO) SIMPLE-ARRAY) #S(SB-KERNEL::TYPE-CONTEXT :SPEC (CONS (OR # SIMPLE-ARRAY) NIL) :PROTO-CLASSOID NIL :CACHEABLE T) NIL)
 18: (SB-KERNEL::PARSE-<CONS> #S(SB-KERNEL::TYPE-CONTEXT :SPEC (CONS (OR # SIMPLE-ARRAY) NIL) :PROTO-CLASSOID NIL :CACHEABLE T) (CONS (OR (SIMPLE-ARRAY RATIO) SIMPLE-ARRAY) NIL))
 19: (SB-KERNEL::%PARSE-TYPE (CONS (OR (SIMPLE-ARRAY RATIO) SIMPLE-ARRAY) NIL) #S(SB-KERNEL::TYPE-CONTEXT :SPEC (CONS (OR # SIMPLE-ARRAY) NIL) :PROTO-CLASSOID NIL :CACHEABLE T))
 20: (SB-KERNEL::BASIC-PARSE-TYPESPEC (CONS (OR (SIMPLE-ARRAY RATIO) SIMPLE-ARRAY) NIL) #S(SB-KERNEL::TYPE-CONTEXT :SPEC (CONS (OR # SIMPLE-ARRAY) NIL) :PROTO-CLASSOID NIL :CACHEABLE T))
 21: (SB-KERNEL:SPECIFIER-TYPE (CONS (OR (SIMPLE-ARRAY RATIO) SIMPLE-ARRAY) NIL) NIL NIL)
 22: (SUBTYPEP (CONS (OR (SIMPLE-ARRAY RATIO) SIMPLE-ARRAY) NIL) NIL #<unused argument>)

Revision history for this message
Paul F. Dietz (paul-f-dietz) wrote :

This bug was found by a property based tester of subtypep in ansi-test. To run this:

1) Get ansi-test from https://github.com/pfdietz/ansi-test
2) In the root directory of that checked out repo, start sbcl and load enough of the tests:

    (load "run.lsp")
    (load "auxilliary/types-aux.lsp")
    (load "auxilliary/random-aux.lsp")
    (load "random/random-types.lsp")

3) In the package CL-TEST, execute test-mutated-types

    (in-package :cl-test)
    (test-mutated-types 10000 10 :reps 2)

If the result is nonempty, it will be a list of type pairs on which a property failed.
Simplify the pairs

    (mapcar #'prune-type-pair *)

4) Additional testing can be done with test-types and test-type-triples. The latter has its own pruner, prune-type-triple.

5) If you run this long enough sbcl bogs down, probably because some internal cache of types has filled up. There should be some way of flushing this cache, or it should be flushed automatically when it gets too full.

Revision history for this message
Tomas Hlavaty (tomas-hlavaty) wrote : Re: [Bug 1916233] Re: Failed AVER in subtypep

On Fri 19 Feb 2021 at 13:17, "Paul F. Dietz" <email address hidden> wrote:
> To run this:
>
> 1) Get ansi-test from https://github.com/pfdietz/ansi-test
> 2) In the root directory of that checked out repo, start sbcl and load enough of the tests:
>
> (load "run.lsp")

cd /tmp
rm -rfv ansi-test
git clone https://github.com/pfdietz/ansi-test
cd ansi-test
nix-shell --pure -p sbcl
sbcl
(load "run.lsp")

; caught ERROR:
; READ error during COMPILE-FILE:
;
; Package QL does not exist.
;
; Line: 28, Column: 17, File-Position: 834
;
; Stream: #<SB-INT:FORM-TRACKING-STREAM for "file /tmp/ansi-test/random/mutate.lsp" {1002A150D3}>
;
; compilation unit aborted
; caught 1 fatal ERROR condition
; caught 1 ERROR condition
While evaluating the form starting at line 7, column 0
  of #P"/tmp/ansi-test/run.lsp":

debugger invoked on a SB-INT:SIMPLE-FILE-ERROR in thread
#<THREAD "main thread" RUNNING {10005184C3}>:
  Couldn't load #P"/tmp/ansi-test/random/mutate.fasl": file does not exist.

Revision history for this message
Paul F. Dietz (paul-f-dietz) wrote :

Arg, my .sbclrc

Revision history for this message
Paul F. Dietz (paul-f-dietz) wrote :

That should be fixed.

Revision history for this message
Paul F. Dietz (paul-f-dietz) wrote :

Another example:

 (subtypep '(or (array ratio) sequence) t) ==> same error

Revision history for this message
Tomas Hlavaty (tomas-hlavaty) wrote :

On Fri 19 Feb 2021 at 14:51, "Paul F. Dietz" <email address hidden> wrote:
> That should be fixed.

(load "run.lsp") works now, thanks

(load "auxilliary/types-aux.lsp")
(load "auxilliary/random-aux.lsp")

should be auxiliary

and then:

* (in-package :cl-test)
#<PACKAGE "CL-TEST">
* (test-mutated-types 10000 10 :reps 2)
; in: TEST-MUTATED-TYPES 10000
; (CL-TEST::TEST-MUTATED-TYPES 10000 10 :REPS 2)
;
; caught STYLE-WARNING:
; undefined function: CL-TEST::TEST-MUTATED-TYPES
;
; compilation unit finished
; Undefined function:
; TEST-MUTATED-TYPES
; caught 1 STYLE-WARNING condition

debugger invoked on a UNDEFINED-FUNCTION in thread
#<THREAD "main thread" RUNNING {10005184C3}>:
  The function CL-TEST::TEST-MUTATED-TYPES is undefined.

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

restarts (invokable by number or by possibly-abbreviated name):
  0: [CONTINUE ] Retry calling TEST-MUTATED-TYPES.
  1: [USE-VALUE ] Call specified function.
  2: [RETURN-VALUE ] Return specified values.
  3: [RETURN-NOTHING] Return zero values.
  4: [ABORT ] Exit debugger, returning to top level.

("undefined function" 10000 10 :REPS 2)
0]

Revision history for this message
Paul F. Dietz (paul-f-dietz) wrote :

Sorry, wrong name. test-random-mutated-types (same arguments)

Revision history for this message
Christophe Rhodes (csr21-cantab) wrote :

Thanks. Pushed a fix for this as 101e631a9202e327b68b763c64188f5a4538352a. I ran 10000 of each of the 10-sized random tests that I could find, with no failures; that's not at all to say that there remain no problems.

Changed in sbcl:
status: New → 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.