[Issue 14025] New: unittests for memoize fail intermittently

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Jan 22 00:06:12 PST 2015


https://issues.dlang.org/show_bug.cgi?id=14025

          Issue ID: 14025
           Summary: unittests for memoize fail intermittently
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: Phobos
          Assignee: nobody at puremagic.com
          Reporter: r.sagitario at gmx.de

The phobos unittest for memoize fails rather often, lately.

core.exception.AssertError at std\functional.d(1092): unittest failure

It seems there's some issue with the initialization check in memoize:

        immutable idx1 = hash % maxSize;
        if (!bts(initialized.ptr, idx1))
            return emplace(&memo[idx1], args, fun(args)).res;
        else if (memo[idx1].args == args)
            return memo[idx1].res;

If the same hash happens to be used as one up the recursion chain, initialized
is already set, but arguments in memo[idx1].args are still garbage from the
GC.malloc call. If they happen to be identical to the current arguments, an
uninitialized result is returned.

It's mostly on Win64, but I've seen it on Win32, too.

--


More information about the Digitalmars-d-bugs mailing list