[FIX] CollectionAtRandom

marcus at ira.uka.de marcus at ira.uka.de
Thu Nov 6 11:47:30 UTC 2003


from preamble:

"Change Set:		CollectionAtRandom
Date:			6 November 2003
Author:			Lukas Renggli

md: Just the latest version with a correct chanset preamble... ;-)

-additional changes (and [et] [er]) from stepane.

The message #atRandom is not thread-save when being used concurrently on
different collections or integers. As a test try to evaluate the
following expressions in your image, the random generator provided by
Collection gets corrupted:

        [ [ (1 to: 100) atRandom ] repeat ] forkAt: 30.
        [ [ 100 atRandom ] repeat ] forkAt: 30.
        
This is a critical bug!! As an example the superb web-framework Seaside
uses random key-generation to identify its sessions. If other threads in
your image use #atRandom problems might arise.

The attached change-set solves the problem by introducing a critical
section to the Collection class providing the random generator."!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CollectionAtRandom.cs.gz
Type: application/octet-stream
Size: 1232 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20031106/54f84ee2/CollectionAtRandom.cs.obj


More information about the Squeak-dev mailing list