Bug 24498 – Multidimensional array not scanned by GC
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2024-04-13T17:31:43Z
Last change time
2024-04-23T14:24:15Z
Keywords
pull
Assigned to
No Owner
Creator
Tim
Comments
Comment #0 by tim.dlang — 2024-04-13T17:31:43Z
This is similar to issue 24436:
```
import std.stdio, core.memory;
void main()
{
int[][][] a = new int[][][](2, 2);
assert(!(GC.getAttr(a[0].ptr) & GC.BlkAttr.NO_SCAN)); // fails now
}
```
The array has three dimensions, but only two are initialized. The middle arrays need to be scanned by the GC, but they are marked as NO_SCAN. The problem exists since https://github.com/dlang/dmd/commit/055accfbe6afe5f72c77617d54f737e71e29f5a3
A similar problem has already been solved in https://github.com/dlang/dmd/pull/16373
The initialization is lowered to _d_newarraymTX!(int[][][], int, int[][]). Maybe this should be _d_newarraymTX!(int[][][], int[], int[][]) instead, because the element type of the array should be int[] and not int.
Comment #1 by dlang-bot — 2024-04-19T18:53:39Z
@tim-dlang created dlang/dmd pull request #16400 "Fix bugzilla 24498 - Multidimensional array not scanned by GC" fixing this issue:
- Fix bugzilla 24498 - Multidimensional array not scanned by GC
For expression `new int[][][](2, 2)` the relevant element type is
`int[]` and not `int`, because only two dimensions are allocated.
https://github.com/dlang/dmd/pull/16400
Comment #2 by tim.dlang — 2024-04-19T18:57:43Z
*** Issue 24440 has been marked as a duplicate of this issue. ***
Comment #3 by dlang-bot — 2024-04-19T20:13:33Z
dlang/dmd pull request #16400 "Fix bugzilla 24498 - Multidimensional array not scanned by GC" was merged into stable:
- f39cc10ef9b4d3e92d0172a41e6b9515de0ba8d0 by Tim Schendekehl:
Fix bugzilla 24498 - Multidimensional array not scanned by GC
For expression `new int[][][](2, 2)` the relevant element type is
`int[]` and not `int`, because only two dimensions are allocated.
https://github.com/dlang/dmd/pull/16400
Comment #4 by dlang-bot — 2024-04-23T14:24:15Z
dlang/dmd pull request #16406 "Merge stable" was merged into master:
- f1307d6c75bef4aaddaba1451b71687e62d21790 by Tim Schendekehl:
Fix bugzilla 24498 - Multidimensional array not scanned by GC (#16400)
For expression `new int[][][](2, 2)` the relevant element type is
`int[]` and not `int`, because only two dimensions are allocated.
https://github.com/dlang/dmd/pull/16406