[squeak-dev] The Trunk: CollectionsTests-Igor.Stasenko.172.mcz

commits at source.squeak.org commits at source.squeak.org
Mon Oct 11 10:46:11 UTC 2010


Igor Stasenko uploaded a new version of CollectionsTests to project The Trunk:
http://source.squeak.org/trunk/CollectionsTests-Igor.Stasenko.172.mcz

==================== Summary ====================

Name: CollectionsTests-Igor.Stasenko.172
Author: Igor.Stasenko
Time: 11 October 2010, 1:46:44.419 pm
UUID: b2dcc937-caa3-3a4e-8e42-8c001e8b1d54
Ancestors: CollectionsTests-ar.171

- added test to check if manipulation with weak registry from #finalize leads to deadlock.

- currently fails for older VMs
- should not fail for VMs with new finalization support

=============== Diff against CollectionsTests-ar.171 ===============

Item was added:
+ Object subclass: #VileFinalizer
+ 	instanceVariableNames: 'weakRegistry'
+ 	classVariableNames: ''
+ 	poolDictionaries: ''
+ 	category: 'CollectionsTests-Weak'!

Item was added:
+ ----- Method: VileFinalizer>>finalize (in category 'as yet unclassified') -----
+ finalize
+ 	weakRegistry remove: self ifAbsent: [].!

Item was added:
+ ----- Method: VileFinalizer>>initialize: (in category 'as yet unclassified') -----
+ initialize: wr
+ 	weakRegistry := wr.
+ 	weakRegistry add: self.!

Item was added:
+ ----- Method: WeakRegistryTest>>testVileFinalizer (in category 'tests') -----
+ testVileFinalizer
+ 	" this test checks that manipulation (or accessing) weak registry 
+ 	does not leads to deadlock, when performed from within #finalize implementation"
+ 	
+ 	| reg villian proc locked |
+ 	
+ 	reg := WeakRegistry new.
+ 	WeakArray removeWeakDependent: reg.  "to prevent test interference with finalization process"
+ 	
+ 	villian := VileFinalizer new initialize: reg.  "add object with vile finalization to registry"
+ 	
+ 	locked := true. "be pessimistic"
+ 
+ 	proc := [ reg finalizeValues. locked := false ] newProcess.
+ 	villian := nil.	
+ 	Smalltalk garbageCollect.
+ 	
+ 	proc resume.
+ 	100 milliSeconds asDelay wait. "give chance for created process to run "
+ 	
+ 	proc isTerminated ifFalse: [ proc terminate ].
+ 
+ 	self assert: locked == false.
+ !




More information about the Squeak-dev mailing list