dmd memory usage/static lib/algorithm bug?

Marek Janukowicz marek at janukowicz.net
Wed Aug 28 14:02:17 PDT 2013


I was finally able to create simple test case that probably reproduces the 
bug (probably, because the stack trace is completely different, but the code 
that is there is similar). This requires 2 source code files:

main.d:

module main;

// This line must be there - import any module from std causes is necessary 
to
// reproduce the bug
import std.stdio;

import sorter;

void main () {
} 

-------------------

sorter.d:

module sorter;

import std.algorithm;

  struct Val {
    int i;
  }

unittest {
  Val [] arr;
  arr ~= Val( 2 );
  arr ~= Val( 1 );

  // This works
  arr.sort!((Val a, Val b) { return a.i < b.i; });

  // This segfaults when sorting
  auto dg = (Val a, Val b) { return a.i < b.i; };
  arr.sort!(dg);

}

------------------

Run with: 

dmd -unittest main.d sorter.d && ./main

For me this results in a segfault. Changing one of many seemingly unrelated 
details (eg. moving offending code directly to main, commenting out 
std.stdio import in main.d) makes the problem disappear.

Can anyone try to reproduce that? Again, I'm on DMD 2.063.2.

H. S. Teoh - thanks for your detailed description, but this test case 
probably sheds some more light and invalidates some of your hyphotheses. As 
for building static library - I thought it would be easier, so if the bug 
remains unresolved I'll probably just rebuild the whole phobos. The problem 
is definitely not some old version of libphobos2.a stuck around, because the 
problem could be reproduced exactly the same way on 3 machines I tried.

-- 
Marek Janukowicz


More information about the Digitalmars-d-learn mailing list