Subject: [clisp-list] please report whether your CLISP crashes on my 9nines example

From: "Hoehle, Joerg-Cyril" <[email-masked]>
Date: Fri Feb 22 00:17:11 2002

Hi,

I submitted a bug-report about a crash, Sam cannot reproduce it. However I still can.
http://sourceforge.net/tracker/?func=detail&aid=514805&group_id=1355&atid=101355

Please try out the following and report either to me or Sam what your CLISP is and how it behaves. I think it's not necessary to respond to the whole list.

I believe neither the stack overflow nor the crash are normal behaviour.
I use clisp-2.27-win32 (binary distribution).

Thanks for participating,
	Jörg Höhle.

;; These rehash-sizes crash CLISP-2.27-win32k
;; 17.0f0 19.0s0 21.0s0 22.0s0
;; These ones work
;; 9.0s0 13.0s0 15.0s0
;; Non-deterministic crashes (i.e. may work) occur with:
;; 16.0f0 16.0l0

;; NB: only (ext:space ..) causes "unknown SW exception". Without it,
;; there's just the "program stack overflow".

;; Joerg Hoehles version: only positives: halves size and doubles speed
;; Based on Bruce Hoult's posting to cll "Cute Little Problem"
;; Best :rehash-size seems to be 9.0s0
(defun nines (&optional (rehash-size 21.0s0))
  (declare (optimize (speed 3) (safety 1)))
  (let ((nums (make-array 10
	  :initial-contents (loop repeat 10 collect
		(make-hash-table :size 450 :rehash-size rehash-size)))))
    (setf (gethash 9 (svref nums 1)) t)
    (loop for n from 2 below 10 as h = (svref nums n) do;; start [*]
	  (loop for p from 1 to (floor n 2) do
		(loop for a being the hash-keys of (svref nums p) do
		      (loop for b being the hash-keys of (svref nums (- n p)) do
			    (setf (gethash (+ a b) h) t  (gethash (* a b) h) t
				  (gethash (abs (- a b)) h) t)
			    unless (zerop b) do (setf (gethash (/ a b) h) t)
			    unless (zerop a) do (setf (gethash (/ b a) h) t))))
	  collect (hash-table-size h)
	  collect ;; no format, just return result
		  (loop for i from 1 unless (gethash i h) do (return i)))))
#|
[2]> (load "9nines" :compiling t)
[3]> (nines)
 *** - Program stack overflow. RESET
[4]> (nines 9.0s0)

(450 2 450 1 450 4 450 13 4050 22 4050 33 36450 103 36450 195)
[5]> (nines 13.0s0)

(450 2 450 1 450 4 450 13 5850 22 5850 33 76050 103 76050 195)
[6]> (ext:space (nines))
 *** - Program stack overflow. RESET
Plus additional window: unknown software exception (0xc0000094) at 0x004e8ad0.
"Integer divide by zero"
Process inferior-lisp exited abnormally with code 148

[Restart]
[4]> (nines 22.0s0)
 *** - Program stack overflow. RESET
[5]> (nines 19.0s0)
 *** - Program stack overflow. RESET
[6]> (nines 15.0s0)

(450 2 450 1 450 4 450 13 6750 22 6750 33 101250 103 101250 195)
[22]> (dotimes (i 10) (print i) (nines 33.0s0))
0 
1 
*** - Program stack overflow. RESET
[32]> (ext:space (nines 33.0s0))
*** - Program stack overflow. RESET
*** - CAR: :ADJUSTABLE is not a list
1. Break [33]> 
> (dotimes (i 10) (print i) (nines 16.0s0))
|#

---

From: Arseny Slobodjuck <[email-masked]>
Date: Fri Feb 22 19:07:07 2002

Hi,

I simplified yor code a bit:

(let ((h (make-hash-table :size 123000)))
  (loop for i from 1 to 10000 do 
    (when (or (zerop (mod i 100)) (= i 1))
      (unless (= i 1)
        (loop for i from 1 to 29 do (princ #\Backspace)))
      (format t "Checking ~7D size ~7D" i  (hash-table-size h)))
    (setf (gethash i h) t)))

Still crashes stack in NT. FreeBSD ok. It's seems that when
hash-table-size becomes about 120000 - 130000 clisp cannot
handle it while "hash table too large" error doesn't arise.
To check this you need quite a computer though.

Also I noticed that integer rehash-sizes behaves as it was
2.0 (Both in FreeBSD and NT). That's a test

(let ((h (make-hash-table :size 1 :rehash-size 1000)))
  (loop for i from 1 to 20 do 
    (setf (gethash i h) t)
    (format t "Checking ~2D size ~D~%" i  (hash-table-size h))))

-- 
Best regards,
 Arseny                            mailto:[email-masked]