Jump to page: 1 2
Thread overview
Several segmentation faults
May 28, 2008
Josh
May 28, 2008
BCS
May 28, 2008
Josh
May 29, 2008
downs
May 29, 2008
Chris Wright
May 29, 2008
Lars
May 29, 2008
Urban Hafner
May 29, 2008
Lars Kyllingstad
May 29, 2008
Urban Hafner
May 29, 2008
Josh
May 30, 2008
Lars Kyllingstad
May 28, 2008
Has anyone had segmentation faults running the tutorials?  This segfaults on my computer (Ubuntu 8.04) using dgc.  It's taken from one of the tutorials, but several similar tutorials also fail.

import std.stdio;

int magicNumber = 42;
char[] password = "sesame";

void main() {
  writefln("Magic number: ", magicNumber);
  writefln("Password: ", password);
}
May 28, 2008
Reply to Josh,

> Has anyone had segmentation faults running the tutorials?  This
> segfaults on my computer (Ubuntu 8.04) using dgc.  It's taken from one
> of the tutorials, but several similar tutorials also fail.
> 
> import std.stdio;
> 
> int magicNumber = 42;
> char[] password = "sesame";
> void main() {
> writefln("Magic number: ", magicNumber);
> writefln("Password: ", password);
> }

does the compiler seg-v or does the compiled program?


May 28, 2008
> does the compiler seg-v or does the compiled program?

The compiled program
May 29, 2008
Josh wrote:
> Has anyone had segmentation faults running the tutorials?  This segfaults on my computer (Ubuntu 8.04) using dgc.  It's taken from one of the tutorials, but several similar tutorials also fail.
> 
> import std.stdio;
> 
> int magicNumber = 42;
> char[] password = "sesame";
> 
> void main() {
>   writefln("Magic number: ", magicNumber);
>   writefln("Password: ", password);
> }

All I can say is there is nothing in there that I could possibly imagine segfaulting.

Ergo it has to be a problem with your system. If you have too much free time, try to build GDC from sources.

Out of curiosity, could you gdb the crashing program?

 --downs
May 29, 2008
Josh Wrote:

> Has anyone had segmentation faults running the tutorials?  This segfaults on my computer (Ubuntu 8.04) using dgc.  It's taken from one of the tutorials, but several similar tutorials also fail.
> 
> import std.stdio;
> 
> int magicNumber = 42;
> char[] password = "sesame";
> 
> void main() {
>   writefln("Magic number: ", magicNumber);
>   writefln("Password: ", password);
> }

I was searching for the answer to the exact same question. It seems that writef and writefln segfault whenever additional arguments are passed. Consider the following (modified) Hello World:

  import std.stdio;

  void main {
      writefln("Hello %s!", "world");
  }

When I compile this on my system (also running Ubuntu 8.04) with GDC and run it, it immediately segfaults without displaying the message. Just using

  writefln("Hello world!");

works perfectly, however. Some more testing shows that writing to other streams (files, etc.) doesn't work either. The printf() function works fine.

Something wrong with the newest Ubuntu build of GDC, then? I tried running my hello-world program through GDB, this is the output I got:

Starting program: /home/lars/development/programming/d/test/helloworld
[Thread debugging using libthread_db enabled]
[New Thread 0x7f0871deb6e0 (LWP 16622)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7f0871deb6e0 (LWP 16622)]
0x000000000040cfe9 in _D3std6format11doFormatPtrFDFwZvAC8TypeInfoG1S6object13__va_list_tagPvZv9formatArgMFaZv6putstrMFAaZv ()
Current language:  auto; currently asm


Regards,
Lars
May 29, 2008
Lars wrote:
> When I compile this on my system (also running Ubuntu 8.04) with GDC and run it, it immediately segfaults without displaying the message. Just using

Which GDC build are you using? There's one built using GCC 4.1 and one using GCC 4.2, IIRC. The latter one also didn't work for me (on other more complex code).

Urban
May 29, 2008
downs wrote:
> Josh wrote:
>> Has anyone had segmentation faults running the tutorials?  This segfaults on my computer (Ubuntu 8.04) using dgc.  It's taken from one of the tutorials, but several similar tutorials also fail.  
>>
>> import std.stdio;
>>
>> int magicNumber = 42;
>> char[] password = "sesame";
>>
>> void main() {
>>   writefln("Magic number: ", magicNumber);
>>   writefln("Password: ", password);
>> }
> 
> All I can say is there is nothing in there that I could possibly imagine segfaulting.
> 
> Ergo it has to be a problem with your system. If you have too much free time, try to build GDC from sources.
> 
> Out of curiosity, could you gdb the crashing program?
> 
>  --downs

I've tried using gdc as installed from the Ubuntu repositories. The programs it produces always segfault on vararg calls.
May 29, 2008
Urban Hafner Wrote:

> Lars wrote:
> > When I compile this on my system (also running Ubuntu 8.04) with GDC and run it, it immediately segfaults without displaying the message. Just using
> 
> Which GDC build are you using? There's one built using GCC 4.1 and one using GCC 4.2, IIRC. The latter one also didn't work for me (on other more complex code).
> 
> Urban

In the repository it is listed as 0.25-4.2.3-2ubuntu2.

-Lars
May 29, 2008
Lars Kyllingstad wrote:
> Urban Hafner Wrote:
> 
>> Lars wrote:
>>> When I compile this on my system (also running Ubuntu 8.04) with GDC and run it, it immediately segfaults without displaying the message. Just using
>> Which GDC build are you using? There's one built using GCC 4.1 and one using GCC 4.2, IIRC. The latter one also didn't work for me (on other more complex code).
>>
>> Urban
> 
> In the repository it is listed as 0.25-4.2.3-2ubuntu2.

I just checked. I'm using 0.25-4.1.2-16ubuntu1. And the package is called gdc-4.1. Maybe this works for you. The only thing is that you have to create a few symlinks, as the executable is called gdc-4.1 instead of gdc (the same for gdmd and maybe others).

Urban
May 29, 2008
Urban Hafner Wrote:

> Lars Kyllingstad wrote:
> > Urban Hafner Wrote:
> > 
> >> Lars wrote:
> >>> When I compile this on my system (also running Ubuntu 8.04) with GDC and run it, it immediately segfaults without displaying the message. Just using
> >> Which GDC build are you using? There's one built using GCC 4.1 and one using GCC 4.2, IIRC. The latter one also didn't work for me (on other more complex code).
> >>
> >> Urban
> > 
> > In the repository it is listed as 0.25-4.2.3-2ubuntu2.
> 
> I just checked. I'm using 0.25-4.1.2-16ubuntu1. And the package is called gdc-4.1. Maybe this works for you. The only thing is that you have to create a few symlinks, as the executable is called gdc-4.1 instead of gdc (the same for gdmd and maybe others).
> 
> Urban

Just to confirm, I tried compiling the same code on Ubuntu 8.04 using gdc-4.1 instead of gdc-4.2.  The program ran fine.  Thanks.

« First   ‹ Prev
1 2