Bug 13930 – std.concurrency can't send immutable AA to another thread
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-01-04T02:44:08Z
Last change time
2020-10-10T23:23:26Z
Assigned to
No Owner
Creator
Martin Nowak
Comments
Comment #0 by code — 2015-01-04T02:44:08Z
cat > bug.d << CODE
import std.concurrency;
void main()
{
immutable aa = ["0":0];
thisTid.send(aa);
}
CODE
dmd -c bug
----
Trying to send an immutable associative array to another thread fails with this error messsage. Looks like a problem with copying in Variant or so.
Hash tables are basic types so this should be supported.
----
/usr/include/dmd/phobos/std/variant.d(621): Error: template instance std.variant.VariantN!32LU.VariantN.handler!(immutable(int[string])) error instantiating
/usr/include/dmd/phobos/std/variant.d(571): instantiated from here: opAssign!(immutable(int[string]))
/usr/include/dmd/phobos/std/concurrency.d(109): instantiated from here: __ctor!(immutable(int[string]))
/usr/include/dmd/phobos/std/concurrency.d(588): instantiated from here: __ctor!(immutable(int[string]))
/usr/include/dmd/phobos/std/concurrency.d(578): instantiated from here: _send!(immutable(int[string]))
/usr/include/dmd/phobos/std/concurrency.d(556): instantiated from here: _send!(immutable(int[string]))
bug.d(6): instantiated from here: send!(immutable(int[string]))
----
I guess this issue contains two distinct problems.
The example in the first comment is about the problem of the `send` function.
I guess it was already solved by issue 21296 because the following test works without errors (I used phobos commit:f85ca8db in which issue 21296 was fixed):
```
@system unittest
{
immutable aa = ["0":0];
thisTid.send(aa);
}
```
The example in the second comment is about the problem of the `receiveOnly` function (same as issue 19345).
This problem only happens with `receiveOnly` but does not happen with other `receive` family such as `receive` and `receiveTimeout`.
I confirmed the following tests work without errors (I used phobos commit:f85ca8db):
```
@system unittest
{
immutable aa = ["0":0];
thisTid.send(aa);
receive((immutable int[string] val) {});
}
@system unittest
{
immutable aa = ["0":0];
thisTid.send(aa);
receiveTimeout(10.seconds, (immutable int[string] val) {});
}
```
Note: I did not test the case of shared.
Comment #4 by dlang-bot — 2020-10-09T15:15:04Z
@tom-tan created dlang/phobos pull request #7655 "Fix `receiveOnly` for non-assignable types (issue 13930, issue 19345)" mentioning this issue:
- Fix receiveOnly for non-assignable types
- Fix issue 13930 - std.concurrency can't send immutable AA to another thread
- Fix issue 19345 - std.concurrency does not work with structs of const value type
https://github.com/dlang/phobos/pull/7655
Comment #5 by dlang-bot — 2020-10-10T02:09:24Z
dlang/phobos pull request #7655 "Fix issue 13930, 19345 - Fix `receiveOnly` for non-assignable types " was merged into master:
- d86c1f605995b423dd1a467b2c1c530dc52adb1e by Tomoya Tanjo:
Fix issue 13930, 19345 - Fix receiveOnly for non-assignable types
https://github.com/dlang/phobos/pull/7655
Comment #6 by dlang-bot — 2020-10-10T23:23:26Z
dlang/phobos pull request #7657 "Revert "Fix issue 13930, 19345 - Fix `receiveOnly` for non-assignable types "" was merged into master:
- 756242350896019ffc7a7cbe05e838538a559f5a by Mathias LANG:
Revert "Fix issue 13930, 19345 - Fix receiveOnly for non-assignable types"
This reverts commit 4f4fef19400ff85eb4699d569b02b21299b254cc.
https://github.com/dlang/phobos/pull/7657