1.0.16.29: workaround for bug 419
[sbcl.git] / BUGS
1 REPORTING BUGS
2
3 Bugs can be reported on the help mailing list
4   sbcl-help@lists.sourceforge.net
5 or on the development mailing list
6   sbcl-devel@lists.sourceforge.net
7
8 Please include enough information in a bug report that someone reading
9 it can reproduce the problem, i.e. don't write
10      Subject: apparent bug in PRINT-OBJECT (or *PRINT-LENGTH*?)
11      PRINT-OBJECT doesn't seem to work with *PRINT-LENGTH*. Is this a bug?
12 but instead
13      Subject: apparent bug in PRINT-OBJECT (or *PRINT-LENGTH*?)
14      In sbcl-1.2.3 running under OpenBSD 4.5 on my Alpha box, when
15      I compile and load the file
16        (DEFSTRUCT (FOO (:PRINT-OBJECT (LAMBDA (X Y)
17                                         (LET ((*PRINT-LENGTH* 4))
18                                           (PRINT X Y)))))
19          X Y)
20      then at the command line type
21        (MAKE-FOO)
22      the program loops endlessly instead of printing the object.
23
24
25 NOTES:
26
27 There is also some information on bugs in the manual page and
28 in the TODO file. Eventually more such information may move here.
29
30 The gaps in the number sequence belong to old bug descriptions which
31 have gone away (typically because they were fixed, but sometimes for
32 other reasons, e.g. because they were moved elsewhere).
33
34
35 2:
36   DEFSTRUCT almost certainly should overwrite the old LAYOUT information
37   instead of just punting when a contradictory structure definition
38   is loaded. As it is, if you redefine DEFSTRUCTs in a way which 
39   changes their layout, you probably have to rebuild your entire
40   program, even if you know or guess enough about the internals of
41   SBCL to wager that this (undefined in ANSI) operation would be safe.
42
43 3: "type checking of structure slots"
44   a:
45   ANSI specifies that a type mismatch in a structure slot
46   initialization value should not cause a warning.
47 WORKAROUND:
48   This one might not be fixed for a while because while we're big
49   believers in ANSI compatibility and all, (1) there's no obvious
50   simple way to do it (short of disabling all warnings for type
51   mismatches everywhere), and (2) there's a good portable
52   workaround, and (3) by their own reasoning, it looks as though
53   ANSI may have gotten it wrong. ANSI justifies this specification
54   by saying 
55     The restriction against issuing a warning for type mismatches
56     between a slot-initform and the corresponding slot's :TYPE
57     option is necessary because a slot-initform must be specified
58     in order to specify slot options; in some cases, no suitable
59     default may exist.
60   However, in SBCL (as in CMU CL or, for that matter, any compiler
61   which really understands Common Lisp types) a suitable default
62   does exist, in all cases, because the compiler understands the
63   concept of functions which never return (i.e. has return type NIL).
64   Thus, as a portable workaround, you can use a call to some
65   known-never-to-return function as the default. E.g.
66     (DEFSTRUCT FOO
67       (BAR (ERROR "missing :BAR argument")
68            :TYPE SOME-TYPE-TOO-HAIRY-TO-CONSTRUCT-AN-INSTANCE-OF))
69   or 
70     (DECLAIM (FTYPE (FUNCTION () NIL) MISSING-ARG))
71     (DEFUN REQUIRED-ARG () ; workaround for SBCL non-ANSI slot init typing
72       (ERROR "missing required argument")) 
73     (DEFSTRUCT FOO
74       (BAR (REQUIRED-ARG) :TYPE TRICKY-TYPE-OF-SOME-SORT)
75       (BLETCH (REQUIRED-ARG) :TYPE TRICKY-TYPE-OF-SOME-SORT)
76       (N-REFS-SO-FAR 0 :TYPE (INTEGER 0)))
77   Such code should compile without complaint and work correctly either
78   on SBCL or on any other completely compliant Common Lisp system.
79
80   b: &AUX argument in a boa-constructor without a default value means
81      "do not initilize this slot" and does not cause type error. But
82      an error may be signalled at read time and it would be good if
83      SBCL did it.
84
85   d: (fixed in 0.8.1.5)
86
87 33:
88   And as long as we're wishing, it would be awfully nice if INSPECT could
89   also report on closures, telling about the values of the bound variables.
90
91   Currently INSPECT and DESCRIBE do show the values, but showing the
92   names of the bindings would be even nicer.
93
94 35:
95   The compiler assumes that any time a function of declared FTYPE
96   doesn't signal an error, its arguments were of the declared type.
97   E.g. compiling and loading
98     (DECLAIM (OPTIMIZE (SAFETY 3)))
99     (DEFUN FACTORIAL (X) (GAMMA (1+ X)))
100     (DEFUN GAMMA (X) X)
101     (DECLAIM (FTYPE (FUNCTION (UNSIGNED-BYTE)) FACTORIAL))
102     (DEFUN FOO (X)
103       (COND ((> (FACTORIAL X) 1.0E6)
104              (FORMAT T "too big~%"))
105             ((INTEGERP X)
106              (FORMAT T "exactly ~S~%" (FACTORIAL X)))
107             (T
108              (FORMAT T "approximately ~S~%" (FACTORIAL X)))))
109   then executing
110     (FOO 1.5)
111   will cause the INTEGERP case to be selected, giving bogus output a la
112     exactly 2.5
113   This violates the "declarations are assertions" principle.
114   According to the ANSI spec, in the section "System Class FUNCTION",
115   this is a case of "lying to the compiler", but the lying is done
116   by the code which calls FACTORIAL with non-UNSIGNED-BYTE arguments,
117   not by the unexpectedly general definition of FACTORIAL. In any case,
118   "declarations are assertions" means that lying to the compiler should
119   cause an error to be signalled, and should not cause a bogus
120   result to be returned. Thus, the compiler should not assume
121   that arbitrary functions check their argument types. (It might
122   make sense to add another flag (CHECKED?) to DEFKNOWN to 
123   identify functions which *do* check their argument types.)
124   (Also, verify that the compiler handles declared function
125   return types as assertions.)
126
127 42:
128   The definitions of SIGCONTEXT-FLOAT-REGISTER and
129   %SET-SIGCONTEXT-FLOAT-REGISTER in x86-vm.lisp say they're not
130   supported on FreeBSD because the floating point state is not saved,
131   but at least as of FreeBSD 4.0, the floating point state *is* saved,
132   so they could be supported after all. Very likely 
133   SIGCONTEXT-FLOATING-POINT-MODES could now be supported, too.
134
135 61:
136   Compiling and loading
137     (DEFUN FAIL (X) (THROW 'FAIL-TAG X))
138     (FAIL 12)
139   then requesting a BACKTRACE at the debugger prompt gives no information
140   about where in the user program the problem occurred.
141
142   (this is apparently mostly fixed on the SPARC, PPC, and x86 architectures:
143   while giving the backtrace the non-x86 systems complains about "unknown
144   source location: using block start", but apart from that the
145   backtrace seems reasonable. On x86 this is masked by bug 353. See
146   tests/debug.impure.lisp for a test case)
147
148 64:
149   Using the pretty-printer from the command prompt gives funny
150   results, apparently because the pretty-printer doesn't know
151   about user's command input, including the user's carriage return
152   that the user, and therefore the pretty-printer thinks that
153   the new output block should start indented 2 or more characters
154   rightward of the correct location.
155
156 67:
157   As reported by Winton Davies on a CMU CL mailing list 2000-01-10,
158   and reported for SBCL by Martin Atzmueller 2000-10-20: (TRACE GETHASH)
159   crashes SBCL. In general tracing anything which is used in the 
160   implementation of TRACE is likely to have the same problem.
161
162 78:
163   ANSI says in one place that type declarations can be abbreviated even
164   when the type name is not a symbol, e.g.
165     (DECLAIM ((VECTOR T) *FOOVECTOR*))
166   SBCL doesn't support this. But ANSI says in another place that this
167   isn't allowed. So it's not clear this is a bug after all. (See the
168   e-mail on cmucl-help@cons.org on 2001-01-16 and 2001-01-17 from WHN
169   and Pierre Mai.)
170
171   (Actually this has changed changed since, and types as above are
172   now supported. This may be a bug.)
173
174 83:
175   RANDOM-INTEGER-EXTRA-BITS=10 may not be large enough for the RANDOM
176   RNG to be high quality near RANDOM-FIXNUM-MAX; it looks as though
177   the mean of the distribution can be systematically O(0.1%) wrong.
178   Just increasing R-I-E-B is probably not a good solution, since
179   it would decrease efficiency more than is probably necessary. Perhaps
180   using some sort of accept/reject method would be better.
181
182 85:
183   Internally the compiler sometimes evaluates
184     (sb-kernel:type/= (specifier-type '*) (specifier-type t))
185   (I stumbled across this when I added an
186     (assert (not (eq type1 *wild-type*)))
187   in the NAMED :SIMPLE-= type method.) '* isn't really a type, and
188   in a type context should probably be translated to T, and so it's
189   probably wrong to ask whether it's equal to the T type and then (using
190   the EQ type comparison in the NAMED :SIMPLE-= type method) return NIL.
191   (I haven't tried to investigate this bug enough to guess whether
192   there might be any user-level symptoms.)
193
194   In fact, the type system is likely to depend on this inequality not
195   holding... * is not equivalent to T in many cases, such as 
196     (VECTOR *) /= (VECTOR T).
197
198 98:
199   In sbcl-0.6.11.41 (and in all earlier SBCL, and in CMU
200   CL), out-of-line structure slot setters are horribly inefficient
201   whenever the type of the slot is declared, because out-of-line
202   structure slot setters are implemented as closures to save space,
203   so the compiler doesn't compile the type test into code, but
204   instead just saves the type in a lexical closure and interprets it
205   at runtime.
206     To exercise the problem, compile and load
207       (cl:in-package :cl-user)
208       (defstruct foo
209         (bar (error "missing") :type bar))
210       (defvar *foo*)
211       (defun wastrel1 (x)
212         (loop (setf (foo-bar *foo*) x)))
213       (defstruct bar)
214       (defvar *bar* (make-bar))
215       (defvar *foo* (make-foo :bar *bar*))
216       (defvar *setf-foo-bar* #'(setf foo-bar))
217       (defun wastrel2 (x)
218         (loop (funcall *setf-foo-bar* x *foo*)))
219   then run (WASTREL1 *BAR*) or (WASTREL2 *BAR*), hit Ctrl-C, and
220   use BACKTRACE, to see it's spending all essentially all its time
221   in %TYPEP and VALUES-SPECIFIER-TYPE and so forth.
222     One possible solution would be simply to give up on 
223   representing structure slot accessors as functions, and represent
224   them as macroexpansions instead. This can be inconvenient for users,
225   but it's not clear that it's worse than trying to help by expanding
226   into a horribly inefficient implementation.
227     As a workaround for the problem, #'(SETF FOO) expressions
228   can be replaced with (EFFICIENT-SETF-FUNCTION FOO), where
229 (defmacro efficient-setf-function (place-function-name)
230   (or #+sbcl (and (sb-int:info :function :accessor-for place-function-name)
231                   ;; a workaround for the problem, encouraging the
232                   ;; inline expansion of the structure accessor, so
233                   ;; that the compiler can optimize its type test
234                   (let ((new-value (gensym "NEW-VALUE-"))
235                         (structure-value (gensym "STRUCTURE-VALUE-")))
236                     `(lambda (,new-value ,structure-value)
237                        (setf (,place-function-name ,structure-value)
238                              ,new-value))))
239       ;; no problem, can just use the ordinary expansion
240       `(function (setf ,place-function-name))))
241
242 100:
243   There's apparently a bug in CEILING optimization which caused 
244   Douglas Crosher to patch the CMU CL version. Martin Atzmueller
245   applied the patches to SBCL and they didn't seem to cause problems
246   (as reported sbcl-devel 2001-05-04). However, since the patches
247   modify nontrivial code which was apparently written incorrectly
248   the first time around, until regression tests are written I'm not 
249   comfortable merging the patches in the CVS version of SBCL.
250
251 108:
252   ROOM issues:
253
254   a) ROOM works by walking over the heap linearly, instead of
255      following the object graph. Hence, it report garbage objects that
256      are unreachable. (Maybe this is a feature and not a bug?)
257
258   b) ROOM uses MAP-ALLOCATED-OBJECTS to walk the heap, which doesn't
259      check all pointers as well as it should, and can hence become
260      confused, leading to aver failures. As of 1.0.13.21 these (the
261      SAP= aver in particular) should be mostly under control, but push
262      ROOM hard enough and it still might croak.
263
264 117:
265   When the compiler inline expands functions, it may be that different
266   kinds of return values are generated from different code branches.
267   E.g. an inline expansion of POSITION generates integer results 
268   from one branch, and NIL results from another. When that inline
269   expansion is used in a context where only one of those results
270   is acceptable, e.g.
271     (defun foo (x)
272       (aref *a1* (position x *a2*)))
273   and the compiler can't prove that the unacceptable branch is 
274   never taken, then bogus type mismatch warnings can be generated.
275   If you need to suppress the type mismatch warnings, you can
276   suppress the inline expansion,
277     (defun foo (x)
278       #+sbcl (declare (notinline position)) ; to suppress bug 117 bogowarnings
279       (aref *a1* (position x *a2*)))
280   or, sometimes, suppress them by declaring the result to be of an
281   appropriate type,
282     (defun foo (x)
283       (aref *a1* (the integer (position x *a2*))))
284
285   This is not a new compiler problem in 0.7.0, but the new compiler
286   transforms for FIND, POSITION, FIND-IF, and POSITION-IF make it 
287   more conspicuous. If you don't need performance from these functions,
288   and the bogus warnings are a nuisance for you, you can return to
289   your pre-0.7.0 state of grace with
290     #+sbcl (declaim (notinline find position find-if position-if)) ; bug 117..
291
292   (see also bug 279)
293
294 124:
295    As of version 0.pre7.14, SBCL's implementation of MACROLET makes
296    the entire lexical environment at the point of MACROLET available
297    in the bodies of the macroexpander functions. In particular, it
298    allows the function bodies (which run at compile time) to try to
299    access lexical variables (which are only defined at runtime).
300    It doesn't even issue a warning, which is bad.
301
302    The SBCL behavior arguably conforms to the ANSI spec (since the
303    spec says that the behavior is undefined, ergo anything conforms).
304    However, it would be better to issue a compile-time error.
305    Unfortunately I (WHN) don't see any simple way to detect this
306    condition in order to issue such an error, so for the meantime
307    SBCL just does this weird broken "conforming" thing.
308
309    The ANSI standard says, in the definition of the special operator
310    MACROLET,
311        The macro-expansion functions defined by MACROLET are defined
312        in the lexical environment in which the MACROLET form appears.
313        Declarations and MACROLET and SYMBOL-MACROLET definitions affect
314        the local macro definitions in a MACROLET, but the consequences
315        are undefined if the local macro definitions reference any
316        local variable or function bindings that are visible in that
317        lexical environment.
318    Then it seems to contradict itself by giving the example
319         (defun foo (x flag)
320            (macrolet ((fudge (z)
321                          ;The parameters x and flag are not accessible
322                          ; at this point; a reference to flag would be to
323                          ; the global variable of that name.
324                          ` (if flag (* ,z ,z) ,z)))
325             ;The parameters x and flag are accessible here.
326              (+ x
327                 (fudge x)
328                 (fudge (+ x 1)))))
329    The comment "a reference to flag would be to the global variable
330    of the same name" sounds like good behavior for the system to have.
331    but actual specification quoted above says that the actual behavior
332    is undefined.
333
334    (Since 0.7.8.23 macroexpanders are defined in a restricted version
335    of the lexical environment, containing no lexical variables and
336    functions, which seems to conform to ANSI and CLtL2, but signalling
337    a STYLE-WARNING for references to variables similar to locals might
338    be a good thing.)
339
340 135:
341   Ideally, uninterning a symbol would allow it, and its associated
342   FDEFINITION and PROCLAIM data, to be reclaimed by the GC. However,
343   at least as of sbcl-0.7.0, this isn't the case. Information about
344   FDEFINITIONs and PROCLAIMed properties is stored in globaldb.lisp
345   essentially in ordinary (non-weak) hash tables keyed by symbols.
346   Thus, once a system has an entry in this system, it tends to live
347   forever, even when it is uninterned and all other references to it
348   are lost.
349
350 143:
351   (reported by Jesse Bouwman 2001-10-24 through the unfortunately
352   prominent SourceForge web/db bug tracking system, which is 
353   unfortunately not a reliable way to get a timely response from
354   the SBCL maintainers)
355       In the course of trying to build a test case for an 
356     application error, I encountered this behavior: 
357       If you start up sbcl, and then lay on CTRL-C for a 
358     minute or two, the lisp process will eventually say: 
359          %PRIMITIVE HALT called; the party is over. 
360     and throw you into the monitor. If I start up lisp, 
361     attach to the process with strace, and then do the same 
362     (abusive) thing, I get instead: 
363          access failure in heap page not marked as write-protected 
364     and the monitor again. I don't know enough to have the 
365     faintest idea of what is going on here. 
366       This is with sbcl 6.12, uname -a reports: 
367          Linux prep 2.2.19 #4 SMP Tue Apr 24 13:59:52 CDT 2001 i686 unknown 
368   I (WHN) have verified that the same thing occurs on sbcl-0.pre7.141
369   under OpenBSD 2.9 on my X86 laptop. Do be patient when you try it:
370   it took more than two minutes (but less than five) for me.
371
372 145:
373   a.
374   ANSI allows types `(COMPLEX ,FOO) to use very hairy values for
375   FOO, e.g. (COMPLEX (AND REAL (SATISFIES ODDP))). The old CMU CL
376   COMPLEX implementation didn't deal with this, and hasn't been
377   upgraded to do so. (This doesn't seem to be a high priority
378   conformance problem, since seems hard to construct useful code
379   where it matters.)
380
381   [ partially fixed by CSR in 0.8.17.17 because of a PFD ansi-tests
382     report that (COMPLEX RATIO) was failing; still failing on types of
383     the form (AND NUMBER (SATISFIES REALP) (SATISFIES ZEROP)). ]
384
385   b. (fixed in 0.8.3.43)
386
387 146:
388   Floating point errors are reported poorly. E.g. on x86 OpenBSD
389   with sbcl-0.7.1, 
390         * (expt 2.0 12777)
391         debugger invoked on condition of type SB-KERNEL:FLOATING-POINT-EXCEPTION:
392           An arithmetic error SB-KERNEL:FLOATING-POINT-EXCEPTION was signalled.
393         No traps are enabled? How can this be?
394   It should be possible to be much more specific (overflow, division
395   by zero, etc.) and of course the "How can this be?" should be fixable.
396
397   See also bugs #45.c and #183
398
399 162:
400   (reported by Robert E. Brown 2002-04-16) 
401   When a function is called with too few arguments, causing the
402   debugger to be entered, the uninitialized slots in the bad call frame 
403   seem to cause GCish problems, being interpreted as tagged data even
404   though they're not. In particular, executing ROOM in the
405   debugger at that point causes AVER failures:
406     * (machine-type)
407     "X86"
408     * (lisp-implementation-version)
409     "0.7.2.12"
410     * (typep 10)
411     ...
412     0] (room)
413     ...
414     failed AVER: "(SAP= CURRENT END)"
415   (Christophe Rhodes reports that this doesn't occur on the SPARC, which
416   isn't too surprising since there are many differences in stack
417   implementation and GC conservatism between the X86 and other ports.)
418
419   This is probably the same bug as 216
420
421 173:
422   The compiler sometimes tries to constant-fold expressions before
423   it checks to see whether they can be reached. This can lead to 
424   bogus warnings about errors in the constant folding, e.g. in code
425   like 
426     (WHEN X
427       (WRITE-STRING (> X 0) "+" "0"))
428   compiled in a context where the compiler can prove that X is NIL,
429   and the compiler complains that (> X 0) causes a type error because
430   NIL isn't a valid argument to #'>. Until sbcl-0.7.4.10 or so this
431   caused a full WARNING, which made the bug really annoying because then 
432   COMPILE and COMPILE-FILE returned FAILURE-P=T for perfectly legal
433   code. Since then the warning has been downgraded to STYLE-WARNING, 
434   so it's still a bug but at least it's a little less annoying.
435
436 183: "IEEE floating point issues"
437   Even where floating point handling is being dealt with relatively
438   well (as of sbcl-0.7.5, on sparc/sunos and alpha; see bug #146), the
439   accrued-exceptions and current-exceptions part of the fp control
440   word don't seem to bear much relation to reality. E.g. on
441   SPARC/SunOS:
442   * (/ 1.0 0.0)
443
444   debugger invoked on condition of type DIVISION-BY-ZERO:
445     arithmetic error DIVISION-BY-ZERO signalled
446   0] (sb-vm::get-floating-point-modes)
447
448   (:TRAPS (:OVERFLOW :INVALID :DIVIDE-BY-ZERO)
449           :ROUNDING-MODE :NEAREST
450           :CURRENT-EXCEPTIONS NIL
451           :ACCRUED-EXCEPTIONS (:INEXACT)
452           :FAST-MODE NIL)
453   0] abort
454   * (sb-vm::get-floating-point-modes)
455   (:TRAPS (:OVERFLOW :INVALID :DIVIDE-BY-ZERO)
456           :ROUNDING-MODE :NEAREST
457           :CURRENT-EXCEPTIONS (:INEXACT)
458           :ACCRUED-EXCEPTIONS (:INEXACT)
459           :FAST-MODE NIL)
460
461 188: "compiler performance fiasco involving type inference and UNION-TYPE"
462     (time (compile
463            nil
464            '(lambda ()
465              (declare (optimize (safety 3)))
466              (declare (optimize (compilation-speed 2)))
467              (declare (optimize (speed 1) (debug 1) (space 1)))
468              (let ((start 4))
469                (declare (type (integer 0) start))
470                (print (incf start 22))
471                (print (incf start 26))
472                (print (incf start 28)))
473              (let ((start 6))
474                (declare (type (integer 0) start))
475                (print (incf start 22))
476                (print (incf start 26)))
477              (let ((start 10))
478                (declare (type (integer 0) start))
479                (print (incf start 22))
480                (print (incf start 26))))))
481
482   [ Update: 1.0.14.36 improved this quite a bit (20-25%) by
483     eliminating useless work from PROPAGATE-FROM-SETS -- but as alluded
484     below, maybe we should be smarter about when to decide a derived
485     type is "good enough". ]
486
487   This example could be solved with clever enough constraint
488   propagation or with SSA, but consider
489
490     (let ((x 0))
491       (loop (incf x 2)))
492
493   The careful type of X is {2k} :-(. Is it really important to be
494   able to work with unions of many intervals?
495
496 191: "Miscellaneous PCL deficiencies"
497   (reported by Alexey Dejneka sbcl-devel 2002-08-04)
498   a. DEFCLASS does not inform the compiler about generated
499      functions. Compiling a file with
500        (DEFCLASS A-CLASS ()
501          ((A-CLASS-X)))
502        (DEFUN A-CLASS-X (A)
503          (WITH-SLOTS (A-CLASS-X) A
504            A-CLASS-X))
505      results in a STYLE-WARNING:
506        undefined-function 
507          SB-SLOT-ACCESSOR-NAME::|COMMON-LISP-USER A-CLASS-X slot READER|
508
509      APD's fix for this was checked in to sbcl-0.7.6.20, but Pierre
510      Mai points out that the declamation of functions is in fact
511      incorrect in some cases (most notably for structure
512      classes).  This means that at present erroneous attempts to use
513      WITH-SLOTS and the like on classes with metaclass STRUCTURE-CLASS
514      won't get the corresponding STYLE-WARNING.
515
516      [much later, in 2006-08] in fact it's no longer erroneous to use
517      WITH-SLOTS on structure-classes.  However, including :METACLASS
518      STRUCTURE-CLASS in the class definition gives a whole bunch of
519      function redefinition warnings, so we're still not good to close
520      this bug...
521
522   c. (fixed in 0.8.4.23)
523
524 201: "Incautious type inference from compound types"
525   a. (reported by APD sbcl-devel 2002-09-17)
526     (DEFUN FOO (X)
527       (LET ((Y (CAR (THE (CONS INTEGER *) X))))
528         (SETF (CAR X) NIL)
529         (FORMAT NIL "~S IS ~S, Y = ~S"
530                 (CAR X)
531                 (TYPECASE (CAR X)
532                   (INTEGER 'INTEGER)
533                   (T '(NOT INTEGER)))
534                 Y)))
535
536     (FOO ' (1 . 2)) => "NIL IS INTEGER, Y = 1"
537
538   b.
539     * (defun foo (x)
540         (declare (type (array * (4 4)) x))
541         (let ((y x))
542           (setq x (make-array '(4 4)))
543           (adjust-array y '(3 5))
544           (= (array-dimension y 0) (eval `(array-dimension ,y 0)))))
545     FOO
546     * (foo (make-array '(4 4) :adjustable t))
547     NIL
548
549 205: "environment issues in cross compiler"
550   (These bugs have no impact on user code, but should be fixed or
551   documented.)
552   a. Macroexpanders introduced with MACROLET are defined in the null
553      lexical environment.
554   b. The body of (EVAL-WHEN (:COMPILE-TOPLEVEL) ...) is evaluated in
555      the null lexical environment.
556   c. The cross-compiler cannot inline functions defined in a non-null
557      lexical environment.
558
559 206: ":SB-FLUID feature broken"
560   (reported by Antonio Martinez-Shotton sbcl-devel 2002-10-07)
561   Enabling :SB-FLUID in the target-features list in sbcl-0.7.8 breaks
562   the build.
563
564 207: "poorly distributed SXHASH results for compound data"
565   SBCL's SXHASH could probably try a little harder. ANSI: "the
566   intent is that an implementation should make a good-faith
567   effort to produce hash-codes that are well distributed
568   within the range of non-negative fixnums". But
569         (let ((hits (make-hash-table)))
570           (dotimes (i 16)
571             (dotimes (j 16)
572               (let* ((ij (cons i j))
573                      (newlist (push ij (gethash (sxhash ij) hits))))
574                 (when (cdr newlist)
575                   (format t "~&collision: ~S~%" newlist))))))
576   reports lots of collisions in sbcl-0.7.8. A stronger MIX function
577   would be an obvious way of fix. Maybe it would be acceptably efficient
578   to redo MIX using a lookup into a 256-entry s-box containing
579   29-bit pseudorandom numbers?
580
581 211: "keywords processing"
582   a. :ALLOW-OTHER-KEYS T should allow a function to receive an odd
583      number of keyword arguments.
584
585 212: "Sequence functions and circular arguments"
586   COERCE, MERGE and CONCATENATE go into an infinite loop when given
587   circular arguments; it would be good for the user if they could be
588   given an error instead (ANSI 17.1.1 allows this behaviour on the part
589   of the implementation, as conforming code cannot give non-proper
590   sequences to these functions.  MAP also has this problem (and
591   solution), though arguably the convenience of being able to do
592     (MAP 'LIST '+ FOO '#1=(1 . #1#))
593   might be classed as more important (though signalling an error when
594   all of the arguments are circular is probably desireable).
595
596 213: "Sequence functions and type checking"
597   b. MAP, when given a type argument that is SUBTYPEP LIST, does not
598      check that it will return a sequence of the given type.  Fixing
599      it along the same lines as the others (cf. work done around
600      sbcl-0.7.8.45) is possible, but doing so efficiently didn't look
601      entirely straightforward.
602   c. All of these functions will silently accept a type of the form
603        (CONS INTEGER *)
604      whether or not the return value is of this type.  This is
605      probably permitted by ANSI (see "Exceptional Situations" under
606      ANSI MAKE-SEQUENCE), but the DERIVE-TYPE mechanism does not
607      know about this escape clause, so code of the form
608        (INTEGERP (CAR (MAKE-SEQUENCE '(CONS INTEGER *) 2)))
609      can erroneously return T.
610
611 215: ":TEST-NOT handling by functions"
612   a. FIND and POSITION currently signal errors when given non-NIL for
613      both their :TEST and (deprecated) :TEST-NOT arguments, but by
614      ANSI 17.2 "the consequences are unspecified", which by ANSI 1.4.2
615      means that the effect is "unpredictable but harmless".  It's not
616      clear what that actually means; it may preclude conforming
617      implementations from signalling errors.
618   b. COUNT, REMOVE and the like give priority to a :TEST-NOT argument
619      when conflict occurs.  As a quality of implementation issue, it
620      might be preferable to treat :TEST and :TEST-NOT as being in some
621      sense the same &KEY, and effectively take the first test function in
622      the argument list.
623   c. Again, a quality of implementation issue: it would be good to issue a
624      STYLE-WARNING at compile-time for calls with :TEST-NOT, and a
625      WARNING for calls with both :TEST and :TEST-NOT; possibly this
626      latter should be WARNed about at execute-time too.
627
628 216: "debugger confused by frames with invalid number of arguments"
629   In sbcl-0.7.8.51, executing e.g. (VECTOR-PUSH-EXTEND T), BACKTRACE, Q
630   leaves the system confused, enough so that (QUIT) no longer works.
631   It's as though the process of working with the uninitialized slot in
632   the bad VECTOR-PUSH-EXTEND frame causes GC problems, though that may
633   not be the actual problem. (CMU CL 18c doesn't have problems with this.)
634
635   This is probably the same bug as 162
636
637 235: "type system and inline expansion"
638   a.
639   (declaim (ftype (function (cons) number) acc))
640   (declaim (inline acc))
641   (defun acc (c)
642     (the number (car c)))
643
644   (defun foo (x y)
645     (values (locally (declare (optimize (safety 0)))
646               (acc x))
647             (locally (declare (optimize (safety 3)))
648               (acc y))))
649
650   (foo '(nil) '(t)) => NIL, T.
651
652   As of 0.9.15.41 this seems to be due to ACC being inlined only once
653   inside FOO, which results in the second call reusing the FUNCTIONAL
654   resulting from the first -- which doesn't check the type.
655
656 237: "Environment arguments to type functions"
657   a. Functions SUBTYPEP, TYPEP, UPGRADED-ARRAY-ELEMENT-TYPE, and 
658      UPGRADED-COMPLEX-PART-TYPE now have an optional environment
659      argument, but they ignore it completely.  This is almost 
660      certainly not correct.
661   b. Also, the compiler's optimizers for TYPEP have not been informed
662      about the new argument; consequently, they will not transform
663      calls of the form (TYPEP 1 'INTEGER NIL), even though this is
664      just as optimizeable as (TYPEP 1 'INTEGER).
665
666 238: "REPL compiler overenthusiasm for CLOS code"
667   From the REPL,
668     * (defclass foo () ())
669     * (defmethod bar ((x foo) (foo foo)) (call-next-method))
670   causes approximately 100 lines of code deletion notes.  Some
671   discussion on this issue happened under the title 'Three "interesting"
672   bugs in PCL', resulting in a fix for this oververbosity from the
673   compiler proper; however, the problem persists in the interactor
674   because the notion of original source is not preserved: for the
675   compiler, the original source of the above expression is (DEFMETHOD
676   BAR ((X FOO) (FOO FOO)) (CALL-NEXT-METHOD)), while by the time the
677   compiler gets its hands on the code needing compilation from the REPL,
678   it has been macroexpanded several times.
679
680   A symptom of the same underlying problem, reported by Tony Martinez:
681     * (handler-case
682         (with-input-from-string (*query-io* "    no")
683           (yes-or-no-p))
684       (simple-type-error () 'error))
685     ; in: LAMBDA NIL
686     ;     (SB-KERNEL:FLOAT-WAIT)
687     ; 
688     ; note: deleting unreachable code
689     ; compilation unit finished
690     ;   printed 1 note
691
692 242: "WRITE-SEQUENCE suboptimality"
693   (observed from clx performance)
694   In sbcl-0.7.13, WRITE-SEQUENCE of a sequence of type 
695   (SIMPLE-ARRAY (UNSIGNED-BYTE 8) (*)) on a stream with element-type
696   (UNSIGNED-BYTE 8) will write to the stream one byte at a time,
697   rather than writing the sequence in one go, leading to severe
698   performance degradation.
699   As of sbcl-0.9.0.36, this is solved for fd-streams, so is less of a
700   problem in practice.  (Fully fixing this would require adding a
701   ansi-stream-n-bout slot and associated methods to write a byte
702   sequence to ansi-stream, similar to the existing ansi-stream-sout
703   slot/functions.)
704
705 243: "STYLE-WARNING overenthusiasm for unused variables"
706   (observed from clx compilation)
707   In sbcl-0.7.14, in the presence of the macros
708     (DEFMACRO FOO (X) `(BAR ,X))
709     (DEFMACRO BAR (X) (DECLARE (IGNORABLE X)) 'NIL)
710   somewhat surprising style warnings are emitted for
711     (COMPILE NIL '(LAMBDA (Y) (FOO Y))):
712   ; in: LAMBDA (Y)
713   ;     (LAMBDA (Y) (FOO Y))
714   ; 
715   ; caught STYLE-WARNING:
716   ;   The variable Y is defined but never used.
717
718 245: bugs in disassembler
719   b. On X86 operand size prefix is not recognized.
720
721 251:
722   (defun foo (&key (a :x))
723     (declare (fixnum a))
724     a)
725
726   does not cause a warning. (BTW: old SBCL issued a warning, but for a
727   function, which was never called!)
728
729 256:
730   Compiler does not emit warnings for
731
732   a. (lambda () (svref (make-array 8 :adjustable t) 1))
733
734   b. (fixed at some point before 1.0.4.10)
735
736   c. (lambda (x)
737        (declare (optimize (debug 0)))
738        (declare (type vector x))
739        (list (fill-pointer x)
740              (svref x 1)))
741
742 257:
743   Complex array type does not have corresponding type specifier.
744
745   This is a problem because the compiler emits optimization notes when
746   you use a non-simple array, and without a type specifier for hairy
747   array types, there's no good way to tell it you're doing it
748   intentionally so that it should shut up and just compile the code.
749
750   Another problem is confusing error message "asserted type ARRAY
751   conflicts with derived type (VALUES SIMPLE-VECTOR &OPTIONAL)" during
752   compiling (LAMBDA (V) (VALUES (SVREF V 0) (VECTOR-POP V))).
753
754   The last problem is that when type assertions are converted to type
755   checks, types are represented with type specifiers, so we could lose
756   complex attribute. (Now this is probably not important, because
757   currently checks for complex arrays seem to be performed by
758   callees.)
759
760 259:
761   (compile nil '(lambda () (aref (make-array 0) 0))) compiles without
762   warning.  Analogous cases with the index and length being equal and
763   greater than 0 are warned for; the problem here seems to be that the
764   type required for an array reference of this type is (INTEGER 0 (0))
765   which is canonicalized to NIL.
766
767 260:
768   a.
769   (let* ((s (gensym))
770          (t1 (specifier-type s)))
771     (eval `(defstruct ,s))
772     (type= t1 (specifier-type s)))
773   => NIL, NIL
774
775   (fixed in 0.8.1.24)
776
777   b. The same for CSUBTYPEP.
778
779 262: "yet another bug in inline expansion of local functions"
780   During inline expansion of a local function Python can try to
781   reference optimized away objects (functions, variables, CTRANs from
782   tags and blocks), which later may lead to problems. Some of the
783   cases are worked around by forbidding expansion in such cases, but
784   the better way would be to reimplement inline expansion by copying
785   IR1 structures.
786
787 266:
788   David Lichteblau provided (sbcl-devel 2003-06-01) a patch to fix
789   behaviour of streams with element-type (SIGNED-BYTE 8).  The patch
790   looks reasonable, if not obviously correct; however, it caused the
791   PPC/Linux port to segfault during warm-init while loading
792   src/pcl/std-class.fasl.  A workaround patch was made, but it would
793   be nice to understand why the first patch caused problems, and to
794   fix the cause if possible.
795
796 268: "wrong free declaration scope"
797   The following code must signal type error:
798
799     (locally (declare (optimize (safety 3)))
800       (flet ((foo (x &optional (y (car x)))
801                (declare (optimize (safety 0)))
802                (list x y)))
803         (funcall (eval #'foo) 1)))
804
805 270:
806   In the following function constraint propagator optimizes nothing:
807
808     (defun foo (x)
809       (declare (integer x))
810       (declare (optimize speed))
811       (typecase x
812         (fixnum "hala")
813         (fixnum "buba")
814         (bignum "hip")
815         (t "zuz")))
816
817 273:
818   Compilation of the following two forms causes "X is unbound" error:
819
820     (symbol-macrolet ((x pi))
821       (macrolet ((foo (y) (+ x y)))
822         (declaim (inline bar))
823         (defun bar (z)
824           (* z (foo 4)))))
825     (defun quux (z)
826       (bar z))
827
828   (See (COERCE (CDR X) 'FUNCTION) in IR1-CONVERT-INLINE-LAMBDA.)
829
830 274:
831   CLHS says that type declaration of a symbol macro should not affect
832   its expansion, but in SBCL it does. (If you like magic and want to
833   fix it, don't forget to change all uses of MACROEXPAND to
834   MACROEXPAND*.)
835
836 275:
837   The following code (taken from CLOCC) takes a lot of time to compile:
838
839     (defun foo (n)
840       (declare (type (integer 0 #.large-constant) n))
841       (expt 1/10 n))
842
843   (fixed in 0.8.2.51, but a test case would be good)
844
845 276:
846   b. The same as in a., but using MULTIPLE-VALUE-SETQ instead of SETQ.
847   c. (defvar *faa*)
848      (defmethod faa ((*faa* double-float))
849            (set '*faa* (when (< *faa* 0) (- *faa*)))
850            (1+ *faa*))
851      (faa 1d0) => type error
852
853 279: type propagation error -- correctly inferred type goes astray?
854   In sbcl-0.8.3 and sbcl-0.8.1.47, the warning
855        The binding of ABS-FOO is a (VALUES (INTEGER 0 0)
856        &OPTIONAL), not a (INTEGER 1 536870911)
857   is emitted when compiling this file:
858     (declaim (ftype (function ((integer 0 #.most-positive-fixnum))
859                               (integer #.most-negative-fixnum 0))
860                     foo))
861     (defun foo (x)
862       (- x))
863     (defun bar (x)
864       (let* (;; Uncomment this for a type mismatch warning indicating 
865              ;; that the type of (FOO X) is correctly understood.
866              #+nil (fs-foo (float-sign (foo x)))
867                    ;; Uncomment this for a type mismatch warning 
868                    ;; indicating that the type of (ABS (FOO X)) is
869                    ;; correctly understood.
870              #+nil (fs-abs-foo (float-sign (abs (foo x))))
871              ;; something wrong with this one though
872              (abs-foo (abs (foo x))))
873         (declare (type (integer 1 100) abs-foo))
874         (print abs-foo)))
875
876  (see also bug 117)
877
878 283: Thread safety: libc functions
879   There are places that we call unsafe-for-threading libc functions
880   that we should find alternatives for, or put locks around.  Known or
881   strongly suspected problems, as of 1.0.3.13: please update this
882   bug instead of creating new ones
883
884 284: Thread safety: special variables
885   There are lots of special variables in SBCL, and I feel sure that at
886   least some of them are indicative of potentially thread-unsafe 
887   parts of the system.  See doc/internals/notes/threading-specials
888
889 286: "recursive known functions"
890   Self-call recognition conflicts with known function
891   recognition. Currently cross compiler and target COMPILE do not
892   recognize recursion, and in target compiler it can be disabled. We
893   can always disable it for known functions with RECURSIVE attribute,
894   but there remains a possibility of a function with a
895   (tail)-recursive simplification pass and transforms/VOPs for base
896   cases.
897
898 288: fundamental cross-compilation issues (from old UGLINESS file)
899   Using host floating point numbers to represent target floating point
900   numbers, or host characters to represent target characters, is
901   theoretically shaky. (The characters are OK as long as the characters
902   are in the ANSI-guaranteed character set, though, so they aren't a
903   real problem as long as the sources don't need anything but that;
904   the floats are a real problem.)
905
906 289: "type checking and source-transforms"
907   a.
908     (block nil (let () (funcall #'+ (eval 'nil) (eval '1) (return :good))))
909   signals type error.
910
911   Our policy is to check argument types at the moment of a call. It
912   disagrees with ANSI, which says that type assertions are put
913   immediately onto argument expressions, but is easier to implement in
914   IR1 and is more compatible to type inference, inline expansion,
915   etc. IR1-transforms automatically keep this policy, but source
916   transforms for associative functions (such as +), being applied
917   during IR1-convertion, do not. It may be tolerable for direct calls
918   (+ x y z), but for (FUNCALL #'+ x y z) it is non-conformant.
919
920   b. Another aspect of this problem is efficiency. [x y + z +]
921   requires less registers than [x y z + +]. This transformation is
922   currently performed with source transforms, but it would be good to
923   also perform it in IR1 optimization phase.
924
925 290: Alpha floating point and denormalized traps
926   In SBCL 0.8.3.6x on the alpha, we work around what appears to be a
927   hardware or kernel deficiency: the status of the enable/disable
928   denormalized-float traps bit seems to be ambiguous; by the time we
929   get to os_restore_fp_control after a trap, denormalized traps seem
930   to be enabled.  Since we don't want a trap every time someone uses a
931   denormalized float, in general, we mask out that bit when we restore
932   the control word; however, this clobbers any change the user might
933   have made.
934
935 297:
936   LOOP with non-constant arithmetic step clauses suffers from overzealous
937   type constraint: code of the form 
938     (loop for d of-type double-float from 0d0 to 10d0 by x collect d)
939   compiles to a type restriction on X of (AND DOUBLE-FLOAT (REAL
940   (0))).  However, an integral value of X should be legal, because
941   successive adds of integers to double-floats produces double-floats,
942   so none of the type restrictions in the code is violated.
943
944 300: (reported by Peter Graves) Function PEEK-CHAR checks PEEK-TYPE
945   argument type only after having read a character. This is caused
946   with EXPLICIT-CHECK attribute in DEFKNOWN. The similar problem
947   exists with =, /=, <, >, <=, >=. They were fixed, but it is probably
948   less error prone to have EXPLICIT-CHECK be a local declaration,
949   being put into the definition, instead of an attribute being kept in
950   a separate file; maybe also put it into SB-EXT?
951
952 301: ARRAY-SIMPLE-=-TYPE-METHOD breaks on corner cases which can arise
953      in NOTE-ASSUMED-TYPES
954   In sbcl-0.8.7.32, compiling the file
955         (defun foo (x y)
956           (declare (type integer x))
957           (declare (type (vector (or hash-table bit)) y))
958           (bletch 2 y))
959         (defun bar (x y)
960           (declare (type integer x))
961           (declare (type (simple-array base (2)) y))
962           (bletch 1 y))
963   gives the error
964     failed AVER: "(NOT (AND (NOT EQUALP) CERTAINP))"
965
966 303: "nonlinear LVARs" (aka MISC.293)
967     (defun buu (x)
968       (multiple-value-call #'list
969         (block foo
970           (multiple-value-prog1
971               (eval '(values :a :b :c))
972             (catch 'bar
973               (if (> x 0)
974                   (return-from foo
975                     (eval `(if (> ,x 1)
976                                1
977                                (throw 'bar (values 3 4)))))))))))
978
979   (BUU 1) returns garbage.
980
981   The problem is that both EVALs sequentially write to the same LVAR.
982
983 306: "Imprecise unions of array types"
984
985   a. fixed in SBCL 0.9.15.48
986
987   b.(subtypep 
988      'array
989      `(or
990        ,@(loop for x across sb-vm:*specialized-array-element-type-properties*
991                collect `(array ,(sb-vm:saetp-specifier x)))))
992     => NIL, T (when it should be T, T)
993
994 309: "Dubious values for implementation limits"
995     (reported by Bruno Haible sbcl-devel "Incorrect value of
996     multiple-values-limit" 2004-04-19)
997   (values-list (make-list 1000000)), on x86/linux, signals a stack
998   exhaustion condition, despite MULTIPLE-VALUES-LIMIT being
999   significantly larger than 1000000.  There are probably similar
1000   dubious values for CALL-ARGUMENTS-LIMIT (see cmucl-help/cmucl-imp
1001   around the same time regarding a call to LIST on sparc with 1000
1002   arguments) and other implementation limit constants.
1003
1004 314: "LOOP :INITIALLY clauses and scope of initializers"
1005   reported by Bruno Haible sbcl-devel "various SBCL bugs" from CLISP
1006   test suite, originally by Thomas F. Burdick.
1007     ;; <http://www.lisp.org/HyperSpec/Body/sec_6-1-7-2.html>
1008     ;; According to the HyperSpec 6.1.2.1.4, in for-as-equals-then, var is
1009     ;; initialized to the result of evaluating form1.  6.1.7.2 says that
1010     ;; initially clauses are evaluated in the loop prologue, which precedes all
1011     ;; loop code except for the initial settings provided by with, for, or as.
1012     (loop :for x = 0 :then (1+ x) 
1013           :for y = (1+ x) :then (ash y 1)
1014           :for z :across #(1 3 9 27 81 243) 
1015           :for w = (+ x y z)
1016           :initially (assert (zerop x)) :initially (assert (= 2 w))
1017           :until (>= w 100) :collect w)
1018     Expected: (2 6 15 38)
1019     Got:      ERROR
1020
1021 318: "stack overflow in compiler warning with redefined class"
1022   reported by Bruno Haible sbcl-devel "various SBCL bugs" from CLISP
1023   test suite.
1024     (defstruct foo a)
1025     (setf (find-class 'foo) nil)
1026     (defstruct foo slot-1)
1027   This used to give a stack overflow from within the printer, which has
1028   been fixed as of 0.8.16.11. Current result:
1029     ; caught ERROR:
1030     ;   can't compile TYPEP of anonymous or undefined class:
1031     ;     #<SB-KERNEL:STRUCTURE-CLASSOID FOO>
1032     ...
1033     debugger invoked on a TYPE-ERROR in thread 19973:
1034       The value NIL is not of type FUNCTION.
1035
1036   CSR notes: it's not really clear what it should give: is (SETF FIND-CLASS)
1037     meant to be enough to delete structure classes from the system?
1038
1039 319: "backquote with comma inside array"
1040   reported by Bruno Haible sbcl-devel "various SBCL bugs" from CLISP
1041   test suite.
1042     (read-from-string "`#1A(1 2 ,(+ 2 2) 4)") 
1043   gives
1044     #(1 2 ((SB-IMPL::|,|) + 2 2) 4)
1045   which probably isn't intentional.
1046
1047 324: "STREAMs and :ELEMENT-TYPE with large bytesize"
1048   In theory, (open foo :element-type '(unsigned-byte <x>)) should work
1049   for all positive integral <x>.  At present, it only works for <x> up
1050   to about 1024 (and similarly for signed-byte), so
1051     (open "/dev/zero" :element-type '(unsigned-byte 1025))
1052   gives an error in sbcl-0.8.10.
1053
1054 325: "CLOSE :ABORT T on supeseding streams"
1055   Closing a stream opened with :IF-EXISTS :SUPERSEDE with :ABORT T leaves no
1056   file on disk, even if one existed before opening.
1057
1058   The illegality of this is not crystal clear, as the ANSI dictionary
1059   entry for CLOSE says that when :ABORT is T superseded files are not
1060   superseded (ie. the original should be restored), whereas the OPEN
1061   entry says about :IF-EXISTS :SUPERSEDE "If possible, the
1062   implementation should not destroy the old file until the new stream
1063   is closed." -- implying that even though undesirable, early deletion
1064   is legal. Restoring the original would none the less be the polite
1065   thing to do.
1066
1067 326: "*PRINT-CIRCLE* crosstalk between streams"
1068   In sbcl-0.8.10.48 it's possible for *PRINT-CIRCLE* references to be
1069   mixed between streams when output operations are intermingled closely
1070   enough (as by doing output on S2 from within (PRINT-OBJECT X S1) in the
1071   test case below), so that e.g. the references #2# appears on a stream
1072   with no preceding #2= on that stream to define it (because the #2= was
1073   sent to another stream).
1074     (cl:in-package :cl-user)
1075     (defstruct foo index)
1076     (defparameter *foo* (make-foo :index 4))
1077     (defstruct bar)
1078     (defparameter *bar* (make-bar))
1079     (defparameter *tangle* (list *foo* *bar* *foo*))
1080     (defmethod print-object ((foo foo) stream)
1081       (let ((index (foo-index foo)))
1082         (format *trace-output*
1083             "~&-$- emitting FOO ~D, ambient *BAR*=~S~%"
1084             index *bar*)
1085         (format stream "[FOO ~D]" index))
1086       foo)
1087     (let ((tsos (make-string-output-stream))
1088           (ssos (make-string-output-stream)))
1089       (let ((*print-circle* t)
1090             (*trace-output* tsos)
1091             (*standard-output* ssos))
1092         (prin1 *tangle* *standard-output*))
1093       (let ((string (get-output-stream-string ssos)))
1094         (unless (string= string "(#1=[FOO 4] #S(BAR) #1#)")
1095           ;; In sbcl-0.8.10.48 STRING was "(#1=[FOO 4] #2# #1#)".:-(
1096           (error "oops: ~S" string)))))
1097   It might be straightforward to fix this by turning the
1098   *CIRCULARITY-HASH-TABLE* and *CIRCULARITY-COUNTER* variables into
1099   per-stream slots, but (1) it would probably be sort of messy faking
1100   up the special variable binding semantics using UNWIND-PROTECT and
1101   (2) it might be sort of a pain to test that no other bugs had been
1102   introduced. 
1103
1104 328: "Profiling generic functions", transplanted from #241
1105   (from tonyms on #lisp IRC 2003-02-25)
1106   In sbcl-0.7.12.55, typing
1107     (defclass foo () ((bar :accessor foo-bar)))
1108     (profile foo-bar)
1109     (unintern 'foo-bar)
1110     (defclass foo () ((bar :accessor foo-bar)))
1111   gives the error message
1112     "#:FOO-BAR already names an ordinary function or a macro."
1113
1114   Problem: when a generic function is profiled, it appears as an ordinary
1115   function to PCL. (Remembering the uninterned accessor is OK, as the
1116   redefinition must be able to remove old accessors from their generic
1117   functions.)
1118
1119 329: "Sequential class redefinition"
1120   reported by Bruno Haible:
1121    (defclass reactor () ((max-temp :initform 10000000)))
1122    (defvar *r1* (make-instance 'reactor))
1123    (defvar *r2* (make-instance 'reactor))
1124    (slot-value *r1* 'max-temp)
1125    (slot-value *r2* 'max-temp)
1126    (defclass reactor () ((uptime :initform 0)))
1127    (slot-value *r1* 'uptime)
1128    (defclass reactor () ((uptime :initform 0) (max-temp :initform 10000)))
1129    (slot-value *r1* 'max-temp) ; => 10000
1130    (slot-value *r2* 'max-temp) ; => 10000000 oops...
1131
1132   Possible solution: 
1133    The method effective when the wrapper is obsoleted can be saved
1134      in the wrapper, and then to update the instance just run through
1135      all the old wrappers in order from oldest to newest.
1136
1137 332: "fasl stack inconsistency in structure redefinition"
1138   (reported by Tim Daly Jr sbcl-devel 2004-05-06)
1139   Even though structure redefinition is undefined by the standard, the
1140   following behaviour is suboptimal: running
1141     (defun stimulate-sbcl ()
1142       (let ((filename (format nil "/tmp/~A.lisp" (gensym))))
1143         ;;create a file which redefines a structure incompatibly
1144         (with-open-file (f filename :direction :output :if-exists :supersede)
1145           (print '(defstruct astruct foo) f)
1146           (print '(defstruct astruct foo bar) f))
1147         ;;compile and load the file, then invoke the continue restart on
1148         ;;the structure redefinition error
1149         (handler-bind ((error (lambda (c) (continue c))))
1150           (load (compile-file filename)))))
1151     (stimulate-sbcl)
1152   and choosing the CONTINUE restart yields the message
1153     debugger invoked on a SB-INT:BUG in thread 27726:
1154       fasl stack not empty when it should be
1155
1156 336: "slot-definitions must retain the generic functions of accessors"
1157   reported by Tony Martinez:
1158     (defclass foo () ((bar :reader foo-bar)))
1159     (defun foo-bar (x) x)
1160     (defclass foo () ((bar :reader get-bar))) ; => error, should work
1161
1162   Note: just punting the accessor removal if the fdefinition
1163   is not a generic function is not enough:
1164
1165    (defclass foo () ((bar :reader foo-bar)))
1166    (defvar *reader* #'foo-bar)
1167    (defun foo-bar (x) x)
1168    (defclass foo () ((bar :initform 'ok :reader get-bar)))
1169    (funcall *reader* (make-instance 'foo)) ; should be an error, since
1170                                            ; the method must be removed
1171                                            ; by the class redefinition
1172
1173   Fixing this should also fix a subset of #328 -- update the
1174   description with a new test-case then.
1175
1176 339: "DEFINE-METHOD-COMBINATION bugs"
1177   (reported by Bruno Haible via the clisp test suite)
1178
1179   a. Syntax checking laxity (should produce errors):
1180      i. (define-method-combination foo :documentation :operator)
1181     ii. (define-method-combination foo :documentation nil)
1182    iii. (define-method-combination foo nil)
1183     iv. (define-method-combination foo nil nil
1184          (:arguments order &aux &key))
1185      v. (define-method-combination foo nil nil (:arguments &whole))
1186     vi. (define-method-combination foo nil nil (:generic-function))
1187    vii. (define-method-combination foo nil nil (:generic-function bar baz))
1188   viii. (define-method-combination foo nil nil (:generic-function (bar)))
1189     ix. (define-method-combination foo nil ((3)))
1190      x. (define-method-combination foo nil ((a)))
1191
1192   b. define-method-combination arguments lambda list badness
1193      i. &aux args are currently unsupported;
1194     ii. default values of &optional and &key arguments are ignored;
1195    iii. supplied-p variables for &optional and &key arguments are not
1196         bound.
1197
1198   c. (fixed in sbcl-0.9.15.15)
1199
1200 344: more (?) ROOM T problems (possibly part of bug 108)
1201   In sbcl-0.8.12.51, and off and on leading up to it, the
1202   SB!VM:MEMORY-USAGE operations in ROOM T caused 
1203         unhandled condition (of type SB-INT:BUG):
1204             failed AVER: "(SAP= CURRENT END)"
1205   Several clever people have taken a shot at this without fixing
1206   it; this time around (before sbcl-0.8.13 release) I (WHN) just
1207   commented out the SB!VM:MEMORY-USAGE calls until someone figures
1208   out how to make them work reliably with the rest of the GC.
1209
1210   (Note: there's at least one dubious thing in room.lisp: see the
1211   comment in VALID-OBJ)
1212
1213 346: alpha backtrace
1214   In sbcl-0.8.13, all backtraces from errors caused by internal errors
1215   on the alpha seem to have a "bogus stack frame".
1216
1217 349: PPRINT-INDENT rounding implementation decisions
1218   At present, pprint-indent (and indeed the whole pretty printer)
1219   more-or-less assumes that it's using a monospace font.  That's
1220   probably not too silly an assumption, but one piece of information
1221   the current implementation loses is from requests to indent by a
1222   non-integral amount.  As of sbcl-0.8.15.9, the system silently
1223   truncates the indentation to an integer at the point of request, but
1224   maybe the non-integral value should be propagated through the
1225   pprinter and only truncated at output?  (So that indenting by 1/2
1226   then 3/2 would indent by two spaces, not one?)
1227
1228 352: forward-referenced-class trouble
1229  reported by Bruno Haible on sbcl-devel
1230    (defclass c (a) ())
1231    (setf (class-name (find-class 'a)) 'b)
1232    (defclass a () (x))
1233    (defclass b () (y))
1234    (make-instance 'c)
1235  Expected: an instance of c, with a slot named x
1236  Got: debugger invoked on a SIMPLE-ERROR in thread 78906:
1237         While computing the class precedence list of the class named C.
1238         The class named B is a forward referenced class.
1239         The class named B is a direct superclass of the class named C.
1240
1241   [ Is this actually a bug?  DEFCLASS only replaces an existing class
1242     when the class name is the proper name of that class, and in the
1243     above code the class found by (FIND-CLASS 'A) does not have a
1244     proper name.  CSR, 2006-08-07 ]
1245
1246 353: debugger suboptimalities on x86
1247  On x86 backtraces for undefined functions start with a bogus stack
1248  frame, and  backtraces for throws to unknown catch tags with a "no 
1249  debug information" frame. These are both due to CODE-COMPONENT-FROM-BITS
1250  (used on non-x86 platforms) being a more complete solution then what
1251  is done on x86.
1252
1253  On x86/linux large portions of tests/debug.impure.lisp have been commented
1254  out as failures. The probable culprit for these problems is in x86-call-context
1255  (things work fine on x86/freebsd).
1256
1257  More generally, the debugger internals suffer from excessive x86/non-x86
1258  conditionalization and OAOOMization: refactoring the common parts would
1259  be good.
1260
1261 354: XEPs in backtraces
1262  Under default compilation policy
1263    (defun test ()
1264      (throw :unknown t))
1265    (test)
1266  Has the XEP for TEST in the backtrace, not the TEST frame itself.
1267  (sparc and x86 at least)
1268
1269  Since SBCL 0.8.20.1 this is hidden unless *SHOW-ENTRY-POINT-DETAILS*
1270  is true (instead there appear two TEST frames at least on ppc). The
1271  underlying cause seems to be that SB-C::TAIL-ANNOTATE will not merge
1272  the tail-call for the XEP, since Python has by that time proved that
1273  the function can never return; same happens if the function holds an
1274  unconditional call to ERROR.
1275
1276 356: PCL corruption
1277     (reported by Bruno Haible)
1278   After the "layout depth conflict" error, the CLOS is left in a state where
1279   it's not possible to define new standard-class subclasses any more.
1280   Test case:
1281   (defclass prioritized-dispatcher ()
1282     ((dependents :type list :initform nil)))
1283   (defmethod sb-pcl:validate-superclass ((c1 sb-pcl:funcallable-standard-class) 
1284                                          (c2 (eql (find-class 'prioritized-dispatcher))))
1285     t)
1286   (defclass prioritized-generic-function (prioritized-dispatcher standard-generic-function)
1287     ()
1288     (:metaclass sb-pcl:funcallable-standard-class))
1289   ;; ERROR, Quit the debugger with ABORT
1290   (defclass typechecking-reader-class (standard-class)
1291     ())
1292   Expected: #<STANDARD-CLASS TYPECHECKING-READER-CLASS>
1293   Got:      ERROR "The assertion SB-PCL::WRAPPERS failed."
1294
1295   [ This test case does not cause the error any more.  However,
1296     similar problems can be observed with 
1297
1298     (defclass foo (standard-class) ()
1299       (:metaclass sb-mop:funcallable-standard-class))
1300     (sb-mop:finalize-inheritance (find-class 'foo))
1301     ;; ERROR, ABORT
1302     (defclass bar (standard-class) ())
1303     (make-instance 'bar)
1304   ]
1305
1306 357: defstruct inheritance of initforms
1307     (reported by Bruno Haible)
1308   When defstruct and defclass (with :metaclass structure-class) are mixed,
1309   1. some slot initforms are ignored by the DEFSTRUCT generated constructor
1310      function, and 
1311   2. all slot initforms are ignored by MAKE-INSTANCE. (This can be arguably
1312      OK for initforms that were given in a DEFSTRUCT form, but for those
1313      given in a DEFCLASS form, I think it qualifies as a bug.)
1314   Test case:
1315   (defstruct structure02a
1316     slot1
1317     (slot2 t)
1318     (slot3 (floor pi)))
1319   (defclass structure02b (structure02a)
1320     ((slot4 :initform -44)
1321      (slot5)
1322      (slot6 :initform t)
1323      (slot7 :initform (floor (* pi pi)))
1324      (slot8 :initform 88))
1325     (:metaclass structure-class))
1326   (defstruct (structure02c (:include structure02b (slot8 -88)))
1327     slot9 
1328     (slot10 t)
1329     (slot11 (floor (exp 3))))
1330   ;; 1. Form:
1331   (let ((a (make-structure02c)))
1332     (list (structure02c-slot4 a)
1333           (structure02c-slot5 a)
1334           (structure02c-slot6 a)
1335           (structure02c-slot7 a)))
1336   Expected: (-44 nil t 9)
1337   Got: (SB-PCL::..SLOT-UNBOUND.. SB-PCL::..SLOT-UNBOUND..
1338         SB-PCL::..SLOT-UNBOUND.. SB-PCL::..SLOT-UNBOUND..)
1339   ;; 2. Form:
1340   (let ((b (make-instance 'structure02c)))
1341     (list (structure02c-slot2 b)
1342           (structure02c-slot3 b)
1343           (structure02c-slot4 b)
1344           (structure02c-slot6 b)
1345           (structure02c-slot7 b)
1346           (structure02c-slot8 b)
1347           (structure02c-slot10 b)
1348           (structure02c-slot11 b)))
1349   Expected: (t 3 -44 t 9 -88 t 20)
1350   Got: (0 0 0 0 0 0 0 0)
1351
1352 359: wrong default value for ensure-generic-function's :generic-function-class argument
1353     (reported by Bruno Haible)
1354   ANSI CL is silent on this, but the MOP's specification of ENSURE-GENERIC-FUNCTION says:
1355    "The remaining arguments are the complete set of keyword arguments
1356     received by ENSURE-GENERIC-FUNCTION."
1357   and the spec of ENSURE-GENERIC-FUNCTION-USING-CLASS:
1358    ":GENERIC-FUNCTION-CLASS - a class metaobject or a class name. If it is not
1359     supplied, it defaults to the class named STANDARD-GENERIC-FUNCTION."
1360   This is not the case in SBCL. Test case:
1361    (defclass my-generic-function (standard-generic-function)
1362      ()
1363      (:metaclass sb-pcl:funcallable-standard-class))
1364    (setf (fdefinition 'foo1)
1365          (make-instance 'my-generic-function :name 'foo1))
1366    (ensure-generic-function 'foo1
1367      :generic-function-class (find-class 'standard-generic-function))
1368    (class-of #'foo1)
1369    ; => #<SB-MOP:FUNCALLABLE-STANDARD-CLASS STANDARD-GENERIC-FUNCTION>
1370    (setf (fdefinition 'foo2)
1371          (make-instance 'my-generic-function :name 'foo2))
1372    (ensure-generic-function 'foo2)
1373    (class-of #'foo2)
1374   Expected: #<SB-MOP:FUNCALLABLE-STANDARD-CLASS STANDARD-GENERIC-FUNCTION>
1375   Got:      #<SB-MOP:FUNCALLABLE-STANDARD-CLASS MY-GENERIC-FUNCTION>
1376
1377 362: missing error when a slot-definition is created without a name
1378     (reported by Bruno Haible)
1379   The MOP says about slot-definition initialization:
1380   "The :NAME argument is a slot name. An ERROR is SIGNALled if this argument
1381    is not a symbol which can be used as a variable name. An ERROR is SIGNALled
1382    if this argument is not supplied."
1383   Test case:
1384    (make-instance (find-class 'sb-pcl:standard-direct-slot-definition))
1385   Expected: ERROR
1386   Got: #<SB-MOP:STANDARD-DIRECT-SLOT-DEFINITION NIL>
1387
1388 363: missing error when a slot-definition is created with a wrong documentation object
1389     (reported by Bruno Haible)
1390   The MOP says about slot-definition initialization:
1391   "The :DOCUMENTATION argument is a STRING or NIL. An ERROR is SIGNALled
1392    if it is not. This argument default to NIL during initialization."
1393   Test case:
1394    (make-instance (find-class 'sb-pcl:standard-direct-slot-definition)
1395                   :name 'foo
1396                   :documentation 'not-a-string)
1397   Expected: ERROR
1398   Got: #<SB-MOP:STANDARD-DIRECT-SLOT-DEFINITION FOO>
1399
1400 369: unlike-an-intersection behavior of VALUES-TYPE-INTERSECTION
1401   In sbcl-0.8.18.2, the identity $(x \cap y \cap y)=(x \cap y)$ 
1402   does not hold for VALUES-TYPE-INTERSECTION, even for types which
1403   can be intersected exactly, so that ASSERTs fail in this test case:
1404     (in-package :cl-user)
1405     (let ((types (mapcar #'sb-c::values-specifier-type 
1406                          '((values (vector package) &optional)
1407                            (values (vector package) &rest t)
1408                            (values (vector hash-table) &rest t)
1409                            (values (vector hash-table) &optional)
1410                            (values t &optional)
1411                            (values t &rest t)
1412                            (values nil &optional)
1413                            (values nil &rest t)
1414                            (values sequence &optional)
1415                            (values sequence &rest t)
1416                            (values list &optional)
1417                            (values list &rest t)))))
1418        (dolist (x types)
1419          (dolist (y types)
1420            (let ((i (sb-c::values-type-intersection x y)))
1421              (assert (sb-c::type= i (sb-c::values-type-intersection i x)))
1422              (assert (sb-c::type= i (sb-c::values-type-intersection i y)))))))
1423
1424 370: reader misbehaviour on large-exponent floats
1425     (read-from-string "1.0s1000000000000000000000000000000000000000")
1426   causes the reader to attempt to create a very large bignum (which it
1427   will then attempt to coerce to a rational).  While this isn't
1428   completely wrong, it is probably not ideal -- checking the floating
1429   point control word state and then returning the relevant float
1430   (most-positive-short-float or short-float-infinity) or signalling an
1431   error immediately would seem to make more sense.
1432
1433 372: floating-point overflow not signalled on ppc/darwin
1434  The following assertions in float.pure.lisp fail on ppc/darwin 
1435  (Mac OS X version 10.3.7):
1436    (assert (raises-error? (scale-float 1.0 most-positive-fixnum)
1437                           floating-point-overflow))
1438    (assert (raises-error? (scale-float 1.0d0 (1+ most-positive-fixnum))
1439                           floating-point-overflow)))
1440  as the SCALE-FLOAT just returns 
1441  #.SB-EXT:SINGLE/DOUBLE-FLOAT-POSITIVE-INFINITY. These tests have been
1442  disabled on Darwin for now.
1443
1444 377: Memory fault error reporting
1445   On those architectures where :C-STACK-IS-CONTROL-STACK is in
1446   *FEATURES*, we handle SIG_MEMORY_FAULT (SEGV or BUS) on an altstack,
1447   so we cannot handle the signal directly (as in interrupt_handle_now())
1448   in the case when the signal comes from some external agent (the user
1449   using kill(1), or a fault in some foreign code, for instance).  As
1450   of sbcl-0.8.20.20, this is fixed by calling
1451   arrange_return_to_lisp_function() to a new error-signalling
1452   function, but as a result the error reporting is poor: we cannot
1453   even tell the user at which address the fault occurred.  We should
1454   arrange such that arguments can be passed to the function called from
1455   arrange_return_to_lisp_function(), but this looked hard to do in
1456   general without suffering from memory leaks.
1457
1458 379: TRACE :ENCAPSULATE NIL broken on ppc/darwin
1459   See commented-out test-case in debug.impure.lisp.
1460
1461 380: Accessor redefinition fails because of old accessor name
1462   When redefining an accessor, SB-PCL::FIX-SLOT-ACCESSORS may try to
1463   find the generic function named by the old accessor name using
1464   ENSURE-GENERIC-FUNCTION and then remove the old accessor's method in
1465   the GF. If the old name does not name a function, or if the old name
1466   does not name a generic function, no attempt to find the GF or remove
1467   any methods is made.
1468
1469   However, if an unrelated GF with an incompatible lambda list exists,
1470   the class redefinition will fail when SB-PCL::REMOVE-READER-METHOD
1471   tries to find and remove a method with an incompatible lambda list
1472   from the unrelated generic function.
1473
1474 382: externalization unexpectedly changes array simplicity
1475   COMPILE-FILE and LOAD
1476     (defun foo ()
1477       (let ((x #.(make-array 4 :fill-pointer 0)))
1478         (values (eval `(typep ',x 'simple-array))
1479                 (typep x 'simple-array))))
1480   then (FOO) => T, NIL.
1481
1482   Similar problems exist with SIMPLE-ARRAY-P, ARRAY-HEADER accessors
1483   and all array dimension functions.
1484
1485 383: ASH'ing non-constant zeros
1486   Compiling
1487     (lambda (b)
1488       (declare (type (integer -2 14) b))
1489       (declare (ignorable b))
1490       (ash (imagpart b) 57))
1491   on PPC (and other platforms, presumably) gives an error during the
1492   emission of FASH-ASH-LEFT/FIXNUM=>FIXNUM as the assembler attempts to
1493   stuff a too-large constant into the immediate field of a PPC
1494   instruction.  Either the VOP should be fixed or the compiler should be
1495   taught how to transform this case away, paying particular attention
1496   to side-effects that might occur in the arguments to ASH.
1497
1498 384: Compiler runaway on very large character types
1499
1500   (compile nil '(lambda (x)
1501                     (declare (type (member #\a 1) x))
1502                     (the (member 1 nil) x)))
1503
1504   The types apparently normalize into a very large type, and the compiler
1505   gets lost in REMOVE-DUPLICATES.  Perhaps the latter should use
1506   a better algorithm (one based on hash tables, say) on very long lists
1507   when :TEST has its default value?
1508
1509   A simpler example:
1510
1511   (compile nil '(lambda (x) (the (not (eql #\a)) x)))
1512
1513   (partially fixed in 0.9.3.1, but a better representation for these
1514    types is needed.)
1515
1516 385:
1517   (format nil "~4,1F" 0.001) => "0.00" (should be " 0.0");
1518   (format nil "~4,1@F" 0.001) => "+.00" (should be "+0.0").
1519
1520 386: SunOS/x86 stack exhaustion handling broken
1521   According to <http://alfa.s145.xrea.com/sbcl/solaris-x86.html>, the
1522   stack exhaustion checking (implemented with a write-protected guard
1523   page) does not work on SunOS/x86.
1524
1525 388:
1526   (found by Dmitry Bogomolov)
1527
1528     (defclass foo () ((x :type (unsigned-byte 8))))
1529     (defclass bar () ((x :type symbol)))
1530     (defclass baz (foo bar) ())
1531
1532   causes error
1533
1534     SB-PCL::SPECIALIZER-APPLICABLE-USING-TYPE-P cannot handle the second argument
1535     (UNSIGNED-BYTE 8).
1536
1537   [ Can't trigger this any more, as of 2006-08-07 ]
1538
1539 389:
1540   (reported several times on sbcl-devel, by Rick Taube, Brian Rowe and
1541   others)
1542
1543   ROUND-NUMERIC-BOUND assumes that float types always have a FORMAT
1544   specifying whether they're SINGLE or DOUBLE.  This is true for types
1545   computed by the type system itself, but the compiler type derivation
1546   short-circuits this and constructs non-canonical types.  A temporary
1547   fix was made to ROUND-NUMERIC-BOUND for the sbcl-0.9.6 release, but
1548   the right fix is to remove the abstraction violation in the
1549   compiler's type deriver.
1550
1551 393: Wrong error from methodless generic function
1552     (DEFGENERIC FOO (X))
1553     (FOO 1 2)
1554   gives NO-APPLICABLE-METHOD rather than an argument count error.
1555
1556 395: Unicode and streams
1557   One of the remaining problems in SBCL's Unicode support is the lack
1558   of generality in certain streams.
1559   a. FILL-POINTER-STREAMs: SBCL refuses to write (e.g. using FORMAT)
1560      to streams made from strings that aren't character strings with
1561      fill-pointers:
1562        (let ((v (make-array 5 :fill-pointer 0 :element-type 'standard-char)))
1563          (format v "foo")
1564          v)
1565      should return a non-simple base string containing "foo" but
1566      instead errors.
1567
1568      (reported on sbcl-help by "tichy")
1569
1570 396: block-compilation bug
1571     (let ((x 1))
1572       (dotimes (y 10)
1573         (let ((y y))
1574           (when (funcall (eval #'(lambda (x) (eql x 2))) y)
1575             (defun foo (z)
1576               (incf x (incf y z))))))
1577       (defun bar (z)
1578         (foo z)
1579         (values x)))
1580   (bar 1) => 11, should be 4.
1581
1582 397: SLEEP accuracy
1583   The more interrupts arrive the less accurate SLEEP's timing gets.
1584     (time (sb-thread:terminate-thread
1585             (prog1 (sb-thread:make-thread (lambda ()
1586                                             (loop
1587                                              (princ #\!)
1588                                              (force-output)
1589                                              (sb-ext:gc))))
1590               (sleep 1))))
1591
1592 398: GC-unsafe SB-ALIEN string deporting
1593   Translating a Lisp string to an alien string by taking a SAP to it
1594   as done by the :DEPORT-GEN methods for C-STRING and UTF8-STRING
1595   is not safe, since the Lisp string can move. For example the
1596   following code will fail quickly on both cheneygc and pre-0.9.8.19
1597   GENCGC: 
1598
1599   (setf (bytes-consed-between-gcs) 4096)
1600   (define-alien-routine "strcmp" int (s1 c-string) (s2 c-string))
1601      
1602   (loop
1603     (let ((string "hello, world"))
1604        (assert (zerop (strcmp string string)))))
1605      
1606   (This will appear to work on post-0.9.8.19 GENCGC, since
1607    the GC no longer zeroes memory immediately after releasing
1608    it after a minor GC. Either enabling the READ_PROTECT_FREE_PAGES
1609    #define in gencgc.c or modifying the example so that a major
1610    GC will occasionally be triggered would unmask the bug.)
1611
1612   On cheneygc the only solution would seem to be allocating some alien
1613   memory, copying the data over, and arranging that it's freed once we
1614   return. For GENCGC we could instead try to arrange that the string
1615   from which the SAP is taken is always pinned.
1616
1617   For some more details see comments for (define-alien-type-method
1618   (c-string :deport-gen) ...)  in host-c-call.lisp.
1619
1620 403: FORMAT/PPRINT-LOGICAL-BLOCK of CONDITIONs ignoring *PRINT-CIRCLE*
1621   In sbcl-0.9.13.34,
1622     (defparameter *c*
1623       (make-condition 'simple-error
1624                       :format-control "ow... ~S"
1625                       :format-arguments '(#1=(#1#))))
1626     (setf *print-circle* t *print-level* 4)
1627     (format nil "~@<~A~:@>" *c*)
1628   gives
1629     "ow... (((#)))"
1630   where I (WHN) believe the correct result is "ow... #1=(#1#)",
1631   like the result from (PRINC-TO-STRING *C*). The question of 
1632   what the correct result is is complicated by the hairy text in 
1633   the Hyperspec "22.3.5.2 Tilde Less-Than-Sign: Logical Block",
1634     Other than the difference in its argument, ~@<...~:> is 
1635     exactly the same as ~<...~:> except that circularity detection 
1636     is not applied if ~@<...~:> is encountered at top level in a 
1637     format string.
1638   But because the odd behavior happens even without the at-sign, 
1639     (format nil "~<~A~:@>" (list *c*)) ; => "ow... (((#)))"
1640   and because something seemingly similar can happen even in 
1641   PPRINT-LOGICAL-BLOCK invoked directly without FORMAT, 
1642     (pprint-logical-block (*standard-output* '(some nonempty list))
1643       (format *standard-output* "~A" '#1=(#1#)))
1644   (which prints "(((#)))" to *STANDARD-OUTPUT*), I don't think 
1645   that the 22.3.5.2 trickiness is fundamental to the problem.
1646
1647   My guess is that the problem is related to the logic around the MODE
1648   argument to CHECK-FOR-CIRCULARITY, but I haven't reverse-engineered
1649   enough of the intended meaning of the different MODE values to be
1650   confident of this.
1651
1652 404: nonstandard DWIMness in LOOP with unportably-ordered clauses
1653   In sbcl-0.9.13, the code
1654     (loop with stack = (make-array 2 :fill-pointer 2 :initial-element t)
1655           for length = (length stack)
1656           while (plusp length)
1657           for element = (vector-pop stack)
1658           collect element)
1659   compiles without error or warning and returns (T T). Unfortunately, 
1660   it is inconsistent with the ANSI definition of the LOOP macro, 
1661   because it mixes up VARIABLE-CLAUSEs with MAIN-CLAUSEs. Furthermore,
1662   SBCL's interpretation of the intended meaning is only one possible,
1663   unportable interpretation of the noncompliant code; in CLISP 2.33.2, 
1664   the code compiles with a warning
1665     LOOP: FOR clauses should occur before the loop's main body
1666   and then fails at runtime with 
1667     VECTOR-POP: #() has length zero
1668   perhaps because CLISP has shuffled the clauses into an 
1669   ANSI-compliant order before proceeding.
1670
1671 405: a TYPE-ERROR in MERGE-LETS exercised at DEBUG 3
1672   In sbcl-0.9.16.21 on linux/86, compiling 
1673     (declaim (optimize (debug 3)))
1674     (defstruct foo bar)
1675     (let ()
1676       (flet ((i (x) (frob x (foo-bar foo))))
1677         (i :five)))
1678   causes a TYPE-ERROR 
1679     The value NIL is not of type SB-C::PHYSENV.
1680   in MERGE-LETS.
1681
1682 406: functional has external references -- failed aver
1683  Given the following food in a single file
1684   (eval-when (:compile-toplevel :load-toplevel :execute)
1685     (defstruct foo3))
1686   (defstruct bar
1687     (foo #.(make-foo3)))
1688  as of 0.9.18.11 the file compiler breaks on it:
1689   failed AVER: "(NOT (FUNCTIONAL-HAS-EXTERNAL-REFERENCES-P CLAMBDA))"
1690  Defining the missing MAKE-LOAD-FORM method makes the error go away.
1691
1692 407: misoptimization of loop, COERCE 'FLOAT, and HANDLER-CASE for bignums
1693   (reported by Ariel Badichi on sbcl-devel 2007-01-09)
1694   407a: In sbcl-1.0.1 on Linux x86, 
1695                 (defun foo ()
1696                   (loop for n from (expt 2 1024) do
1697                         (handler-case
1698                             (coerce n 'single-float)
1699                           (simple-type-error ()
1700                             (format t "Got here.~%")
1701                             (return-from foo)))))
1702                 (foo)
1703         causes an infinite loop, where handling the error would be expected.
1704   407b: In sbcl-1.0.1 on Linux x86, 
1705                 (defun bar ()
1706                   (loop for n from (expt 2 1024) do
1707                         (handler-case
1708                             (format t "~E~%" (coerce n 'single-float))
1709                           (simple-type-error ()
1710                             (format t "Got here.~%")
1711                             (return-from bar)))))
1712         fails to compile, with
1713                 Too large to be represented as a SINGLE-FLOAT: ...
1714         from
1715                 0: ((LABELS SB-BIGNUM::CHECK-EXPONENT) ...)
1716                 1: ((LABELS SB-BIGNUM::FLOAT-FROM-BITS) ...)
1717                 2: (SB-KERNEL:%SINGLE-FLOAT ...)
1718                 3: (SB-C::BOUND-FUNC ...)
1719                 4: (SB-C::%SINGLE-FLOAT-DERIVE-TYPE-AUX ...)
1720
1721   These are now fixed, but (COERCE HUGE 'SINGLE-FLOAT) still signals a
1722   type-error at runtime. The question is, should it instead signal a
1723   floating-point overflow, or return an infinity?
1724
1725 408: SUBTYPEP confusion re. OR of SATISFIES of not-yet-defined predicate
1726         As reported by Levente M\'{e}sz\'{a}ros sbcl-devel 2006-02-20,
1727                 (aver (equal (multiple-value-list
1728                               (subtypep '(or (satisfies x) string)
1729                                         '(or (satisfies x) integer)))
1730                              '(nil nil)))
1731         fails. Also, beneath that failure lurks another failure,
1732                 (aver (equal (multiple-value-list
1733                               (subtypep 'string
1734                                         '(or (satisfies x) integer)))
1735                              '(nil nil)))
1736         Having looked at this for an hour or so in sbcl-1.0.2, and
1737         specifically having looked at the output from
1738           laptop$ sbcl
1739           * (let ((x 'string)
1740                   (y '(or (satisfies x) integer)))
1741               (trace sb-kernel::union-complex-subtypep-arg2
1742                      sb-kernel::invoke-complex-subtypep-arg1-method
1743                      sb-kernel::type-union
1744                      sb-kernel::type-intersection
1745                      sb-kernel::type=)
1746               (subtypep x y))
1747         my (WHN) impression is that the problem is that the semantics of TYPE=
1748         are wrong for what the UNION-COMPLEX-SUBTYPEP-ARG2 code is trying
1749         to use it for. The comments on the definition of TYPE= probably
1750         date back to CMU CL and seem to define it as a confusing thing:
1751         its primary value is something like "certainly equal," and its
1752         secondary value is something like "certain about that certainty."
1753         I'm left uncertain how to fix UNION-COMPLEX-SUBTYPEP-ARG2 without
1754         reducing its generality by removing the TYPE= cleverness. Possibly
1755         the tempting TYPE/= relative defined next to it might be a
1756         suitable replacement for the purpose. Probably, though, it would
1757         be best to start by reverse engineering exactly what TYPE= and
1758         TYPE/= do, and writing an explanation which is so clear that one
1759         can see immediately what it's supposed to mean in odd cases like
1760         (TYPE= '(SATISFIES X) 'INTEGER) when X isn't defined yet.
1761
1762 409: MORE TYPE SYSTEM PROBLEMS
1763   Found while investigating an optimization failure for extended
1764   sequences. The extended sequence type implementation was altered to
1765   work around the problem, but the fundamental problem remains, to wit:
1766     (sb-kernel:type= (sb-kernel:specifier-type '(or float ratio))
1767                      (sb-kernel:specifier-type 'single-float))
1768   returns NIL, NIL on sbcl-1.0.3.
1769   (probably related to bug #408)
1770
1771 410: read circularities and type declarations
1772   Consider the definition
1773     (defstruct foo (a 0 :type (not symbol)))
1774   followed by
1775     (setf *print-circle* t) ; just in case
1776     (read-from-string "#1=#s(foo :a #1#)")
1777   This gives a type error (#:G1 is not a (NOT SYMBOL)) because of the
1778   implementation of read circularity, using a symbol as a marker for
1779   the previously-referenced object.
1780
1781 415: Issues creating large arrays on x86-64/Linux and x86/Darwin
1782
1783    (make-array (1- array-dimension-limit))
1784
1785    causes a GC invariant violation on x86-64/Linux, and
1786    an unhandled SIGILL on x86/Darwin.
1787
1788 416: backtrace confusion
1789
1790   (defun foo (x)
1791     (let ((v "foo"))
1792       (flet ((bar (z)
1793                (oops v z)
1794                (oops z v)))
1795         (bar x)
1796         (bar v))))
1797   (foo 13)
1798
1799   gives the correct error, but the backtrace shows 
1800     1: (SB-KERNEL:FDEFINITION-OBJECT 13 NIL)
1801   as the second frame.
1802
1803 418: SUBSEQ on lists doesn't support bignum indexes
1804
1805  LIST-SUBSEQ* now has all the works necessary to support bignum indexes,
1806  but it needs to be verified that changing the DEFKNOWN doesn't kill
1807  performance elsewhere.
1808
1809  Other generic sequence functions have this problem as well.
1810
1811 419: stack-allocated indirect closure variables are not popped
1812
1813     (locally (declare (optimize sb-c::stack-allocate-dynamic-extent
1814                                 sb-c::stack-allocate-value-cells))
1815       (defun bug419 (x)
1816         (multiple-value-call #'list
1817           (eval '(values 1 2 3))
1818           (let ((x x))
1819             (declare (dynamic-extent x))
1820             (flet ((mget (y)
1821                      (+ x y))
1822                    (mset (z)
1823                      (incf x z)))
1824               (declare (dynamic-extent #'mget #'mset))
1825               ((lambda (f g) (eval `(progn ,f ,g (values 4 5 6)))) #'mget #'mset))))))
1826
1827   (ASSERT (EQUAL (BUG419 42) '(1 2 3 4 5 6))) => failure
1828
1829   Note: as of SBCL 1.0.26.29 this bug no longer affects user code, as
1830   SB-C::STACK-ALLOCATE-VALUE-CELLS needs to be explicitly turned on for
1831   that to happen. Proper fix for this bug requires (Nikodemus thinks)
1832   storing the relevant LAMBDA-VARs in a :DYNAMIC-EXTENT cleanup, and
1833   teaching stack analysis how to deal with them.
1834
1835 420: The MISC.556 test from gcl/ansi-tests/misc.lsp fails hard.
1836
1837 In sbcl-1.0.13 on Linux/x86, executing 
1838        (FUNCALL
1839         (COMPILE NIL
1840                  '(LAMBDA (P1 P2)
1841                     (DECLARE
1842                      (OPTIMIZE (SPEED 1) (SAFETY 0) (DEBUG 0) (SPACE 0))
1843                      (TYPE (MEMBER 8174.8604) P1) (TYPE (MEMBER -95195347) P2))
1844                     (FLOOR P1 P2)))
1845         8174.8604 -95195347)
1846 interactively causes
1847   SB-SYS:MEMORY-FAULT-ERROR: Unhandled memory fault at #x8.
1848 The gcl/ansi-tests/doit.lisp program terminates prematurely shortly after
1849 MISC.556 by falling into gdb with
1850   fatal error encountered in SBCL pid 2827: Unhandled SIGILL
1851 unless the MISC.556 test is commented out.
1852
1853 Analysis: + and a number of other arithmetic functions exhibit the
1854 same behaviour. Here's the underlying problem: On x86 we perform
1855 single-float + integer normally using double-precision, and then
1856 coerce the result back to single-float. (The FILD instruction always
1857 gives us a double-float, and unless we do MOVE-FROM-SINGLE it remains
1858 one. Or so it seems to me, and that would also explain the observed
1859 behaviour below.)
1860
1861 During IR1 we derive the types for both
1862
1863  (+ <single> <integer>)                   ; uses double-precision
1864  (+ <single> (FLOAT <integer> <single>))  ; uses single-precision
1865
1866 and get a mismatch for a number of unlucky arguments. This leads to
1867 derived result type NIL, and ends up flushing the whole whole
1868 operation -- and finally we generate code without a return sequence,
1869 and fall through to whatever.
1870
1871 The use of double-precision in the first case appears to be an
1872 (un)happy accident -- interval arithmetic gives us the
1873 double-precision result because that's what the backend does.
1874
1875  (+ 8172.0 (coerce -95195347 'single-float)) ; => -9.518717e7
1876  (+ 8172.0 -95195347)                        ; => -9.5187176e7
1877  (coerce (+ 8172.0 (coerce -95195347 'double-float)) 'single-float)
1878                                              ; => -9.5187176e7
1879
1880 Which should be fixed, the IR1, or the backend?
1881
1882 421: READ-CHAR-NO-HANG misbehaviour on Windows Console:
1883
1884   It seems that on Windows READ-CHAR-NO-HANG hangs if the user
1885   has pressed a key, but not yet enter (ie. SYSREAD-MAY-BLOCK-P
1886   seems to lie if the OS is buffering input for us on Console.)
1887
1888   reported by Elliot Slaughter on sbcl-devel 2008/1/10.
1889
1890 422: out-of-extent return not checked in safe code
1891
1892  (declaim (optimize safety))
1893  (funcall (catch 't (block nil (throw 't (lambda () (return))))))
1894
1895 behaves ...erratically. Reported by Kevin Reid on sbcl-devel
1896 2007-07-06. (We don't _have_ to check things like this, but we
1897 generally try to check returns in safe code, so we should here too.)
1898
1899 424: toplevel closures and *CHECK-CONSISTENCY*
1900
1901  The following breaks under COMPILE-FILE if *CHECK-CONSISTENCY* is true.
1902
1903   (let ((exported-symbols-alist
1904          (loop for symbol being the external-symbols of :cl
1905                collect (cons symbol
1906                              (concatenate 'string
1907                                           "#"
1908                                           (string-downcase symbol))))))
1909     (defun hyperdoc-lookup (symbol)
1910       (cdr (assoc symbol exported-symbols-alist))))
1911
1912  (Test-case adapted from CL-PPCRE.)
1913
1914 425: reading from closed streams
1915
1916  Reported by Damien Cassou on sbcl-devel. REPL transcript follows:
1917
1918   * (open ".bashrc" :direction :input)
1919   #<SB-SYS:FD-STREAM for "file /home/cassou/.bashrc" {A6ADFC9}>
1920   * (defparameter *s* *)
1921   *S*
1922   * (read-line *s*)
1923   "# -*- Mode: Sh -*-"
1924   * (read-line *s*)
1925   "# Files you make look like rw-r--r--"
1926   * (open-stream-p *s*)
1927   T
1928   * (close *s*)
1929   T
1930   * (open-stream-p *s*)
1931   NIL
1932   * (read-line *s*)
1933   "umask 022"
1934
1935  The problem is with the fast path using ansi-stream-cin-buffer not hitting
1936  closed-flame.
1937
1938 426: inlining failure involving multiple nested calls
1939
1940    (declaim (inline foo))
1941    (defun foo (x y)
1942      (cons x y))
1943    (defun bar (x)
1944      (foo (foo x x) (foo x x)))
1945    ;; shows a full call to FOO
1946    (disassemble 'bar)
1947    ;; simple way to test this programmatically
1948    (let ((code (sb-c::fun-code-header #'bar))
1949          (foo (sb-impl::fdefinition-object 'foo nil)))
1950      (loop for i from sb-vm:code-constants-offset below (sb-kernel:get-header-data code)
1951            do (assert (not (eq foo (sb-kernel:code-header-ref code i))))))
1952
1953  This appears to be an ancient bug, inherited from CMUCL: reportedly
1954  18c does the same thing. RECOGNIZE-KNOWN-CALL correctly picks up only
1955  one of the calls, but local call analysis fails to inline the call
1956  for the second time. Nikodemus thinks (but is not 100% sure based on
1957  very brief investigation) that the call that is not inlined is the
1958  second nested one. A trivial fix is to call CHANGE-REF-LEAF in known
1959  call for functions already inline converted there, but he is not sure
1960  if this has adverse effects elsewhere.