[Issue 21728] New: rawRead calls fread with NULL if invoked on closed readEnd of Pipe (segfault)

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Mar 18 10:59:33 UTC 2021


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

          Issue ID: 21728
           Summary: rawRead calls fread with NULL if invoked on closed
                    readEnd of Pipe (segfault)
           Product: D
           Version: D2
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: kdevel at vogtner.de

```n1.d
import std.stdio;
import std.process;

void main ()
{
   auto p = pipe ();
   p.readEnd.close;
   ubyte [1] u;
   auto n = p.readEnd.rawRead (u);
}
```

$ dmd -g n1.d
$ gdb ./n1
[...]
(gdb) r
[...]
Program received signal SIGSEGV, Segmentation fault.
0xXXXXXXXXXXXXXXXX in fread () from /lib64/libc.so.6
[...]
(gdb) bt
#0  0xXXXXXXXXXXXXXXXX in fread () from /lib64/libc.so.6
#1  0xXXXXXXXXXXXXXXXX in std.stdio() (obj=..., f=0x0) at
[...]/dmd2/linux/bin64/../../src/phobos/std/stdio.d:4383
#2  0xXXXXXXXXXXXXXXXX in std.stdio.File() (this=..., buffer=...)
    at [...]/dmd2/linux/bin64/../../src/phobos/std/stdio.d:1036
#3  0xXXXXXXXXXXXXXXXX in D main () at n1.d:9
[...]

fread is called with a null ptr as FILE*. It seems that trustedFwrite
may be also affected.

Problem turned up in in
http://forum.dlang.org/thread/tmcqsxilpythexmscycd@forum.dlang.org

--


More information about the Digitalmars-d-bugs mailing list