[BUG][FIX][TEST] CollectionAtRandom

Lukas Renggli renggli at student.unibe.ch
Tue Nov 4 19:21:21 UTC 2003


Sorry, the comments I wrote got lost somehow:

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

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.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Cheers,
Lukas & Adrian

-- 
Lukas Renggli
http://renggli.freezope.org




More information about the Squeak-dev mailing list