Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Corruption of keys in an aa

Moderators: kris

Posted: 09/10/08 17:23:46

I've found some kind of bug with associative arrays, which may be to do with tango's core lib or may not be. Using dmd 1.035 (& 1.033), tango r3935.

The problem is that a small char[] key is put into an associative array, and then when the array is iterated, this key has a size of nearly 2GB (I think the length has been the same every time I output it). This is an intermittent problem (although it happens most times I try now). I haven't tried creating a small test-case for the problem (because roughly this code used to work until quite recently, and what's causing it isn't at all obvious). Here's a snippet:

            // Types:
            // interface IDataSection {...}
            // class Options {...}
            // alias char[] ID;
            // IDataSection[ID] ds.sec;
            // Options[ID] subClasses;
            DataSet ds = new DataSet();
            foreach (id, subOpts; subClasses) {
                ds.sec[id] = subOpts.optionChanges;
                debug logger.trace ("Saving options section: "~id);
            }
            foreach (i,s; ds.sec)
                debug logger.trace ("sec ID length: {}", i.length);
            debug logger.trace ("0"); // never reached

And here's the output:

1758  Trace mde.lookup.Options - Saving options section: misc
1758  Trace mde.lookup.Options - Saving options section: font
1758  Trace mde.lookup.Options - Saving options section: video
1758  Trace mde.lookup.Options - sec ID length: 1931506542
fish: Job 1, “bin/mde” terminated by signal SIGSEGV (Address boundary error)
Author Message

Posted: 09/11/08 12:15:07

I just ported my app back to tango 0.99.6 and got the same result (same length), so it's probably not a tango issue.

If anyone has ideas of what it could be that'd be great, otherwise I'll just have to keep fiddling with code.

Posted: 09/12/08 15:49:23

My bad. I deleted an object twice which caused widespread mayhem *grins*