Debugging silent exit of threads in Phobos calls
Russel Winder
russel at winder.org.uk
Sat Jun 2 10:02:51 UTC 2018
On Fri, 2018-06-01 at 16:19 -0400, Steven Schveighoffer via
Digitalmars-d-learn wrote:
> On 6/1/18 1:41 PM, Russel Winder wrote:
> > struct Datum {
> > public const int a;
> > public const int b;
> > }
> >
> > struct Message {
> > Datum datum;
> > }
>
> I found the bug. Basically, the Variant static if is failing because
> the
> assignment it is checking (assigning a Message to a Message) would
> overwrite const data. But it's not really overwriting existing data,
> it's emplacing into new data (always). So this check is not correct.
I think then my bug report 18934 is slightly wrong and it isn't the
struct within struct that is the problem, it is the const fields in a
struct that is?
> Much simpler test case:
>
> struct S
> {
> const int x;
> }
>
> void main()
> {
> import std.variant;
> import std.stdio;
> Variant v = S(1);
> writeln(v.get!S); // same failure
> }
>
Aha, much nicer since it is far more localised to the issue. I was
still focused on the receive and the struct within struct, which seems
to be the wrong issue: it is the const fields that are the problem.
Feel free to ignore my example and stack trace on
https://issues.dlang.org/show_bug.cgi?id=18934
and replace it with the above!
> If I replace the check in std.variant:
>
> static if (is(typeof(*cast(T*) target = *src)) ||
>
> with:
>
> static if (is(typeof(delegate T() {return *src;}))
> ||
>
> Then it works (both your code, and the simple example).
>
> Note that in all cases, variant is returning a COPY of the data, not
> a
> reference, so it shouldn't be possible to violate const.
Excellently done. Thanks for attacking this problem and finding a
solution. I will not now even contemplate hacking up my code. Actually
I would have put const in and still got a problem it seems, as I had
the wrong reason for the problem.
> Please, file a bug. I will see if I can submit a PR to fix.
>
Bug report is 18934.
If there can be a fast release of this via 2.080.1 with subsequence
fast releases via d-apt and Debian and Fedora packaging, I would be a
very happy bunny.
In the meantime onward with ACCU 2019 organisation.
ACCU needs more D content. Yes it is 50% C++, but that is exactly why
it needs D content. It also needs Go content. in 2018 we had Rust
content and it went down well.
--
Russel.
===========================================
Dr Russel Winder t: +44 20 7585 2200
41 Buckmaster Road m: +44 7770 465 077
London SW11 1EN, UK w: www.russel.org.uk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20180602/20154ce3/attachment-0001.sig>
More information about the Digitalmars-d-learn
mailing list