RejectedSoftware Forums

Sign up

LDC2 and fiber communication

When using vibe.d 0.8.0 with ldc2 1.3.0-beta2 on windows, trying to send or sendCompat anything to a task created before the sender, causes a range violation. This does not happen with dmd.

CoreTaskFiber was terminated unexpectedly: Range violation

This program will reproduce the error. Swapping the runTask lines will produce the expected hello output.

import std.stdio;
import core.time;
import vibe.core.core;
import vibe.core.concurrency;

Task alice;
Task bob;

int main () {
    bob = runTask(() { bobProc(); });
    alice = runTask(() { aliceProc(); });

    setTimer(1.seconds, () { exitEventLoop(); });
    return runEventLoop();
}

void aliceProc () {
    send(bob, "hello");
}

void bobProc () {
    receive(
        (string s) { writeln(s); }
    );
}

Re: LDC2 and fiber communication

Am 21.07.2017 um 22:51 schrieb Hugo D.:

When using vibe.d 0.8.0 with ldc2 1.3.0-beta2 on windows, trying to send or sendCompat anything to a task created before the sender, causes a range violation. This does not happen with dmd.

CoreTaskFiber was terminated unexpectedly: Range violation

This program will reproduce the error. Swapping the runTask lines will produce the expected hello output.

import std.stdio;
import core.time;
import vibe.core.core;
import vibe.core.concurrency;

Task alice;
Task bob;

int main () {
    bob = runTask(() { bobProc(); });
    alice = runTask(() { aliceProc(); });

    setTimer(1.seconds, () { exitEventLoop(); });
    return runEventLoop();
}

void aliceProc () {
    send(bob, "hello");
}

void bobProc () {
    receive(
        (string s) { writeln(s); }
    );
}

Just to rule this out, can you try if this also occurs with LDC 1.3.0
final? I remember there were some issues with the betas, although I
don't know if those were related.

Re: LDC2 and fiber communication

On Sat, 22 Jul 2017 15:31:03 +0200, Sönke Ludwig wrote:

Just to rule this out, can you try if this also occurs with LDC 1.3.0
final? I remember there were some issues with the betas, although I
don't know if those were related.

Still happens on ldc2 1.3.0 final.

Running with verbose debug logging spits out this stack trace, if it can be of any help.

Full error: core.exception.RangeError@C:\D\ldc2\bin\..\import\std\container\array.d(593): Range violation
----------------
0x00007FF7E663CD08 in std.container.array.Array!(void*).Array.opSlice at C:\D\ldc2\import\std\container\array.d(593)
0x00007FF7E663C712 in vibe.core.drivers.libasync.LibasyncManualEvent.removeMySignal at [...]\vibe-d-0.8.0\vibe-d\core\vibe\core\drivers\libasync.d(969)
0x00007FF7E663BD13 in vibe.core.drivers.libasync.LibasyncManualEvent.release at [...]\vibe-d-0.8.0\vibe-d\core\vibe\core\drivers\libasync.d(904)
0x00007FF7E663AF12 in vibe.core.drivers.libasync.LibasyncManualEvent.doWait!false.doWait at [...]\vibe-d-0.8.0\vibe-d\core\vibe\core\drivers\libasync.d(928)
0x00007FF7E663AE60 in vibe.core.drivers.libasync.LibasyncManualEvent.waitUninterruptible at [...]\vibe-d-0.8.0\vibe-d\core\vibe\core\drivers\libasync.d(865)
0x00007FF7E6672171 in vibe.core.sync.TaskConditionImpl!(false, Mutex).TaskConditionImpl.wait at [...]\vibe-d-0.8.0\vibe-d\core\vibe\core\sync.d(861)
0x00007FF7E667200F in vibe.core.sync.TaskCondition.wait at [...]\vibe-d-0.8.0\vibe-d\core\vibe\core\sync.d(568)
0x00007FF7E656362A in bool std.concurrency.MessageBox.get!(@safe void function(immutable(char)[])*).get(@safe void function(immutable(char)[])*) at C:\D\ldc2\import\std\concurrency.d(2106)
0x00007FF7E65512B0 in void std.concurrency.receive!(@safe void function(immutable(char)[])*).receive(@safe void function(immutable(char)[])*) at C:\D\ldc2\import\std\concurrency.d(701)
0x00007FF7E65511B0 in app.bobProc at S:\projects\dlang\vibetest\source\app.d(31)
0x00007FF7E655118E in app.main.__lambda1 at S:\projects\dlang\vibetest\source\app.d(16)
0x00007FF7E655EF09 in vibe.core.core.makeTaskFuncInfo!(void delegate()).makeTaskFuncInfo.callDelegate at [...]\vibe-d-0.8.0\vibe-d\core\vibe\core\core.d(633)
0x00007FF7E6624688 in vibe.core.core.CoreTask.run at [...]\vibe-d-0.8.0\vibe-d\core\vibe\core\core.d(1269)
0x00007FF7E670E254 in fiber_entryPoint
0x00007FF7E670C709 in D4core6thread5Fiber9initStackMFNbZ10trampolineFNaNbNiZv

Re: LDC2 and fiber communication

Am 23.07.2017 um 03:35 schrieb Hugo D.:

On Sat, 22 Jul 2017 15:31:03 +0200, Sönke Ludwig wrote:

Just to rule this out, can you try if this also occurs with LDC 1.3.0
final? I remember there were some issues with the betas, although I
don't know if those were related.

Still happens on ldc2 1.3.0 final.

Running with verbose debug logging spits out this stack trace, if it can be of any help.

Full error: core.exception.RangeError@C:\D\ldc2\bin\..\import\std\container\array.d(593): Range violation
----------------
0x00007FF7E663CD08 in std.container.array.Array!(void*).Array.opSlice at C:\D\ldc2\import\std\container\array.d(593)
0x00007FF7E663C712 in vibe.core.drivers.libasync.LibasyncManualEvent.removeMySignal at [...]\vibe-d-0.8.0\vibe-d\core\vibe\core\drivers\libasync.d(969)
(...)

Ah, you are using the libasync driver, which is currently not tested
against LDC, because of LDC specific failures. If possible, it would be
the safest bet to use a different compiler/driver combination for now.

But, without understanding the root cause for the error, I've committed
a fix for this particular range violation error and tagged version
0.8.1-alpha.4. The CI test now also passes on LDC 1.3.0.