Last active
December 8, 2017 11:22
-
-
Save otwieracz/d88dfc0d8b726f2610dda310e2b1e406 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ql:quickload :bordeaux-threads) | |
(ql:quickload :local-time) | |
(ql:quickload :lparallel) | |
(in-package #:cl-user) | |
(defvar *bug-lock* (bt:make-lock "bug-lock")) | |
(defvar *bug-channel* nil) | |
(defvar *bug-results-consumer-thread* nil) | |
(defun init () | |
(setf lparallel:*kernel* (lparallel:make-kernel 1 :name "LPARALLEL-BUG")) | |
(setf *bug-channel* (lparallel:make-channel)) | |
(setf *bug-results-consumer-thread* | |
(bt:make-thread (lambda () | |
(loop (handler-case (unless (eq (lparallel:receive-result *bug-channel*) | |
:ok) | |
(error "Something went wrong")) | |
(error (c) (format t "Error during BUG-RESULTS-CONSUMER: ~A" c)))))))) | |
(defmethod bug-compute () | |
(let ((task (lambda () | |
(format t "locking~%") | |
(finish-output t) | |
(bt:with-lock-held (*bug-lock*) | |
(format t "locked~%") | |
(finish-output t) | |
(sleep 1) | |
(format t "unlocking~%") | |
(finish-output t) | |
) | |
(format t "unlocked~%") | |
(finish-output t) | |
:ok))) | |
(format t "submitting~%") | |
(finish-output t) | |
(lparallel:submit-task *bug-channel* task))) | |
(defun do-in-loop () | |
(dotimes (x 10) | |
(bug-compute) | |
(sleep 0.1))) | |
(defun test () | |
(format t "*** other thread goes to sleep ***~%") | |
(finish-output t) | |
(bt:with-lock-held (*bug-lock*) | |
(format t "*** other thread wakes up ***~%") | |
(finish-output t))) | |
(defun main () | |
(init) | |
(do-in-loop) | |
(sleep 1) | |
(test) | |
(sleep 12)) | |
#+sbcl(save-lisp-and-die "sbcl-sad" :toplevel #'main :executable t) | |
#+ccl(save-application "ccl-sad" :toplevel-function #'main :prepend-kernel t) | |
;; Valid behavior: | |
;; | |
;; $ ./sbcl-sad | |
;; otwieracz@odyssey:~/work/end/git/instinct-engine/bug$ ./sbcl-sad | |
;; submitting | |
;; submitting | |
;; submitting | |
;; submitting | |
;; submitting | |
;; submitting | |
;; submitting | |
;; submitting | |
;; locking | |
;; submitting | |
;; locking | |
;; submitting | |
;; locked | |
;; unlocking | |
;; unlocking | |
;; *** other thread goes to sleep *** | |
;; unlocked | |
;; *** other thread wakes up *** | |
;; locking | |
;; locked | |
;; unlocking | |
;; unlocked | |
;; locking | |
;; locked | |
;; unlocking | |
;; unlocked | |
;; locking | |
;; locked | |
;; unlocking | |
;; unlocked | |
;; locking | |
;; locked | |
;; unlocking | |
;; unlocked | |
;; locking | |
;; locked | |
;; unlocking | |
;; unlocked | |
;; locking | |
;; locked | |
;; unlocking | |
;; unlocked | |
;; locking | |
;; locked | |
;; Invalid behavior: | |
;; | |
;; [slawek@dev-ui-endsec-net-unstable-centos-7-160216826a0 ~]$ ./sbcl-sad | |
;; submitting | |
;; submitting | |
;; submitting | |
;; submitting | |
;; submitting | |
;; submitting | |
;; submitting | |
;; submitting | |
;; submitting | |
;; submitting | |
;; locking | |
;; locked | |
;; *** other thread goes to sleep *** | |
;; unlocking | |
;; unlocked | |
;; locking | |
;; locked | |
;; unlocking | |
;; unlocked | |
;; locking | |
;; locked | |
;; unlocking | |
;; unlocked | |
;; locking | |
;; locked | |
;; unlocking | |
;; unlocked | |
;; locking | |
;; locked | |
;; unlocking | |
;; unlocked | |
;; locking | |
;; locked | |
;; unlocking | |
;; unlocked | |
;; locking | |
;; locked | |
;; unlocking | |
;; unlocked | |
;; locking | |
;; locked | |
;; unlocking | |
;; unlocked | |
;; locking | |
;; locked | |
;; unlocking | |
;; unlocked | |
;; locking | |
;; locked | |
;; unlocking | |
;; unlocked | |
;; *** other thread wakes up *** |
Linux dev-centos-7-160216826a0 3.10.0-693.11.1.el7.x86_64 #1 SMP Mon Dec 4 23:52:40 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
at Google Cloud Platform, source imagecentos-7-v20171025
is affectedLinux rozalia 4.4.0-28-generic #47-Ubuntu SMP Fri Jun 24 10:09:13 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
at Digital Ocean - not affectedLinux instance-1 4.9.0-4-amd64 #1 SMP Debian 4.9.51-1 (2017-09-28) x86_64 GNU/Linux
at GCP not affectedLinux instance-2 3.10.0-693.5.2.el7.x86_64 #1 SMP Fri Oct 20 20:32:50 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
at GCP, source imagecentos-7-v20171129
is also affectedLinux xxxx 3.10.0-514.6.1.el7.x86_64 #1 SMP Wed Jan 18 13:06:36 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
at Proxmox QEMU not affectedLinux ip-172-31-47-168 4.9.62-21.56.amzn1.x86_64 #1 SMP Thu Nov 16 05:37:08 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
at AWS, source imageamzn-ami-hvm-2017.09.1.20171120-x86_64-gp2 (ami-bf4193c7)
is affected
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Binary generated with
SBCL 1.4.1.debian
on:Linux odyssey 4.13.0-1-amd64 #1 SMP Debian 4.13.13-1 (2017-11-16) x86_64 GNU/Linux
works fine here.SCPed to:
Linux dev-centos-7-160216826a0 3.10.0-693.11.1.el7.x86_64 #1 SMP Mon Dec 4 23:52:40 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
@ Google Cloud Platform, source imagecentos-7-v20171025
behaves incorrectly.Both SBCL and CCL present same behavior.