Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;; (THREADTEST ..) launches some threads that generate garbage.
- ;; It crashes on latest rpi deb build with:
- ;; > Unhandled exception 4 at 0x1512acec, context->regs at #x74d64490
- ;; specifically, it
- ;; crashes on raspberri pi armcl dev version:
- ;; * "Version 1.12-dev (v1.12-dev.4-3-gdd5622e9) LinuxARM32"
- ;; but does NOT crash on release version:
- ;; * "Version 1.11.5/v1.11.5 (LinuxARM32)"
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; It also seems to expose a locking problem in Version 1.11.5 when
- ;; run as (threadtest :loop-count 10000 :exercise-locking) to force
- ;; allocations inside the threads to take place inside a
- ;; with-lock-grabbed, the error:
- ;;
- ;; Current process #<PROCESS Reader 4(26) [Active] #x150D335E> does not own
- ;; lock #<RECURSIVE-LOCK "glock" [ptr @ #x76105C60] #x150BB0D6>
- ;;
- ;; occurs in CCL::%UNLOCK-RECURSIVE-LOCK-OBJECT
- ;;
- ;; could this locking problem be the source of the threading bug here?
- ;; https://trac.clozure.com/ccl/ticket/1257
- (defparameter *the-glock* nil) ;; allow us to look at lock while running
- (defun threadtest (&key
- (thread-count 7)
- (loop-count 1000)
- (exercise-locking nil)
- (garbage-count 1000))
- (let ((done-flags (make-array thread-count :initial-element nil))
- (lock (ccl:make-lock "done-flags-lock"))
- (glock (when exercise-locking
- (ccl:make-lock "glock"))))
- (setf *the-glock* glock)
- (dotimes (i thread-count)
- (process-run-function
- (format nil "Reader ~d" i)
- (lambda (i)
- (unwind-protect
- (dotimes (j loop-count)
- #+nil ;; temporarily remove this additonal complication
- (setf (ccl:process-name ccl:*current-process*)
- (format nil "Reader ~d: ~d" i j))
- (garbagemaker garbage-count glock)
- ))
- (ccl:with-lock-grabbed (lock) (setf (elt done-flags i) t)))
- i))
- (loop do
- (unless
- (ccl:with-lock-grabbed (lock)
- (position nil done-flags))
- (return)))))
- ;; make some garbage, optionally grab a lock to exercise
- ;; locking in threads
- (defun garbagemaker (garbage-count lock)
- (loop for i below garbage-count
- collect (if lock
- (ccl:with-lock-grabbed (lock)
- (make-string 10))
- (make-string 10))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement