Bug 18667 – Segfault in std.file.dirEntries

Status
NEW
Severity
major
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2018-03-26T23:39:59Z
Last change time
2024-12-01T16:33:10Z
Keywords
bootcamp
Assigned to
No Owner
Creator
Seb
Moved to GitHub: phobos#10323 →

Comments

Comment #0 by greensunny12 — 2018-03-26T23:39:59Z
DScanner sometimes segfaults in dirEntries: --- 0x00007ffff6fa6fb6 in __readdir (dirp=0x0) at ../sysdeps/posix/readdir.c:44 44 ../sysdeps/posix/readdir.c: No such file or directory. #0 0x00007ffff6fa6fb6 in __readdir (dirp=0x0) at ../sysdeps/posix/readdir.c:44 #1 0x0000000000a89169 in std.file.DirIteratorImpl.next() (this=...) at std/file.d:4029 #2 0x0000000000a89628 in std.file.DirIteratorImpl.popFront() (this=...) at std/file.d:4133 #3 0x0000000000a898e9 in std.file.DirIterator.popFront() (this=...) at std/file.d:4155 #4 0x00000000008c8da1 in dsymbol.modulecache.ModuleCache.addImportPaths() (this=0x7ffff7ee9530, root=...) at dsymbol/src/dsymbol/modulecache.d:133 #5 0x00000000008c8d95 in dsymbol.modulecache.ModuleCache.addImportPaths() (this=0x7ffff7ee9530, root=...) at dsymbol/src/dsymbol/modulecache.d:132 #6 0x00000000008c8d95 in dsymbol.modulecache.ModuleCache.addImportPaths() (this=0x7ffff7ee9530, root=...) at dsymbol/src/dsymbol/modulecache.d:132 #7 0x00000000008c8bcb in dsymbol.modulecache.ModuleCache.addImportPaths() (this=..., paths=...) at dsymbol/src/dsymbol/modulecache.d:136 #8 0x0000000000a565ed in D main (args=...) at src/main.d:151 #9 0x0000000000a75784 in rt.dmain2._d_run_main() (this=0x7fffffffe3e0) at src/rt/dmain2.d:508 #10 0x0000000000a755cc in rt.dmain2._d_run_main() (this=0x7fffffffe3e0, dg=...) at src/rt/dmain2.d:469 #11 0x0000000000a756d9 in rt.dmain2._d_run_main() (this=0x7fffffffe3e0) at src/rt/dmain2.d:508 #12 0x0000000000a755cc in rt.dmain2._d_run_main() (this=0x7fffffffe3e0, dg=...) at src/rt/dmain2.d:469 #13 0x0000000000a75530 in _d_run_main (argc=7, argv=0x7fffffffe4e8, mainFunc=0xa56010 <D main>) at src/rt/dmain2.d:528 #14 0x0000000000a63a0e in main () --- https://github.com/dlang/phobos/pull/6344 I haven't been able to reproduce this locally and segfault is copied from the failing CircleCi run. The Dlang side: https://github.com/dlang/phobos/blob/4c4c37d0b464df05e2f5298d4ddc9b6a9f16bb1b/std/file.d#L4029 for (dirent* fdata; (fdata = readdir(_stack[$-1].h)) != null; ) The glibc side: https://github.molgen.mpg.de/git-mirror/glibc/blob/master/sysdeps/posix/readdir.c #ifndef __READDIR # define __READDIR __readdir ... #endif __READDIR (DIR *dirp) { DIRENT_TYPE *dp; int saved_errno = errno; #if IS_IN (libc) __libc_lock_lock (dirp->lock); #endif So it looks like we are passing a null pointer to readdir. A first start would be to modify the dirEntries implementation to ensure that no invalid data is passed to readdir by e.g. adding more asserts.
Comment #1 by greensunny12 — 2018-03-28T06:29:04Z
Another related segfault from Phobos's CircleCi --- Program received signal SIGHUP, Hangup. __lll_lock_wait_private () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95 95 ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S: No such file or directory. #0 __lll_lock_wait_private () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95 #1 0x00007ffff6fa7068 in _L_lock_29 () from /lib/x86_64-linux-gnu/libc.so.6 #2 0x00007ffff6fa6fc0 in __readdir (dirp=0x7ffff7f2af84) at ../sysdeps/posix/readdir.c:44 #3 0x0000000000aca6d1 in std.file.DirIteratorImpl.next() (this=...) at std/file.d:4555 #4 0x0000000000acab90 in std.file.DirIteratorImpl.popFront() (this=...) at std/file.d:4659 #5 0x0000000000acae39 in std.file.DirIterator.popFront() (this=...) at std/file.d:4681 #6 0x00000000008f9e65 in dsymbol.modulecache.ModuleCache.addImportPaths() (this=0x7ffff7ee9560, root=...) at dsymbol/src/dsymbol/modulecache.d:133 #7 0x00000000008f9e59 in dsymbol.modulecache.ModuleCache.addImportPaths() (this=0x7ffff7ee9560, root=...) at dsymbol/src/dsymbol/modulecache.d:132 #8 0x00000000008f9e59 in dsymbol.modulecache.ModuleCache.addImportPaths() (this=0x7ffff7ee9560, root=...) at dsymbol/src/dsymbol/modulecache.d:132 #9 0x00000000008f9c8f in dsymbol.modulecache.ModuleCache.addImportPaths() (this=..., paths=...) at dsymbol/src/dsymbol/modulecache.d:136 #10 0x0000000000a1896b in D main (args=...) at src/dscanner/main.d:158 #11 0x0000000000ab5d74 in rt.dmain2._d_run_main() (this=0x7fffffffe3c0) at src/rt/dmain2.d:508 #12 0x0000000000ab5bbc in rt.dmain2._d_run_main() (this=0x7fffffffe3c0, dg=...) at src/rt/dmain2.d:469 #13 0x0000000000ab5cc9 in rt.dmain2._d_run_main() (this=0x7fffffffe3c0) at src/rt/dmain2.d:508 #14 0x0000000000ab5bbc in rt.dmain2._d_run_main() (this=0x7fffffffe3c0, dg=...) at src/rt/dmain2.d:469 #15 0x0000000000ab5b20 in _d_run_main (argc=7, argv=0x7fffffffe4c8, mainFunc=0xa18328 <D main>) at src/rt/dmain2.d:528 #16 0x0000000000a26f82 in main () ---
Comment #2 by bugzilla — 2018-04-06T04:31:59Z
Raising importance to major because of its disruption to the auto testing.
Comment #3 by greeenify — 2018-05-05T02:08:42Z
Comment #4 by robert.schadek — 2024-12-01T16:33:10Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/10323 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB