Thread overview
[Issue 6463] New: Segfault on writeln() from a Fiber
Aug 10, 2011
Danny Arends
Aug 11, 2011
Danny Arends
Aug 16, 2011
dawg@dawgfoto.de
Aug 16, 2011
Danny Arends
Aug 16, 2011
Danny Arends
Aug 17, 2011
dawg@dawgfoto.de
August 10, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6463

           Summary: Segfault on writeln() from a Fiber
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: Danny.Arends@gmail.com


--- Comment #0 from Danny Arends <Danny.Arends@gmail.com> 2011-08-10 03:10:21 PDT ---
Trying to print floats and doubles from a fiber it fails with a segfault, while it is possible to do the same in the main thread.

The expected output of the attached code file: 15 15 Done

However I get: 15 segfault

I am using the DMD64 D Compiler v 2.054 on Debian 64

What am I doing wrong, because using to!string() on the floats and double allows me to print them to std.out.

I however get weird behavior when I try to do math on the floats and doubles in the fiber, or when I pass them to C-functions.

Kind regards, Danny

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 11, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6463



--- Comment #1 from Danny Arends <Danny.Arends@gmail.com> 2011-08-11 06:21:47 PDT ---
Tested on other systems: 32bit Debian Squeeze and Win32, this does not happen
and I get the expected output of:
15
15
Done

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 16, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6463


dawg@dawgfoto.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dawg@dawgfoto.de


--- Comment #2 from dawg@dawgfoto.de 2011-08-15 21:22:58 PDT ---
Can you please post the code.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 16, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6463



--- Comment #3 from Danny Arends <Danny.Arends@gmail.com> 2011-08-16 01:02:02 PDT ---
Created an attachment (id=1017)
Segfault from fiber

The file I forgot to attach

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 16, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6463



--- Comment #4 from Danny Arends <Danny.Arends@gmail.com> 2011-08-16 01:02:30 PDT ---
Sorry forgot to attach the file.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 17, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6463


dawg@dawgfoto.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


--- Comment #5 from dawg@dawgfoto.de 2011-08-17 09:04:13 PDT ---
I can confirm this crash.
The reason though is not strictly a bug.
What you observe is a stack overflow due to big local buffers
in std.format.formatValue and even bigger ones in libc's vfprintf.
Fibers are allocated with a default stack size of one memory page (usually 4096
Bytes), but calling these two function already allocates >3KB stack space.

As a workaround you can increase the stack size in the Fiber constructor. I'm afraid there is no easy solution to determine the smallest possible stack size that is safe for all your code paths. In this example 8K => 'this() { super(&run, 8192); }' will suffice.

martin

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------