[Issue 15294] New: receiveTimeout with negative value asserts

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Nov 5 15:25:39 PST 2015


https://issues.dlang.org/show_bug.cgi?id=15294

          Issue ID: 15294
           Summary: receiveTimeout with negative value asserts
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: justin at economicmodeling.com

std.concurrency.receiveTimeout claims to not wait if the provided Duration is
negative, but an assert trips if a negative value is supplied.

> cat test.d
void main()
{
    import std.concurrency;
    import core.time;

    auto dontWait = dur!"msecs"(-1);
    spawn(&foo);
    receiveTimeout(dontWait, (int i){});
}

void foo() {}


Using DMD 2.069.0:
> dmd test.d
> ./test
core.exception.AssertError at std/concurrency.d(1910): Assertion failure
----------------
??:? _d_assert [0x4518f7]
??:? void std.concurrency.__assert(int) [0x459354]
??:? bool std.concurrency.MessageBox.get!(core.time.Duration, pure nothrow
@nogc @safe void function(int)*).get(scope core.time.Duration, scope pure
nothrow @nogc @safe void function(int)*) [0x441614]
??:? bool std.concurrency.receiveTimeout!(pure nothrow @nogc @safe void
function(int)*).receiveTimeout(core.time.Duration, pure nothrow @nogc @safe
void function(int)*) [0x441595]
??:? _Dmain [0x4413c7]
??:? _D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv [0x455f5a]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int
function(char[][])*).tryExec(scope void delegate()) [0x455eb0]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int
function(char[][])*).runAll() [0x455f16]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int
function(char[][])*).tryExec(scope void delegate()) [0x455eb0]
??:? _d_run_main [0x455e0d]
??:? main [0x44ed7d]
??:? __libc_start_main [0x82126b44]

Here is the problematic line:
https://github.com/D-Programming-Language/phobos/blob/master/std/concurrency.d#L1910

--


More information about the Digitalmars-d-bugs mailing list