Ticket #968 (closed defect: fixed)

Opened 2 years ago

Last modified 23 months ago

apparent GC issue on x8632

Reported by: gb Owned by: gb
Priority: normal Milestone:
Component: Runtime (threads, GC) Version: trunk
Keywords: Cc:

Description

See  http://clozure.com/pipermail/openmcl-devel/2012-May/013568.html

I was unable to reproduce this after doing:

? (progn
    (egc nil)
    (set-lisp-heap-gc-threshold (ash 512 20))
    (gc))

before calling (RUN), even when TEST/RUN created threads and RUN ran for 2500 iterations instead of 25. That suggests pretty strongly that this is a GC bug (or that the code involved in BIGNUM * FIXNUM multiplication doesn't follow register conventions correctly and that the failure occurs when such code is interrupted by GC in another thread.)

When a failure occurs, several words (in the "middle" of the result bignum) have incorrect values; the bignum is of the correct size and the words near both ends seem to be correct. This is also consistent with GC-related memory corruption.

Attachments

x8632-bignum.lisp.diff Download (629 bytes) - added by uchida 23 months ago.

Change History

comment:1 Changed 2 years ago by gb

  • Owner set to gb

comment:2 Changed 2 years ago by jlawrence

I still see this issue on 32-bit Linux with latest from svn and full rebuild. Verbatim test is

(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)))
    (ccl:process-run-function
     "test"
     (lambda ()
       (let ((result (compute)))
         (assert (eql expected result)))))))

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

With the GC commands you gave, I occasionally get the assertion failure with 2500 iterations; around 1 in 6 chance, restarting CCL for each run.

Linux xi 3.2.0-24-generic-pae #39-Ubuntu SMP Mon May 21 18:54:21 UTC 2012 i686 i686 i386 GNU/Linux

gcc (Ubuntu/Linaro? 4.6.3-1ubuntu5) 4.6.3

Changed 23 months ago by uchida

comment:3 follow-up: ↓ 4 Changed 23 months ago by uchida

The attached patch seems to fix the problem.

comment:4 in reply to: ↑ 3 Changed 23 months ago by uchida

Replying to uchida:

The attached patch seems to fix the problem.

Tested on dx86cl with 2500 iterations.

uchita-akiko-no-macbook-2:lispbox-0.7 uchidamasako$ ./ccl/dx86cl -n
Welcome to Clozure Common Lisp Version 1.8-r15287M  (DarwinX8632)!
? (defun compute ()
  (loop
     :for result := 1 :then (* result 10)
     :repeat 2000
     :finally (return result)))

COMPUTE
? (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)))))))

TEST
? (defun run ()
  (loop :repeat 2500 :do (test)))

RUN
? (run)
NIL
? 

comment:5 Changed 23 months ago by gb

  • Status changed from new to closed
  • Resolution set to fixed

(In [15454]) In %MULTIPLY-AND-ADD: (thanks to uchida) don't try to keep node X in imm reg imm0.

Fixes ticket:968 in the trunk.

Note: See TracTickets for help on using tickets.