www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17402] New: dirEntries iterator crashes in conjunction with

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

          Issue ID: 17402
           Summary: dirEntries iterator crashes in conjunction with
                    readText
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: razvan.nitu1305 gmail.com

The following code crashes:

auto dFiles = dirEntries("dmd/phobos/std/", "*.d", SpanMode.depth);
foreach (d; dFiles)
{
    string input = readText(d.name);
}

It seems that somehow readText breaks the dirEntries iterator. It works for the
first five files but then it crashes with the following error message:

/home/razvan/dmd/dmd/generated/linux/release/64/dmd(_D4core7runtime18runModuleUnitTestsUZ19unittestSegvHandlerUNbiPS4core3sys5posix6signal9siginfo_tPvZv+0x38)[0x8244a4]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f059337a390]
/lib/x86_64-linux-gnu/libc.so.6(readdir+0x32)[0x7f05925be8a2]
/home/razvan/dmd/dmd/generated/linux/release/64/dmd(_D3std4file15DirIteratorImpl4nextMFZb+0xa5)[0x815fa5]
/home/razvan/dmd/dmd/generated/linux/release/64/dmd(_D3std4file15DirIteratorImpl8popFrontMFZv+0x3f)[0x8162e7]
/home/razvan/dmd/dmd/generated/linux/release/64/dmd(_D3std4file11DirIterator8popFrontMFZv+0x11)[0x816665]
/home/razvan/dmd/dmd/generated/linux/release/64/dmd(_D3std9algorithm9iteration125__T12FilterResultS80_D3std4file10dirEntriesFAyaAyaE3std4file8SpanModebZ1fMFNaNbS3std4file8DirEntryZbTS3std4file11DirIteratorZ12FilterResult8popFrontMFZv+0x24)[0x816ed4]
/home/razvan/dmd/dmd/generated/linux/release/64/dmd(_D4ddmd5parse18__unittestL8445_11FZv+0x134)[0x6c3bac]
/home/razvan/dmd/dmd/generated/linux/release/64/dmd(_D4ddmd5parse9__modtestFZv+0x9)[0x6db0c9]
/home/razvan/dmd/dmd/generated/linux/release/64/dmd(_D4core7runtime18runModuleUnitTestsUZ14__foreachbody2MFPS6object10ModuleInfoZi+0x2d)[0x8244f1]
/home/razvan/dmd/dmd/generated/linux/release/64/dmd(_D6object10ModuleInfo7opApplyFMDFPS6object10ModuleInfoZiZ9__lambda2MFyPS6object10ModuleInfoZi+0x23)[0x8099c3]
/home/razvan/dmd/dmd/generated/linux/release/64/dmd(_D2rt5minfo17moduleinfos_applyFMDFyPS6object10ModuleInfoZiZ14__foreachbody2MFKS2rt19sections_elf_shared3DSOZi+0x56)[0x80ece6]
/home/razvan/dmd/dmd/generated/linux/release/64/dmd(_D2rt19sections_elf_shared3DSO7opApplyFMDFKS2rt19sections_elf_shared3DSOZiZi+0x46)[0x80f04a]
/home/razvan/dmd/dmd/generated/linux/release/64/dmd(_D2rt5minfo17moduleinfos_applyFMDFyPS6object10ModuleInfoZiZi+0x22)[0x80ec72]
/home/razvan/dmd/dmd/generated/linux/release/64/dmd(_D6object10ModuleInfo7opApplyFMDFPS6object10ModuleInfoZiZi+0x22)[0x80999a]
/home/razvan/dmd/dmd/generated/linux/release/64/dmd(runModuleUnitTests+0x9d)[0x8243d1]
/home/razvan/dmd/dmd/generated/linux/release/64/dmd(_D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZv+0x17)[0x80cb8b]
/home/razvan/dmd/dmd/generated/linux/release/64/dmd(_D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ7tryExecMFMDFZvZv+0x24)[0x80cb28]
/home/razvan/dmd/dmd/generated/linux/release/64/dmd(_d_run_main+0x1e0)[0x80ca8c]
/home/razvan/dmd/dmd/generated/linux/release/64/dmd(main+0x22)[0x69ef7a]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f0592517830]
/home/razvan/dmd/dmd/generated/linux/release/64/dmd(_start+0x29)[0x5a9719

--
May 16