sb-int:bug from broken backquote forms

Bug #770184 reported by 3b
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Fix Released
Undecided
Unassigned

Bug Description

 ```((,,@1))
errors with:

debugger invoked on a SB-INT:BUG in thread #<THREAD "initial thread" RUNNING
                                             {1002959311}>:
(A SB-INT:BUG was caught when trying to print *DEBUG-CONDITION* when entering
the debugger. Printing was aborted and the SB-INT:BUG was stored in
SB-DEBUG::*NESTED-DEBUG-CONDITION*.)
...
0: (SB-INT:BUG #<error printing object>)
1: (SB-IMPL::BACKQ-UNPARSE #<error printing object>)
2: (SB-IMPL::BACKQ-UNPARSE #<error printing object>)
3: (SB-IMPL::PPRINT-BACKQUOTE #<error printing object>)
4: (SB-PRETTY:OUTPUT-PRETTY-OBJECT #<error printing object>)
5: (SB-PRETTY:OUTPUT-PRETTY-OBJECT #<error printing object>)
6: (PRIN1 #<error printing object>)
7: (SB-IMPL::REPL-FUN NIL)

```((,',@1))
errors with the more readable:
debugger invoked on a SB-INT:BUG in thread #<THREAD "initial thread" RUNNING
                                             {1002959311}>:
    found illegal dotted backquote form: (QUOTE . 1)
  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/>.
...
0: (SB-INT:BUG "found illegal dotted backquote form: ~S" (QUOTE . 1))
1: (SB-IMPL::BACKQ-UNPARSE (QUOTE . 1) NIL)
2: (SB-IMPL::BACKQ-UNPARSE #<error printing object>)
3: (SB-IMPL::BACKQ-UNPARSE #<error printing object>)
4: (SB-IMPL::PPRINT-BACKQUOTE #<error printing object>)
5: (SB-PRETTY:OUTPUT-PRETTY-OBJECT #<error printing object>)
6: (SB-PRETTY:OUTPUT-PRETTY-OBJECT #<error printing object>)
7: (PRIN1 #<error printing object>)
8: (SB-IMPL::REPL-FUN NIL)

expected: PRINTable error message about trying to splice something that isn't a list

tested on 1.0.47.1, x8664 linux

Tags: backquote
Revision history for this message
3b (00003b) wrote :

Looking further, `(,@1) evaluates to 1 and `(1 ,@2) evaluates to (1 . 2), which don't seem conformant, if i'm looking at the right part of clhs 2.4.6.

 `(,@1 2) errors with "The value 1 is not of type LIST." as expected.

Revision history for this message
Valentin Pavlov (x-pavlov) wrote :

It seems that the problem is in src/code/backq.lisp, more specifically in the "hairy" case handling.

The backquotify function handles forms that end with ",@form)" as ending in " . ,form)"

This might be OK for most of the cases, but when form is an atom this leads to the faulty behavior described above. A quick fix that leaves the rest of the backq logic unaffected would probably be simiar to:

--- src/code/backq.lisp 2011-03-27 11:49:23.000000000 +0300
+++ src/code/backq.lisp 2011-04-26 10:26:06.673291931 +0300
@@ -115,18 +115,24 @@
                (cond
                 ((eq aflag *bq-at-flag*)
                  (if (null dflag)
- (if (expandable-backq-expression-p a)
- (values 'append (list a))
- (comma a))
+ (cond
+ ((expandable-backq-expression-p a)
+ (values 'append (list a)))
+ ((atom a)
+ (simple-reader-error stream ",@ before an atom in ~S" code))
+ (t (comma a)))
                      (values 'append
                              (cond ((eq dflag 'append)
                                     (cons a d ))
                                    (t (list a (backquotify-1 dflag d)))))))
                 ((eq aflag *bq-dot-flag*)
                  (if (null dflag)
- (if (expandable-backq-expression-p a)
- (values 'nconc (list a))
- (comma a))
+ (cond
+ ((expandable-backq-expression-p a)
+ (values 'nconc (list a)))
+ ((atom a)
+ (simple-reader-error stream ",. before an atom in ~S" code))
+ (t (comma a)))
                      (values 'nconc
                              (cond ((eq dflag 'nconc)
                                     (cons a d))

Changed in sbcl:
assignee: nobody → Nikodemus Siivola (nikodemus)
status: New → In Progress
Revision history for this message
Nikodemus Siivola (nikodemus) wrote :

commit afbad5dccd85bfbcbe70598782eab30ac05f2fdf
Author: Nikodemus Siivola <email address hidden>
Date: Wed Aug 24 14:52:38 2011 +0300

    be more careful about ,@<constant-atom> and ,.<constant-atom>

      Specifically, signal a read-time error for those things which COMMA
      special-cases when constructing a splice.

      Fixes lp#770184.

Changed in sbcl:
assignee: Nikodemus Siivola (nikodemus) → nobody
status: In Progress → 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.