This project is read-only.
1
Vote

Lazy<T> and Volatile causes Execution Timeout Error

description

Hi there!
 
I encountered another problem using Alpaca.
I get an Execution Timeout Error with the hint to an "This is a strong indication of a livelock". But to be honest, I've no idea where this might occur.
Any help is highly welcome :-)
 
Here's my test code:
 
using System;
using System.Threading.Tasks;
using Microsoft.Concurrency.TestTools.UnitTesting;
 
namespace MOCTestProject
{
public class AlpacaTest7
{
    [DataRaceTestMethod]
    public void VolatileTest()
    {
        var lazy1 = new Lazy<Item3>();
 
        Item3 item1 = null;
        Item3 item2 = null;
 
        Parallel.Invoke(
            () => { item1 = lazy1.Value; },
            () => { item2 = lazy1.Value;  }
            );
 
        Assert.IsNotNull(item1);
        Assert.IsNotNull(item2);
    }
 
    public class Item3
    {
        private volatile bool done;
 
        public Item3()
        {
            done = Text != "Text";
            if (done == false)
                Text = "Test";
        }
 
        public string Text { get; private set; }
    }
}
}

comments