Either I'm confused or the gc is

donallen donaldcallen at gmail.com
Wed Oct 21 23:02:07 UTC 2020


On Wednesday, 21 October 2020 at 22:28:48 UTC, H. S. Teoh wrote:
> On Wed, Oct 21, 2020 at 09:35:43PM +0000, donallen via 
> Digitalmars-d wrote: [...]
>> [...]
>
> That is correct, since you declared the `children` array as a 
> local variable.
>
>
>> [...]
>
> Also correct. Barring a bug in the GC.
>
>
>> [...]
>
> It would appear to be so, but it's really hard to say without 
> being able to reproduce the problem locally.  Another 
> possibility is memory corruption caused by incorrect 
> translation of C code to D. Generally, this should be pretty 
> rare: Walter designed D syntax to be similar to C syntax such 
> that if it compiles, it should work exactly as it does in C, 
> otherwise there should be a compile error.  But there *are* 
> corner cases where this may inadvertently happen.
>
> There are also some gotchas with interfacing D code with C 
> libraries (sqlite, as you mentioned), which may appear to work 
> at first but may introduce subtle memory problems if not used 
> correctly.
>
> Of course, there *is* the possibility that there's a bug in the 
> GC that causes it to collect prematurely, but IMO the chances 
> of that are pretty low, because D arrays are one of its 
> most-used core features, and if something so basic doesn't work 
> correctly, we would have seen (and fixed) the problem a long 
> time ago.  At least, it would have surfaced in some of the 
> large D projects out there.  But I haven't heard of any such 
> problem recently, except in connection with code that 
> interfaces with C, where sometimes mistakes can happen and 
> memory corruption results.
>
> But on the off-chance there *is* a bug in the GC: we'd greatly 
> appreciate it if you could somehow reduce the problem to a 
> minimal test case that we can reproduce locally so that we can 
> investigate.

I will try.

My suspicion that there's a gc problem largely rests on the fact 
that when I run the program with the gc disabled, the problem 
goes away -- it behaves as it should.

Do you know if there's any way to configure the gc so it tells 
you what it's doing? It would be great if it could be told to 
announce when it's running and what it's collecting. I did a 
little looking in the documentation yesterday for that and did 
not find anything. If you can't help in that area, I'll have a 
look at the gc source code.

>
>
> T



More information about the Digitalmars-d mailing list