www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21728] New: rawRead calls fread with NULL if invoked on


          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 puremagic.com
          Reporter: kdevel vogtner.de

import std.stdio;
import std.process;

void main ()
   auto p = pipe ();
   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


    at [...]/dmd2/linux/bin64/../../src/phobos/std/stdio.d:1036


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

Mar 18 2021