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

            Bug ID: 115630
           Summary: Bounded queue does not finalize controlled components
           Product: gcc
           Version: 13.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
          Assignee: unassigned at gcc dot gnu.org
          Reporter: saulius.grazulis at bti dot vu.lt
                CC: dkm at gcc dot gnu.org
  Target Milestone: ---

Created attachment 58510
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58510&action=edit
Source code, compilation and run logs and command history to reproduce the bug

The controlled components of an instance of the
Ada.Containers.Synchronized_Queue_Interfaces does not run the Finalize
procedure for the elements that are still in the queue when the queue goes out
of scope (e.g. when the control exits a 'declare' block). This can be
demonstrated to lead to memory leaks if Finalize is used to release the memory
(see 'check_queue_finalisation.adb').

When 'check_queue_finalisation' is run, 'Dispose' is called only once from the
'Finalize'. The expected behaviour is that 'Dispose' is called for all
allocated blocks eventually.

The finalisers are not always called even if I wrap my Controlled type value in
am Indefinite_Holder ('check_indefinite_queue_finalisation.adb').

The code works as expected for Unbounded_Synchronized_Queues with an
Indefinite_Holder wrapper ('check_unbounded_indefinite_queue_finalisation.adb')

Reply via email to