[Issue 1555] New: segfault in std.stdio.readln()

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Oct 7 19:53:09 PDT 2007


http://d.puremagic.com/issues/show_bug.cgi?id=1555

           Summary: segfault in std.stdio.readln()
           Product: DGCC aka GDC
           Version: 0.24
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: dvdfrdmn at users.sf.net
        ReportedBy: dlang at davidb.org


The following program causes a segfault on EOF with gdc-0.24. I've
reproduced this on amd64, x86 both with the binary distribution and with
the gentoo emerged version (gcc-4.1.2). This does not appear to happen
with dmd.

======================================================================
module readline;

import std.stdio;

void main ()
{
  while (1) {
    char[] buf = readln ();
    if (buf is null)
      break;
    writef ("%s", buf);
  }
}
======================================================================

Upon EOF, there is a segfault inside of a string dup inside of readln:

uint std.stdio.readln(struct std.c.stdio._iobuf*, inout char[])

#0 0xb7ed6a2c in memcpy () from /lib/libc.so.6
#1 0x0805992e in _adDupT ()
#2 0x080546e5 in _D3std5stdio6readlnFPS3std1c5stdio6_iobufKAaZk ()
#3 0x0805476a in _D3std5stdio6readlnFPS3std1c5stdio6_iobufZAa ()
#4 0x0804a076 in _Dmain ()
#5 0x08061018 in _D9dgccmain211_d_run_mainUiPPaPUAAaZiZi2goMFZv ()
#6 0x080610ca in _d_run_main ()
#7 0x0805d49b in main ()

I can try to build phobos with debugging symbols if other are unable to
reproduce this problem.


-- 



More information about the D.gnu mailing list