ldc-developers/ldc — Issue #51: invalid memory read in gc
Author: pompei2
Created: 2011-12-17 18:53:57+00:00
State: open

Compiling an empty D2 program (void main() {}) using ldc2 master (ldc b41688a, druntime v2.054-226-g10e4512 and phobos v2.054-844-g1f6264e) and then running it through valgrind gives me an invalid read, conditional jump depending on uninit value and 5 leaks. (for details: http://pastebin.com/sEfnqUdd).

Compiling the same program with the dmd 2.057 from d-p-l.org and running it through valgrind gives no invalid read or conditional jump depending on uninit value and only 4 memory leaks, which are included in the 5 from ldc2. The one which happens only if using ldc2 is #2.

line 2280 in gcx.d (which is the offending line) contains the following code:
auto p = cast(byte *)(*p1);

and the conditional jump depending on uninit value is most probably just a subsequent error which will go away when the invalid read is solved.

pompei2: Looks like one of the GC root ranges our druntime uses is off, thus producing an invalid read. Don't know off-hand fi this is a bug, though [...]