jscl icon indicating copy to clipboard operation
jscl copied to clipboard

REPL crash

Open kanubacode opened this issue 8 years ago • 5 comments
trafficstars

One can easily crash the REPL trying to evaluate a large number, such as 1d999.

kanubacode avatar Jul 21 '17 04:07 kanubacode

Very interesting.

Compare

(progn (read-from-string "1d999") nil)   ;; works

(progn 1d999 nil)   ; hangs!

First one suggests that is not the reader. But (read-from-string "1d999") fails.. so maybe the printer? but the second example is not printed at all.

davazp avatar Jul 21 '17 08:07 davazp

This is a reader error, not printer. If it was the printer, the latter test of yours would work. Additionally SBCL explicitly gives an error as:

READER-ERROR at 5 on #<SB-IMPL::STRING-INPUT-STREAM {100376C6E3}>:
failed to build float from 1d999
Original error: Too large to be represented as a DOUBLE-FLOAT:
  10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
   [Condition of type SB-KERNEL:READER-IMPOSSIBLE-NUMBER-ERROR]

This is a lesser known issue as to why it is very difficult to create a sandboxable Common Lisp...more than just a subset of symbols need to be considered.

kanubacode avatar Jul 21 '17 08:07 kanubacode

But if it is reader, how the first example (progn (read-from-string "1d999") nil) works?

Or even (integerp (read-from-string "1d999")). Or at least they don't hang.

davazp avatar Jul 21 '17 08:07 davazp

The first example produces the same error on SBCL, so I assume an implementation problem found as a result of the first bug.

kanubacode avatar Jul 21 '17 08:07 kanubacode

Sure, but setting aside the fact that we could signal an error. I would expect the code still to just give a meaningless result, but never to hang. But I am not sure where it hangs.

I'll have a look.

hanks for reporting it!

davazp avatar Jul 21 '17 09:07 davazp