Bug 10463 – dirEntries() segfaults on paths the user does not have access to

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2013-06-24T06:36:00Z
Last change time
2013-07-03T07:33:37Z
Assigned to
nobody
Creator
kevin.lamonte
Depends on
8563

Comments

Comment #0 by kevin.lamonte — 2013-06-24T06:36:07Z
Code to reproduce: ---- import std.stdio; import std.file; void main(string [] args) { string path = args[1]; stdout.writefln("Iterating directory: %s", path); foreach (string name; dirEntries(path, SpanMode.shallow)) { stdout.writefln("%s", name); } } ---- Good execution: $ rdmd test.d /home Iterating directory: /home /home/lost+found /home/kevinl Bad execution: $ rdmd test.d /home/lost+found Iterating directory: /home/lost+found Segmentation fault (core dumped) gdb backtrace: $ dmd test.d $ gdb test GNU gdb (GDB) 7.4.1-debian Copyright (C) 2012 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Reading symbols from /home/kevinl/code/d-tui/test...(no debugging symbols found)...done. (gdb) set args /home/lost+found (gdb) ru Starting program: /home/kevinl/code/d-tui/test /home/lost+found [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Iterating directory: /home/lost+found Program received signal SIGSEGV, Segmentation fault. 0x0000000000465805 in std.typecons.__T10RefCountedTS3std4file15DirIteratorImplVE3std8typecons24RefCountedAutoInitialize0Z.RefCounted.__dtor() () (gdb) bt #0 0x0000000000465805 in std.typecons.__T10RefCountedTS3std4file15DirIteratorImplVE3std8typecons24RefCountedAutoInitialize0Z.RefCounted.__dtor() () #1 0x00007ffff7fd38c0 in ?? () #2 0x00007fffffffd8f0 in ?? () #3 0x00000000004658ed in std.file.DirIterator.__fieldDtor() () #4 0x0000000000470300 in ?? () #5 0x00007fffffffdeb0 in ?? () #6 0x00000000004540b3 in D main () #7 0x00007fffffffda50 in ?? () #8 0x00007fffffffdd10 in ?? () #9 0x0000000000460bc2 in _d_throwc () #10 0x00007fffffffe020 in ?? () #11 0x00007fffffffe070 in ?? () #12 0x00000000006d8da0 in ?? () #13 0x00007fffffffdd10 in ?? () #14 0x0000000000000002 in ?? () #15 0x00007fffffffdeb0 in ?? () #16 0x0000000000454020 in D main () #17 0x00007fffffffd958 in ?? () #18 0x00007fffffffdeb0 in ?? () #19 0x000000000049cb30 in _TMP296 () #20 0x000000000069e3f0 in __dso_handle () #21 0x0000000000453f80 in frame_dummy () #22 0x0000000000000001 in ?? () #23 0x000000000069e400 in _HandlerTable0 () #24 0x000000000069e418 in _HandlerTable0 () #25 0x00007ffff7fd38c0 in ?? () #26 0x0000000000000000 in ?? ()
Comment #1 by nilsbossung — 2013-06-26T19:11:54Z
Marking as depending on 8563 instead of being a duplicate, because this is a phobos bug that may be fixable by working around the dmd issue.
Comment #2 by nilsbossung — 2013-07-03T07:33:37Z
Issue 8563 is fixed. The test case of this issue now throws a nice "Permission denied" exception. Closing.