April 04, 2023
https://issues.dlang.org/show_bug.cgi?id=23821

          Issue ID: 23821
           Summary: Valgrind issue with dynamic arrays
           Product: D
           Version: D2
          Hardware: x86_64
                OS: FreeBSD
            Status: NEW
          Severity: normal
          Priority: P1
         Component: druntime
          Assignee: nobody@puremagic.com
          Reporter: FreeBSD@SystemGoats.com

/* memtest2.d
   ldc version 1.30.0 (DMD v2.100.1, LLVM 13.0.1)(x86_64-portbld-freebsd13.1)
   Compile: ldc2 memtest2.d
   Run:     valgrind -s --leak-check=full ./memtest2
*/

void main () {
  int[1] foo;
  int[] bar;
  foo[0] = 5;   // OK
  bar ~= 5;     // Valgrind issue. Comment out for re-test without error.
}

//////////////////////////////////////////////////////////////////////////

==6448== Memcheck, a memory error detector
==6448== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==6448== Using Valgrind-3.20.0 and LibVEX; rerun with -h for copyright info
==6448== Command: ./memtest2
==6448==
==6448==
==6448== HEAP SUMMARY:
==6448==     in use at exit: 1,848 bytes in 5 blocks
==6448==   total heap usage: 490 allocs, 485 frees, 178,156 bytes allocated
==6448==
==6448== 32 bytes in 1 blocks are possibly lost in loss record 1 of 5
==6448==    at 0x484CBC4: malloc (in
/usr/local/libexec/valgrind/vgpreload_memcheck-amd64-freebsd.so)
==6448==    by 0x23FD3A:
_D4core8internal2gc4impl12conservativeQw10initializeFZCQCbQBq11gcinterface2GC
(in /usr/home/A/B/memtest/memtest2)
==6448==    by 0x23EF49:
_D4core2gc8registry16createGCInstanceFAyaZCQBpQBn11gcinterface2GC (in
/usr/home/A/B/memtest/memtest2)
==6448==    by 0x23E2EC: gc_init (in /usr/home/A/B/memtest/memtest2)
==6448==    by 0x23E365: gc_init_nothrow (in /usr/home/A/B/memtest/memtest2)
==6448==    by 0x2595C7:
_DThn16_4core8internal2gc4impl5protoQo7ProtoGC6qallocMFNbmkMxC8TypeInfoZSQCn6memory8BlkInfo_
(in /usr/home/A/B/memtest/memtest2)
==6448==    by 0x23E4EB: gc_qalloc (in /usr/home/A/B/memtest/memtest2)
==6448==    by 0x285B0D: _d_arrayappendcTX (in /usr/home/A/B/memtest/memtest2)
==6448==    by 0x232C7A: _Dmain (in /usr/home/A/B/memtest/memtest2)
==6448==    by 0x233227: _D2rt6dmain212_d_run_main2UAAamPUQgZiZ6runAllMFZv (in
/usr/home/A/B/memtest/memtest2)
==6448==    by 0x2330F5: _d_run_main2 (in /usr/home/A/B/memtest/memtest2)
==6448==    by 0x232F4D: _d_run_main (in /usr/home/A/B/memtest/memtest2)
==6448==
==6448== LEAK SUMMARY:
==6448==    definitely lost: 0 bytes in 0 blocks
==6448==    indirectly lost: 0 bytes in 0 blocks
==6448==      possibly lost: 32 bytes in 1 blocks
==6448==    still reachable: 1,816 bytes in 4 blocks
==6448==         suppressed: 0 bytes in 0 blocks
==6448== Reachable blocks (those to which a pointer was found) are not shown.
==6448== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==6448==
==6448== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

--