D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3897 - Sporadic incorrectness with builtin AAs
Summary: Sporadic incorrectness with builtin AAs
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 regression
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-08 06:38 UTC by David Simcha
Modified: 2014-02-15 02:43 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description David Simcha 2010-03-08 06:38:43 UTC
Here's about the best I can do to reproduce this issue.  It showed up in a monte carlo unittest of one of my associative array implementations that tested whether it gets the same answers as the builtin implementation.  Probably some subtle memory corruption issue.

import std.stdio, std.random, std.conv;

void main() {
    // Monte carlo unit test builtin hash table.
    uint[uint] table;
    auto gen = Random(42);
    foreach(i; 0..1_000_000) {
        auto num1 = gen.front();
        gen.popFront();
        auto num2 = gen.front();
        gen.popFront();

        table[num1] = num2;
    }

    // Note that we're using the same seed again.
    gen = Random(42);
    foreach(i; 0..1_000_000) {
        auto num1 = gen.front();
        gen.popFront();
        auto num2 = gen.front();
        gen.popFront();

        assert(num1 in table);
        assert(table[num1] == num2);
    }
}
Comment 1 David Simcha 2010-03-08 06:54:19 UTC
Never mind.  I filed this report in a hurry.  While I still think something screwy is going on with the builtin AAs, this is not a valid way to reproduce it.  Will file a new report when I have more time to look into the problem.