https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109003
Bug ID: 109003 Summary: memory leak in module loading (mio_formal_arglist) Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: rguenth at gcc dot gnu.org Target Milestone: --- valgrind complains when building SPEC 2017 521.wrf ==24177== 32 bytes in 2 blocks are possibly lost in loss record 66 of 2,272 ==24177== at 0x4C39571: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==24177== by 0x1C071F0: xcalloc (xmalloc.c:164) ==24177== by 0x766248: mio_formal_arglist (module.cc:3201) ==24177== by 0x766248: mio_symbol(gfc_symbol*) (module.cc:4586) ==24177== by 0x766836: load_needed(pointer_info*) (module.cc:5195) ==24177== by 0x7667E0: load_needed(pointer_info*) (module.cc:5154) ==24177== by 0x7667D5: load_needed(pointer_info*) (module.cc:5153) ==24177== by 0x7667D5: load_needed(pointer_info*) (module.cc:5153) ==24177== by 0x7667E0: load_needed(pointer_info*) (module.cc:5154) ==24177== by 0x7667D5: load_needed(pointer_info*) (module.cc:5153) ==24177== by 0x7667D5: load_needed(pointer_info*) (module.cc:5153) ==24177== by 0x7667D5: load_needed(pointer_info*) (module.cc:5153) ==24177== by 0x767C0B: read_module() (module.cc:5697) I'm not sure what actually happens, but I guess sym->formal is eventually replaced so the allocated memory gets dangling? Or we free some of the module memory later but not everything. It seems valgrind complains about a lot of leaks when modules are involved.