www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Seems core.thread.Fiber is broken dmd windows 64-bit build

reply "Carl Sturtivant" <sturtivant gmail.com> writes:
The following crashes on Windows 7 sp1 64-bit edition when build 
at 64 bits with dmd and the Microsoft linker that comes with 
Windows SDK 7.1 (i.e. MSVC 2010 linker). I've had no trouble with 
other D code when using that arrangement, though I have not used 
threads. When built at 32 bits with dmd and optlink it runs fine.
==============
import core.thread, std.stdio;

void main() {
     writefln( "A pointer is %d bytes", (void*).sizeof);
         void f1() {
             writeln( 1);
             Fiber.yield();
             writeln( 3);
         }
     auto fiber = new Fiber( &f1);
     fiber.call();
     writeln( 2);
     fiber.call();
     writeln( 4);
}
===============
The 64 bit version outputs 1 and crashes when yield is executed. 
Other tests reveal that yield is the problem.

Should I be doing something special with linkage so this works? 
What is going on?
Mar 08 2015
next sibling parent reply "Carl Sturtivant" <sturtivant gmail.com> writes:
Please confirm or deny that this is a real bug, as its getting in 
the way of a genuine project. How should I proceed?

I'm working on a 64-bit Windows port of the following.
http://www.cs.arizona.edu/icon/
Here's the 32-bit Windows port.
http://www.cs.arizona.edu/icon/v95w.htm

Among other things I'm using D to implement Icon's coexpressions 
portably using core.thread.Fiber which works fine at 32 bits. 
They are implemented using pthreads on other platforms, though 
historically there used to be a platform dependent assembly code 
context switch, close to the way that core.thread.Fiber is 
implemented. The Fiber implementation is 20 times faster at 32 
bits.
Mar 09 2015
parent reply "Benjamin Thaut" <code benjamin-thaut.de> writes:
On Monday, 9 March 2015 at 14:39:34 UTC, Carl Sturtivant wrote:
 Please confirm or deny that this is a real bug, as its getting 
 in the way of a genuine project. How should I proceed?

 I'm working on a 64-bit Windows port of the following.
 http://www.cs.arizona.edu/icon/
 Here's the 32-bit Windows port.
 http://www.cs.arizona.edu/icon/v95w.htm

 Among other things I'm using D to implement Icon's 
 coexpressions portably using core.thread.Fiber which works fine 
 at 32 bits. They are implemented using pthreads on other 
 platforms, though historically there used to be a platform 
 dependent assembly code context switch, close to the way that 
 core.thread.Fiber is implemented. The Fiber implementation is 
 20 times faster at 32 bits.
I can reproduce this issue with dmd 2.066.1, please go forward and open a issue on https://issues.dlang.org/ Kind Regards Benjamin Thaut
Mar 09 2015
parent reply "Carl Sturtivant" <sturtivant gmail.com> writes:
 I can reproduce this issue with dmd 2.066.1,
 please go forward and open a issue on https://issues.dlang.org/

 Kind Regards
 Benjamin Thaut
Thank you; will do.
Mar 09 2015
parent reply "Jacques =?UTF-8?B?TcO8bGxlciI=?= <jacques.mueller gmx.de> writes:
With the newest beta everything seems to work fine.
http://forum.dlang.org/thread/md5kq0$8au$1 digitalmars.com
Mar 09 2015
next sibling parent "Carl Sturtivant" <sturtivant gmail.com> writes:
On Monday, 9 March 2015 at 17:00:38 UTC, Jacques Müller wrote:
 With the newest beta everything seems to work fine.
 http://forum.dlang.org/thread/md5kq0$8au$1 digitalmars.com
That's great news! Thank you.
Mar 09 2015
prev sibling parent "Carl Sturtivant" <sturtivant gmail.com> writes:
 http://forum.dlang.org/thread/md5kq0$8au$1 digitalmars.com
Got a working build at 64 bits using the 2.067 beta 3. Delighted.
Mar 09 2015
prev sibling parent reply "David Nadlinger" <code klickverbot.at> writes:
On Sunday, 8 March 2015 at 18:18:49 UTC, Carl Sturtivant wrote:
 Should I be doing something special with linkage so this works? 
 What is going on?
IIRC there are some fixes to the Win64 context switching code in the 2.067 or master druntime. You might want to try those first before spending more time tracking this down. — David
Mar 09 2015
parent "Carl Sturtivant" <sturtivant gmail.com> writes:
 IIRC there are some fixes to the Win64 context switching code 
 in the 2.067 or master druntime. You might want to try those 
 first before spending more time tracking this down.
Great, and thanks.
Mar 09 2015