New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dmd 2.069.1 regression, std.concurrency functions sleep forever #1343

Closed
NCrashed opened this Issue Dec 1, 2015 · 2 comments

Comments

Projects
None yet
2 participants
@NCrashed
Contributor

NCrashed commented Dec 1, 2015

I move my old project from dmd 2.066 to latest release. The problem: std.concurrency functions (
receive, receiveOnly, receiveTimeout) hang vibed's fibers.

Demo of issue

dub.sdl

name "threads-test"
dependency "vibe-d" version="==0.7.27-alpha.1"
versions "VibeDefaultMain"

app.d

import std.stdio;
import std.concurrency : 
    stdReceiveOnly = receiveOnly
  , stdThisTid = thisTid
  , StdTid = Tid
  , stdSend = send
  , spawn;
import vibe.d;

void thread1(StdTid mainThread, StdTid otherThread) {

  writeln("thread1 send");
  otherThread.stdSend(stdThisTid);
  writeln("thread1 wait");
  stdReceiveOnly!StdTid();

  writeln("thread1 exit");
  mainThread.stdSend(true);
}

void thread2(StdTid mainThread) {
  writeln("thread2 wait");
  std.concurrency.receive((StdTid otherThread) {
      writeln("thread2 send");
      otherThread.stdSend(stdThisTid);
    });

  writeln("thread2 exit");
  mainThread.stdSend(true);
}

void test()
{
  auto tid2 = spawn(&thread2, stdThisTid);
    auto tid1 = spawn(&thread1, stdThisTid, tid2);

  stdReceiveOnly!bool();
  stdReceiveOnly!bool();
  writeln("test exit");
}

shared static this()
{
  auto settings = new HTTPServerSettings;
  settings.port = 8080;

  listenHTTP(settings, &handleRequest);
}

void handleRequest(HTTPServerRequest req,
                   HTTPServerResponse res)
{
  test();
  if (req.path == "/")
    res.writeBody("Hello, World!", "text/plain");
}

Vibe-d: 0.7.27-alpha.1
dmd: 2.069.1
platform: Fedora 23 x86_64

P.S. Dirty workaround is to run your stuff in separate thread and communicate with a fiber via shared memory.

@NCrashed NCrashed changed the title from dmd 2.069.1 regression, std.concurrency functions sleeps forever to dmd 2.069.1 regression, std.concurrency functions sleep forever Dec 1, 2015

@s-ludwig

This comment has been minimized.

Show comment
Hide comment
@s-ludwig

s-ludwig Dec 2, 2015

Member

Fixed by d8b51c2 - std.concurrency integration simply got disabled a while ago, so that it used the default implementation, which blocks the event loop.

Member

s-ludwig commented Dec 2, 2015

Fixed by d8b51c2 - std.concurrency integration simply got disabled a while ago, so that it used the default implementation, which blocks the event loop.

@s-ludwig s-ludwig closed this Dec 2, 2015

@s-ludwig s-ludwig reopened this Dec 2, 2015

@s-ludwig

This comment has been minimized.

Show comment
Hide comment
@s-ludwig

s-ludwig Dec 2, 2015

Member

The fixed caused troubles and requires a more involved fix.

Member

s-ludwig commented Dec 2, 2015

The fixed caused troubles and requires a more involved fix.

@s-ludwig s-ludwig closed this in 8257198 Jan 29, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment