[elephant-devel] serializer not thread safe!

Ian Eslick eslick at media.mit.edu
Wed May 28 12:26:48 UTC 2008


Good catch!  I'll promote that.  I think the original intention was to  
minimize locking, but you are correct in observing that the corner  
case of length = 1 can lead to errors.

Thanks,
Ian

On May 28, 2008, at 5:26 AM, Alex Mizrahi wrote:

> obviously broken code:
>
> (defun get-circularity-hash ()
>  "Get a clean hash for object serialization"
>  (declare (type fixnum *circularity-initial-hash-size*))
>  (if (= 0 (length *circularity-hash-queue*))
>      (make-hash-table :test 'eq :size *circularity-initial-hash-size*)
>      (ele-with-fast-lock (*serializer-fast-lock*)
>        (vector-pop *circularity-hash-queue*))))
>
> concurrent call could happen between check and pop, thus  
> invalidating the
> check.
>
> (defun get-cicularity-hash ()
>   (or
>      (ele-with-fast-lock (*serializer-fast-lock*)
>        (and (plusp (length *circularity-hash-queue*))
>             (vector-pop *circularity-hash-queue*)))
>      (make-hash-table :test 'eq :size *circularity-initial-hash- 
> size*)))
>
>
>
>
> _______________________________________________
> elephant-devel site list
> elephant-devel at common-lisp.net
> http://common-lisp.net/mailman/listinfo/elephant-devel




More information about the elephant-devel mailing list