www.digitalmars.com         C & C++   DMDScript  

D.gnu - [Bug 233] New: crash in memory allocator

http://bugzilla.gdcproject.org/show_bug.cgi?id=233

            Bug ID: 233
           Summary: crash in memory allocator
           Product: GDC
           Version: 5.x
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: High
         Component: libgdruntime
          Assignee: ibuclaw gdcproject.org
          Reporter: sebastien.alaiwan gmail.com

The following program, making random allocations, segfaults quickly:

$ cat fuzzalloc.d
import std.stdio;
import std.random;

int main(string[] args)
{
  // make the issue appear sooner
  {
    import core.memory;
    GC.disable();
  }

  Random gen;

  gen.seed(1234);

  long[][1000] tabs;

  for(int k=0;;++k)
  {
    if(k%100000 == 0)
      writeln(k);

    {
      const i = uniform(0, tabs.length, gen);
      tabs[i].length = uniform(0, 10000, gen);
    }

    if(uniform(0, 2, gen))
    {
      const i = uniform(0, tabs.length, gen);
      const j = uniform(0, tabs.length, gen);
      tabs[i] = tabs[j];
    }
  }

  return 0;
}

$ gdc -O3 fuzzalloc.d -o fuzzalloc && ./fuzzalloc
0
100000
200000
300000
400000
500000
[1]    9902 segmentation fault  ./fuzzalloc

-- 
You are receiving this mail because:
You are watching all bug changes.
Jul 15 2016