Bugzilla – Bug 319969
[PATCH] set null to WeakReference.Target doesn't work
Last modified: 2007-09-15 21:24:46 UTC
---- Reported by BurlachenkoO@mail.ru 2006-01-06 10:54:23 MST ---- Description of Problem: set null to WeakReference.Target doesn't work Steps to reproduce the problem: I execute such code in C# console project: using System; namespace Mono_GC { class A{} class Class1 { [STAThread] static void Main(string[] args) { A a = new A(); WeakReference weak = new WeakReference(a); Console.WriteLine("weak.Target = " + a); if(weak.Target != null) Console.WriteLine("weak.Target != null"); else Console.WriteLine("weak.Target == null"); weak.Target = null; Console.WriteLine("weak.Target = null"); if(weak.Target != null) Console.WriteLine("test failed"); else Console.WriteLine("test passed"); Console.WriteLine("Weak reference test has been finished."); } } } Actual Results: weak.Target = Mono_GC.A weak.Target != null weak.Target = null test failed Weak reference test has been finished. Expected Results: weak.Target = Mono_GC.A weak.Target != null weak.Target = null test passed Weak reference test has been finished. How often does this happen? every run ---- Additional Comments From robertj@gmx.net 2006-01-07 18:12:10 MST ---- This is a minor bug in gc.c:mono_gchandle_set_target () ---- Additional Comments From robertj@gmx.net 2006-01-07 18:12:59 MST ---- Created an attachment (id=169042) gc.diff ---- Additional Comments From vargaz@gmail.com 2006-01-11 10:54:07 MST ---- This is ok to check in. ---- Additional Comments From vargaz@gmail.com 2006-01-11 10:57:18 MST ---- It may be better to add this mono_gc_weak_link_remove () in boehm-gc.c ---- Additional Comments From robertj@gmx.net 2006-01-11 11:50:48 MST ---- Like this? ---- Additional Comments From robertj@gmx.net 2006-01-11 11:51:29 MST ---- Created an attachment (id=169043) gc2.diff ---- Additional Comments From vargaz@gmail.com 2006-01-18 10:32:42 MST ---- Yes. ---- Additional Comments From robertj@gmx.net 2006-01-18 11:25:38 MST ---- Fixed in SVN 55725. Imported an attachment (id=169042) Imported an attachment (id=169043)