[Openmcl-devel] Bignum issue

James M. Lawrence llmjjmll at gmail.com
Mon May 14 17:09:47 PDT 2012


This eventually gives an assertion failure on my machine.

(defun compute ()
  (loop
     :for result := 1 :then (* result 10)
     :repeat 2000
     :finally (return result)))

(defun test ()
  (declare (optimize (debug 3) (safety 3) (speed 0)))
  (let ((expected (expt 10 2000))
        (result (compute)))
    (assert (eql expected result))))

(defun run ()
  (let ((count 0))
    (loop
       (test)
       (incf count)
       (when (zerop (mod count 1000))
         (princ ".")))))

Tested on 32-bit CCL 1.8 and from SVN; Linux Core-i7. Number of
iterations until the assert signals: 36000, 31000, 18000, 24000,
230000 (an outlier).

The value of `result' varies, though it always consists of a bunch of
nines, followed by random digits, followed by zeros. The value of
`expected' is correct.

The problem seems to be exacerbated by the presence of threads. If we
create many threads then the assertion fails immediately.

(defun test ()
  (declare (optimize (debug 3) (safety 3) (speed 0)))
  (let ((expected (expt 10 2000)))
    (ccl:process-run-function
     "test"
     (lambda ()
       (let ((result (compute)))
         (assert (eql expected result)))))))

(defun run ()
  (loop :repeat 25 :do (test)))



More information about the Openmcl-devel mailing list