[Bug fortran/97123] New: double free detected in tcache 2 with recursive allocatable type

igor.gayday at mu dot edu gcc-bugzilla@gcc.gnu.org
Sun Sep 20 05:41:39 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97123

            Bug ID: 97123
           Summary: double free detected in tcache 2 with recursive
                    allocatable type
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: igor.gayday at mu dot edu
  Target Milestone: ---

Consider the following program:

program test_prg
  implicit none

  type :: recursive_block
    type(recursive_block), allocatable :: subblocks(:, :)
  end type

  type(recursive_block) :: top_level
  top_level = init_recursive()
  deallocate(top_level % subblocks)

contains

  function init_recursive() result(res)
    type(recursive_block) :: res
    type(recursive_block), allocatable :: inner(:, :)

    allocate(inner(1, 1))
    allocate(inner(1, 1) % subblocks(1, 1))
    res % subblocks = inner
  end function
end program

Compiled with gfortran 10.2, it crashes at runtime on deallocate(top_level %
subblocks) with the following message:
free(): double free detected in tcache 2


More information about the Gcc-bugs mailing list