gdc compiled program seg fault

Daniel Benamy dbenamy at gmail.com
Fri Aug 1 04:41:15 PDT 2008


I'm having trouble getting a trivial d program working properly. I'm trying
with gdc both with the prebuild binaries downloaded from
http://downloads.sourceforge.net/dgcc/gdc-0.24-x86_64-linux-gnu-gcc-4.1.2.tar.bz2?modtime=1187745544&big_mirror=0
and with a version I built myself. I installed the prebuilt one in /usr/local.
For the one I built, I specified d version 2, a prefix in my home dir and
static and no shared options to allow it compile. I'm on fedora 9.

gdc compiles the program fine and it runs. As long as I enter words, it echos
them back. But when I hit ctrl + d to signal eof, it seg faults.

$ cat test.d
import std.stdio;

int main()
{
        char[] buf;
        while ((buf = readln()) != null)
                writef("%s", buf);
        return 0;
}

$ gdc -Wall -g test.d -o test

$ ./test
hello
hello
<I typed ctrl + d here.>
Segmentation fault

$ gdb ./test
GNU gdb Fedora (6.8-12.fc9)
Copyright (C) 2008 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-redhat-linux-gnu"...
(gdb) r
Starting program: /data/Documents/Eclipse Workspace/Simple D Kernel/test
[Thread debugging using libthread_db enabled]
foo
foo
<I typed ctrl + d here.>
[New Thread 0x7fe4bf3e36f0 (LWP 18639)]

Program received signal SIGSEGV, Segmentation fault.
0x0000003568283b8b in memcpy () from /lib64/libc.so.6
Missing separate debuginfos, use: debuginfo-install glibc.x86_64
(gdb) bt
#0  0x0000003568283b8b in memcpy () from /lib64/libc.so.6
#1  0x000000000041203c in _adDupT ()
#2  0x000000000040d32d in _D3std5stdio6readlnFPS3std1c5stdio6_iobufKAaZm ()
#3  0x000000000040d3a0 in _D3std5stdio6readlnFPS3std1c5stdio6_iobufZAa ()
#4  0x000000000040289c in _Dmain () at test.d:6
#5  0x0000000000419ce6 in _D9dgccmain211_d_run_mainUiPPaPUAAaZiZi2goMFZv ()
#6  0x0000000000419d9f in _d_run_main ()
#7  0x000000356821e32a in __libc_start_main () from /lib64/libc.so.6
#8  0x00000000004027e9 in _start ()

I'm not sure if this is the right place to report this. If somewhere else is
better, please let me know where.

Thanks,
Dan


More information about the Digitalmars-d-bugs mailing list