Bug on C++ GC

Monkey Forums/Monkey Bug Reports/Bug on C++ GC

ziggy(Posted 2014) [#1]
This code shows the issue:
Strict
#CPP_GC_MODE=2

Class Fake
	Field z:= New List<String>
End

Function Main:Int()
	Local f:Fake
	Repeat
		f = New Fake()
		
		f = Null
	Forever
End

It just crashes after some seconds.


dawlane(Posted 2014) [#2]
@ziggy: Which OS? And what kind of crash? On Linux with out using mode 2 it crashes within 30 seconds and takes the OS with it.
I added a loop counter, set mode 2 and left it run on Linux in release and debug mode. It crashed with a MAV on the 786433 iteration in both release and debug while creating a new instance.

Edit: Yet it looks like the code is working correctly on the Desktop target.


ziggy(Posted 2014) [#3]
It crashes very soon on Windows 7 32 bits. Haven't tested on 64 bits, but I guess it's the same.


dawlane(Posted 2014) [#4]
After doing a little playing around in with the C++ in Code Blocks in Linux. The gc has a problem when a gc sweep is triggered. gc_unmarked_list.succ is coming back as invalid/Null.
I tested a number of combinations. Using ziggy's example above
1) Add something to the class instance list data member and there is no problem. If you don't add any thing then result MAV.
2) Remove all code related to the list member and added a normal class integer data member variable with a default value in the class definition. Result MAV
3) Same as 2, but instead of setting the value in the definition. I initialised the data member in the loop. Result Mav.
I also tried using a few other data types with tests 2 & 3 with the same results. I haven't test Maps, but I will have a guess that it would be the same as it is for lists. I haven't tested this out on the Desktop target yet.


ziggy(Posted 2014) [#5]
The sample I provided was related to some very strange things I had while working on Jungle Gui, and also related to a forum post in the general discussion forum. It's a constant issue, replicable always, so something definitively worth fixing


dawlane(Posted 2014) [#6]
Edit: Yet it looks like the code is working correctly on the Desktop target.
I'll change that statement . It's not.
I've check this out so far on the 32bit and 64bit versions of Linux. The 32bit version chokes at 1572865 iterations. It doesn't matter if you null any data member or not. It will still crash with a MAV.

Is this code problem occurring with just the GNU tool chain or is it happening with the Visual Studio tools as well?

Running Valgrind on Linux gives very little information apart from an
Invalid write of size 4
at 0x807AA35: bbMain()
by 0x807B0D1: bb_std_main(int, char const**)
Address 0x8 is not stack'd, malloc'd or (recently) free'd.

Which could be any thing from writing below the stack to null pointer or object.


marksibly(Posted 2014) [#7]
Definitely a monkey bug. The problem is in the 'move marked to unmarked' section of gc_sweep - see if you can spot it for mega bonus points!

Will be fixed in next release...will commit a bit later today too.