Bug 1175 - ConditionalWeakTable misbehavior with sgen collector
Summary: ConditionalWeakTable misbehavior with sgen collector
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: GC ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2011-10-01 12:17 UTC by Brian Luczkiewicz
Modified: 2011-11-30 14:25 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Program to reproduce the bug (1.41 KB, application/octet-stream)
2011-10-01 12:17 UTC, Brian Luczkiewicz
Details
A patch solving the problem (1.21 KB, patch)
2011-11-22 09:04 UTC, Gleb Golubitsky
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Brian Luczkiewicz 2011-10-01 12:17:59 UTC
Created attachment 551 [details]
Program to reproduce the bug

1. Download the attached file and name it 't.cs'
2. Compile with 'dmcs t.cs'
3. Run with 'mono-sgen t.exe'

Expected Result:

program runs forever, printing "loop 0\nloop 1\n..."


Actual Result:

program throws after ~250 iterations because an object disappeared from a ConditionalWeakTable that shouldn't have.

This bug only manifests with mono-sgen. If I run with mono (boehm), the program loops forever, as expected.
Comment 1 Brian Luczkiewicz 2011-10-01 12:19:58 UTC
Ack..forgot to specify. I'm running mono 2.10.5 on OSX Lion.
Comment 2 Zoltan Varga 2011-10-04 18:23:03 UTC
Can't reproduce this with HEAD/mono 2.10 branch on linux.
Comment 3 Brian Luczkiewicz 2011-10-05 14:03:54 UTC
I can not reproduce this on linux either.

I just checked out the git repository on an osx/lion machine + tried with both HEAD and 2.10. The bug is present in both.

This bug is looking osx specific.
Comment 4 Rodrigo Kumpera 2011-11-07 20:11:34 UTC
I've tried with master/2.10 on OSX/lion  and it works fine.

There has been a regression on this area that has been fixed since.
Comment 5 Gleb Golubitsky 2011-11-21 08:39:38 UTC
Just reproduced on commit d6be15f97bc5727a0dff04dd4cd288f9c99b1660

Here is an output of the test code: http://pastebin.com/ZKTpinu1
Comment 6 Gleb Golubitsky 2011-11-21 08:41:20 UTC
if i run the sample without sgen GC -- the test works as expected
Comment 7 Gleb Golubitsky 2011-11-22 09:04:49 UTC
Created attachment 929 [details]
A patch solving the problem

A patch solving the problem. It's against current mono-2.10 branch.

The patch is very simple -- it doesn't allow GC to skip scanning all ephemerons arrays basing only on an array address. Such skips are big mistake, bcs if an array allocated in different region it can contain references to the region we scanning. So it's necessary to scan all available arrays.

Applying patch fixes problem (test case passes well).
Comment 8 Brian Luczkiewicz 2011-11-30 14:25:25 UTC
I've tested your patch out by hand against 2.10.6. It does indeed fix the problem. It also solves another sgen-related crash that I was having trouble making a small test case for. Great work!