Should mention
$ dmd --version
DMD64 D Compiler v2.079.1
Comment #2 by Marco.Leise — 2018-04-30T19:39:59Z
First thing that came to my mind ... there is suddenly an obvious GC bug exposed by writeln?! Probably more likely some custom stuff that overwrites internal data structures or something, let's look at the provided test case...
GC.malloc(GC.BlkAttr.NO_SCAN);
That does not look like the correct first argument to: https://dlang.org/phobos/core_memory.html#.GC.malloc
Could you please give the amount of bytes you want to allocate and then post the corrected test case? ;)
Comment #3 by jack — 2018-04-30T19:43:56Z
(In reply to Marco Leise from comment #2)
> First thing that came to my mind ... there is suddenly an obvious GC bug
> exposed by writeln?! Probably more likely some custom stuff that overwrites
> internal data structures or something, let's look at the provided test
> case...
>
> GC.malloc(GC.BlkAttr.NO_SCAN);
>
> That does not look like the correct first argument to:
> https://dlang.org/phobos/core_memory.html#.GC.malloc
>
> Could you please give the amount of bytes you want to allocate and then post
> the corrected test case? ;)
==========
import std.traits;
import std.stdio;
struct String
{
ref opOpAssign(string op, R)(R r)
{
convertToBig();
large.ptr[large.len .. r.length] = r;
}
ubyte isBig()
{
return small.slen;
}
void convertToBig()
{
import core.memory;
char* p = cast(char*) GC.malloc(10, GC.BlkAttr.NO_SCAN);
large.ptr = p;
}
struct Small
{
ubyte slen;
}
struct Large
{
size_t len;
char* ptr;
}
Small small;
Large large;
}
unittest
{
auto a = String();
a ~= " test test test test test";
writeln(a);
}
==========
Comment #4 by Marco.Leise — 2018-04-30T19:56:54Z
You allocated 10 bytes for the string " test test test test test". Let me count ... 1 ... 2 ... 3 ... mmh ... no. If it was April 1st, ok, but it is close to May 1st.
Comment #5 by jack — 2018-04-30T20:02:34Z
(In reply to Marco Leise from comment #4)
> You allocated 10 bytes for the string " test test test test test". Let me
> count ... 1 ... 2 ... 3 ... mmh ... no. If it was April 1st, ok, but it is
> close to May 1st.
Reducing this bug isn't easy. I basically have to fight dustmite to not get rid of the actual bug and add in a new bug.
If I'm able to get a good reduced test case I'll reopen.