public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ada/115630] New: Bounded queue does not finalize controlled components
@ 2024-06-25  7:07 saulius.grazulis at bti dot vu.lt
  2024-06-27 10:55 ` [Bug ada/115630] " ebotcazou at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: saulius.grazulis at bti dot vu.lt @ 2024-06-25  7:07 UTC (permalink / raw)
  To: gcc-bugs

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')

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug ada/115630] Bounded queue does not finalize controlled components
  2024-06-25  7:07 [Bug ada/115630] New: Bounded queue does not finalize controlled components saulius.grazulis at bti dot vu.lt
@ 2024-06-27 10:55 ` ebotcazou at gcc dot gnu.org
  2024-06-27 11:26 ` saulius.grazulis at bti dot vu.lt
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2024-06-27 10:55 UTC (permalink / raw)
  To: gcc-bugs

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

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2024-06-27
     Ever confirmed|0                           |1
                 CC|                            |ebotcazou at gcc dot gnu.org
             Status|UNCONFIRMED                 |WAITING

--- Comment #1 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
Please try with newer versions, 14.x at least or else mainline.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug ada/115630] Bounded queue does not finalize controlled components
  2024-06-25  7:07 [Bug ada/115630] New: Bounded queue does not finalize controlled components saulius.grazulis at bti dot vu.lt
  2024-06-27 10:55 ` [Bug ada/115630] " ebotcazou at gcc dot gnu.org
@ 2024-06-27 11:26 ` saulius.grazulis at bti dot vu.lt
  2024-06-27 11:29 ` saulius.grazulis at bti dot vu.lt
  2024-06-27 11:33 ` ebotcazou at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: saulius.grazulis at bti dot vu.lt @ 2024-06-27 11:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Saulius Gražulis <saulius.grazulis at bti dot vu.lt> ---
OK, I can confirm that GNAT 15.0 from the git://gcc.gnu.org/git/gcc.git master
no longer gas the bug, the finalization behaves as expected:

saulius@pterodaktilis queue-finlisation/ $
PATH=$HOME/install/gnat-alire/gnat-13.2.1/bin:$PATH

saulius@pterodaktilis queue-finlisation/ $ gnatclean check_queue_finalisation
"./check_queue_finalisation.ali" has been deleted
"./check_queue_finalisation.o" has been deleted
"check_queue_finalisation" has been deleted

saulius@pterodaktilis queue-finlisation/ $ gnatmake check_queue_finalisation
gcc -c check_queue_finalisation.adb
gnatbind -x check_queue_finalisation.ali
gnatlink check_queue_finalisation.ali

saulius@pterodaktilis queue-finlisation/ $ ./check_queue_finalisation | grep
'Disposing' 
>>> Disposing 'Thing'  Address:  140729416360224 Name: 'T' Some_Stuff: Count:  0 Name: 't'
saulius@pterodaktilis queue-finlisation/ $ 
saulius@pterodaktilis queue-finlisation/ $
PATH=$HOME/install/gcc/gcc-gnu-commit-7fada36c778/bin:$PATH

# Too few 'Dispose' procedures called...

saulius@pterodaktilis queue-finlisation/ $ gnat --version
GNAT 15.0.0 20240626 (experimental)
Copyright (C) 1996-2024, Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

saulius@pterodaktilis queue-finlisation/ $ gnatclean check_queue_finalisation
"./check_queue_finalisation.ali" has been deleted
"./check_queue_finalisation.o" has been deleted
"check_queue_finalisation" has been deleted

saulius@pterodaktilis queue-finlisation/ $ gnatmake check_queue_finalisation
gcc -c check_queue_finalisation.adb
gnatbind -x check_queue_finalisation.ali
gnatlink check_queue_finalisation.ali

saulius@pterodaktilis queue-finlisation/ $ ./check_queue_finalisation | grep
'Disposing' 
>>> Disposing 'Thing'  Address:  140735380336864 Name: 'T' Some_Stuff: Count:  0 Name: 't'
>>> Disposing 'Thing'  Address:  140735380334504 Name: 'Y' Some_Stuff: Count:  0 Name: 'y'
>>> Disposing 'Thing'  Address:  140735380334472 Name: 'X' Some_Stuff: Count:  0 Name: 'x'
>>> Disposing 'Thing'  Address:  140735380336768 Name: 'U' Some_Stuff: Count:  0 Name: 'u'
>>> Disposing 'Thing'  Address:  140735380336864 Name: 'W' Some_Stuff: Count:  0 Name: 'w'

# All objects Dispose'd as intended :)

Sorry for the false alarm, and thanks for the rapid fixes! (Did not expect the
15.0 o have the issue fixed already :)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug ada/115630] Bounded queue does not finalize controlled components
  2024-06-25  7:07 [Bug ada/115630] New: Bounded queue does not finalize controlled components saulius.grazulis at bti dot vu.lt
  2024-06-27 10:55 ` [Bug ada/115630] " ebotcazou at gcc dot gnu.org
  2024-06-27 11:26 ` saulius.grazulis at bti dot vu.lt
@ 2024-06-27 11:29 ` saulius.grazulis at bti dot vu.lt
  2024-06-27 11:33 ` ebotcazou at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: saulius.grazulis at bti dot vu.lt @ 2024-06-27 11:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Saulius Gražulis <saulius.grazulis at bti dot vu.lt> ---
PS All other queues also behave as expected when compiled with GNAT 15.0.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug ada/115630] Bounded queue does not finalize controlled components
  2024-06-25  7:07 [Bug ada/115630] New: Bounded queue does not finalize controlled components saulius.grazulis at bti dot vu.lt
                   ` (2 preceding siblings ...)
  2024-06-27 11:29 ` saulius.grazulis at bti dot vu.lt
@ 2024-06-27 11:33 ` ebotcazou at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2024-06-27 11:33 UTC (permalink / raw)
  To: gcc-bugs

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

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
   Target Milestone|---                         |14.0
             Status|WAITING                     |RESOLVED

--- Comment #4 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
Thanks for confirming.  This also works with 14.x for me.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-06-27 11:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-25  7:07 [Bug ada/115630] New: Bounded queue does not finalize controlled components saulius.grazulis at bti dot vu.lt
2024-06-27 10:55 ` [Bug ada/115630] " ebotcazou at gcc dot gnu.org
2024-06-27 11:26 ` saulius.grazulis at bti dot vu.lt
2024-06-27 11:29 ` saulius.grazulis at bti dot vu.lt
2024-06-27 11:33 ` ebotcazou at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).