Ian Fairclough wrote:

I have managed to re-create an isolated problem which might be interesting.

When I try to increase the size of the view for the attached data file by 1, I get a core dump as follows :
[...]

It looks like this is a serious file-damaging bug in Metakit (at least 2.4.9.2, probably a few before, this is tied to subview caching and open/save optimizations).

I've just checked in a change to Metakit which passes all tests, including the new one which brought it all out in the open. The test is frighteningly simple:

  {
    c4_Storage s1 ("t1.dat", true);
    c4_View v1 = s1.GetAs("v1[v2[p1:I]]");
    v1.SetSize(1);
    s1.Commit();
  }
  // start with a valid non-empty view with a subview
  {
    c4_Storage s1 ("t1.dat", true);
    c4_View v1 = s1.View("v1");
    v1.SetSize(0);
    s1.Commit();
    v1.SetSize(1);
    s1.Commit();
    // at this point, the 2.4.9.2 file is corrupt!
    s1.SaveTo(c4_FileStream (fopen("t2.dat", "w"), true));
  }
  // using this damaged datafile will then crash
  {
    c4_Storage s1 ("t1.dat", true);
    c4_View v1 = s1.View("v1");
    v1.SetSize(2);
  }

In plain English: you have to delete all rows of a view with subviews, commit, resize to create a new row with an empty subview, and commit. That produces a damaged MK datafile. leaving out the first commit works fine. Closing and re-opening works fine. Only the sequence above seems to have all the ingedients to trigger the bug.

Blocked views use subviews and modify them constantly, but as far as I can tell they can *never* lead to the above usage pattern (blocks don't get resized to zero *and* re-used). So although blocked views are probably the most common use for subviews, they will not hit this bug.

I've checked in changes to CVS. I'll soon release a 2.4.9.3 update, but would also like to ask you to give the current sources in CVS a very good work-out. There are almost no changes to the core since the MK 2.4.9.2 release in March 2003, so I don't expect any regression of the code at all (bugs nor performance). If you doubt it, please run some checks.

I'd also like to very much thank Ian Fairclough for patiently digging in, to get the issue to the surface and for ultimately coming up with a simple stand-alone example I could use to reproduce the problem and drill down into. It made *ALL* the difference in the world!

Let's hope this fully resolves the issue.

-jcw

_____________________________________________
Metakit mailing list  -  [EMAIL PROTECTED]
http://www.equi4.com/mailman/listinfo/metakit

Reply via email to