Search code examples
c#exceptionstack-overflowdb4o

db4o bug when using UniqueFieldValueConstraint on a string field of an instance that also has a member of type object?


I think I may have encountered a possible bug with db4o 8.0 for .NET, as the following will produce a StackOverFlow exception.

public static void Test() {
    var config = Db4oEmbedded.NewConfiguration();
    var field = "ID";
    config.Common.ObjectClass(typeof(TestClass)).ObjectField(field).Indexed(true);
    config.Common.Add(new UniqueFieldValueConstraint(typeof(TestClass), field));
    var db = Db4oEmbedded.OpenFile(config, "test.yap");
    db.Store(new TestClass());
    db.Commit();
}

public class TestClass {
    //[NonSerialized]
    public object DataMember = new object();

    public string ID;
}

In my case I was able to mark DataMember as Transient ([NonSerialized]) and avoid the issue.

However this makes it impossible to use the DataMember in a predicate (in my case, DataMember is a simple object used as a lock in all properties, but it is like if the constructor of TestClass were not called as DataMember is null within the predicate).

Do you have any idea why it would not work? Shall I file a bug report?


Solution

  • I have filed a bug which was acknowledged as Major: http://tracker.db4o.com/browse/COR-2296.