www.digitalmars.com         C & C++   DMDScript  

D - BUG: 2nd GC Run Segfaults

DMD 0.68, on RedHat 9

When the GC runs twice, the second run segfaults.  It turns out that it 
segfaults when the code attempts to use the Thread reference.  For some 
reason, the Thread object was cleaned up on the first run of the GC!

The following code generates an error:

	import gc;
	import c.stdio;
  	int main(char[][] args)
	  printf("Starting test!\n"); fflush(null);
	  return 0;

The output, after I added some trace statements into phobos, looks like 

	fullcollect: START
	fullcollect: END
	Starting test!
	fullcollect: START
	 threads:0/1 t=0x401b9fc0 *(long*)t=0x804e129Thread.~this(): 
	fullcollect: END
	fullcollect: START
	 threads:0/1 t=0x401b9fc0 *(long*)t=(nil)Segmentation fault

The key thing to note is that Thread.~this() gets called during 
Jul 16 2003