Skip to content
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

Stalled thread in concurrency.d unittest #10377

Open
dlangBugzillaToGithub opened this issue Jul 4, 2019 · 1 comment
Open

Stalled thread in concurrency.d unittest #10377

dlangBugzillaToGithub opened this issue Jul 4, 2019 · 1 comment
Labels
Arch:x86_64 Issues specific to x86_64 OS:Linux Issues specific to Linux Severity:Minor

Comments

@dlangBugzillaToGithub
Copy link

zorael reported this on 2019-07-04T23:54:10Z

Transfered from https://issues.dlang.org/show_bug.cgi?id=20028

CC List

Description

2.087.

In a unit test in concurrency.d, a thread is spawned to await the numbers 1 to 9 to be sent to it via concurrency messages. A Generator is set up to provide the numbers, but it only yields 1, 2 and 3. The thread is left waiting for 4 to 9, which never arrive, and the thread stalls on receiveOnly!int().

https://github.com/dlang/phobos/blob/98c7f5aa/std/concurrency.d#L1771

> auto tid = spawn({
>     int i;
> 
>     try
>     {
>         for (i = 1; i < 10; i++)  // <--
>         {
>             assertNotThrown!AssertError(assert(receiveOnly!int() == i));
>         }
>     }
>     catch (OwnerTerminated e)
>     {
> 
>     }
> 
>     // i will advance 1 past the last value expected
>     assert(i == 4);
> });
> 
> auto r = new Generator!int({
>     assertThrown!Exception(yield(2.0));
>     yield(); // ensure this is a no-op
>     yield(1);
>     yield(); // also once something has been yielded
>     yield(2);
>     yield(3);
> });
> 
> foreach (e; r)
> {
>     tid.send(e);
> }

Changing it to (i = 1; i <= 3; i++) fixes it and lets the thread exit.
@dlangBugzillaToGithub
Copy link
Author

bugzilla (@WalterBright) commented on 2019-12-10T10:33:34Z

What exactly is the problem? This unittest has run thousends of times and always worked. IMHO the loop intentionally loops until 10. This is part of the test...

@LightBender LightBender removed the P3 label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arch:x86_64 Issues specific to x86_64 OS:Linux Issues specific to Linux Severity:Minor
Projects
None yet
Development

No branches or pull requests

2 participants