Re: [spice-server 2/2] Add missing chainups to parent class

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 
> A few dispose/finalize implementations were not chaining up to their
> parent classes, causing memory leaks.
> 
> This fixes leaks like the following:
> 
> ==16240== Memcheck, a memory error detector
> ==16240== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
> ==16240== Using Valgrind-3.12.0 and LibVEX; rerun with -h for copyright info
> ==16240== Command: ./test-leaks
> ==16240==
> ==16240==
> ==16240== HEAP SUMMARY:
> ==16240==     in use at exit: 245,490 bytes in 3,638 blocks
> ==16240==   total heap usage: 5,418 allocs, 1,780 frees, 17,676,968 bytes
> allocated
> ==16240==
> ==16240== 16 bytes in 1 blocks are definitely lost in loss record 203 of 771
> ==16240==    at 0x4C2DADE: malloc (vg_replace_malloc.c:298)
> ==16240==    by 0x4C2FC91: realloc (vg_replace_malloc.c:785)
> ==16240==    by 0x52864E: dispatcher_register_handler (dispatcher.c:374)
> ==16240==    by 0x5293E0: main_dispatcher_constructed (main-dispatcher.c:315)
> ==16240==    by 0x7F873DB: g_object_new_internal (gobject.c:1823)
> ==16240==    by 0x7F87EE4: g_object_new_valist (gobject.c:2042)
> ==16240==    by 0x7F86E90: g_object_new (gobject.c:1626)
> ==16240==    by 0x5292A5: main_dispatcher_new (main-dispatcher.c:295)
> ==16240==    by 0x429A0A: do_spice_init (reds.c:3416)
> ==16240==    by 0x42A3F5: spice_server_init (reds.c:3663)
> ==16240==    by 0x4095B1: server_leaks (test-leaks.c:45)
> ==16240==    by 0x844C60A: test_case_run (gtestutils.c:2161)
> ==16240==    by 0x844C9CA: g_test_run_suite_internal (gtestutils.c:2244)
> ==16240==    by 0x844CA73: g_test_run_suite_internal (gtestutils.c:2256)
> ==16240==    by 0x844CC8A: g_test_run_suite (gtestutils.c:2332)
> ==16240==    by 0x844B92C: g_test_run (gtestutils.c:1599)
> ==16240==    by 0x409A0B: main (test-leaks.c:126)
> ==16240==
> ==16240== 16 bytes in 1 blocks are definitely lost in loss record 204 of 771
> ==16240==    at 0x4C2DADE: malloc (vg_replace_malloc.c:298)
> ==16240==    by 0x4C2FC91: realloc (vg_replace_malloc.c:785)
> ==16240==    by 0x52864E: dispatcher_register_handler (dispatcher.c:374)
> ==16240==    by 0x5293E0: main_dispatcher_constructed (main-dispatcher.c:315)
> ==16240==    by 0x7F873DB: g_object_new_internal (gobject.c:1823)
> ==16240==    by 0x7F87EE4: g_object_new_valist (gobject.c:2042)
> ==16240==    by 0x7F86E90: g_object_new (gobject.c:1626)
> ==16240==    by 0x5292A5: main_dispatcher_new (main-dispatcher.c:295)
> ==16240==    by 0x429A0A: do_spice_init (reds.c:3416)
> ==16240==    by 0x42A3F5: spice_server_init (reds.c:3663)
> ==16240==    by 0x40BFD4: test_new (test-display-base.c:902)
> ==16240==    by 0x40979D: vmc_leaks (test-leaks.c:92)
> ==16240==    by 0x844C60A: test_case_run (gtestutils.c:2161)
> ==16240==    by 0x844C9CA: g_test_run_suite_internal (gtestutils.c:2244)
> ==16240==    by 0x844CA73: g_test_run_suite_internal (gtestutils.c:2256)
> ==16240==    by 0x844CC8A: g_test_run_suite (gtestutils.c:2332)
> ==16240==    by 0x844B92C: g_test_run (gtestutils.c:1599)
> ==16240==    by 0x409A0B: main (test-leaks.c:126)
> ==16240==
> ==16240== 96 bytes in 1 blocks are definitely lost in loss record 638 of 771
> ==16240==    at 0x4C2FA50: calloc (vg_replace_malloc.c:711)
> ==16240==    by 0x8427D3C: g_malloc0 (gmem.c:124)
> ==16240==    by 0x842801F: g_malloc0_n (gmem.c:355)
> ==16240==    by 0x527B44: dispatcher_constructed (dispatcher.c:141)
> ==16240==    by 0x529321: main_dispatcher_constructed (main-dispatcher.c:307)
> ==16240==    by 0x7F873DB: g_object_new_internal (gobject.c:1823)
> ==16240==    by 0x7F87EE4: g_object_new_valist (gobject.c:2042)
> ==16240==    by 0x7F86E90: g_object_new (gobject.c:1626)
> ==16240==    by 0x5292A5: main_dispatcher_new (main-dispatcher.c:295)
> ==16240==    by 0x429A0A: do_spice_init (reds.c:3416)
> ==16240==    by 0x42A3F5: spice_server_init (reds.c:3663)
> ==16240==    by 0x4095B1: server_leaks (test-leaks.c:45)
> ==16240==    by 0x844C60A: test_case_run (gtestutils.c:2161)
> ==16240==    by 0x844C9CA: g_test_run_suite_internal (gtestutils.c:2244)
> ==16240==    by 0x844CA73: g_test_run_suite_internal (gtestutils.c:2256)
> ==16240==    by 0x844CC8A: g_test_run_suite (gtestutils.c:2332)
> ==16240==    by 0x844B92C: g_test_run (gtestutils.c:1599)
> ==16240==    by 0x409A0B: main (test-leaks.c:126)
> ==16240==
> ==16240== 96 bytes in 1 blocks are definitely lost in loss record 639 of 771
> ==16240==    at 0x4C2FA50: calloc (vg_replace_malloc.c:711)
> ==16240==    by 0x8427D3C: g_malloc0 (gmem.c:124)
> ==16240==    by 0x842801F: g_malloc0_n (gmem.c:355)
> ==16240==    by 0x527B44: dispatcher_constructed (dispatcher.c:141)
> ==16240==    by 0x529321: main_dispatcher_constructed (main-dispatcher.c:307)
> ==16240==    by 0x7F873DB: g_object_new_internal (gobject.c:1823)
> ==16240==    by 0x7F87EE4: g_object_new_valist (gobject.c:2042)
> ==16240==    by 0x7F86E90: g_object_new (gobject.c:1626)
> ==16240==    by 0x5292A5: main_dispatcher_new (main-dispatcher.c:295)
> ==16240==    by 0x429A0A: do_spice_init (reds.c:3416)
> ==16240==    by 0x42A3F5: spice_server_init (reds.c:3663)
> ==16240==    by 0x40BFD4: test_new (test-display-base.c:902)
> ==16240==    by 0x40979D: vmc_leaks (test-leaks.c:92)
> ==16240==    by 0x844C60A: test_case_run (gtestutils.c:2161)
> ==16240==    by 0x844C9CA: g_test_run_suite_internal (gtestutils.c:2244)
> ==16240==    by 0x844CA73: g_test_run_suite_internal (gtestutils.c:2256)
> ==16240==    by 0x844CC8A: g_test_run_suite (gtestutils.c:2332)
> ==16240==    by 0x844B92C: g_test_run (gtestutils.c:1599)
> ==16240==    by 0x409A0B: main (test-leaks.c:126)
> ==16240==
> ==16240== LEAK SUMMARY:
> ==16240==    definitely lost: 224 bytes in 4 blocks
> ==16240==    indirectly lost: 0 bytes in 0 blocks
> ==16240==      possibly lost: 0 bytes in 0 blocks
> ==16240==    still reachable: 207,718 bytes in 3,312 blocks
> ==16240==                       of which reachable via heuristic:
> ==16240==                         newarray           : 1,536 bytes in 16
> blocks
> ==16240==         suppressed: 34,548 bytes in 302 blocks
> ==16240== Reachable blocks (those to which a pointer was found) are not
> shown.
> ==16240== To see them, rerun with: --leak-check=full --show-leak-kinds=all
> ==16240==
> ==16240== For counts of detected and suppressed errors, rerun with: -v
> ==16240== ERROR SUMMARY: 4 errors from 4 contexts (suppressed: 20 from 20)
> FAIL test-leaks (exit status: 1)

Acked-by: Frediano Ziglio <fziglio@xxxxxxxxxx>

Frediano

> ---
>  server/main-dispatcher.c | 1 +
>  server/reds.c            | 2 ++
>  server/spicevmc.c        | 1 +
>  3 files changed, 4 insertions(+)
> 
> diff --git a/server/main-dispatcher.c b/server/main-dispatcher.c
> index 51d6004..019bf4d 100644
> --- a/server/main-dispatcher.c
> +++ b/server/main-dispatcher.c
> @@ -332,4 +332,5 @@ static void main_dispatcher_finalize(GObject *object)
>  
>      self->priv->core->watch_remove(self->priv->core, self->priv->watch);
>      self->priv->watch = NULL;
> +    G_OBJECT_CLASS(main_dispatcher_parent_class)->finalize(object);
>  }
> diff --git a/server/reds.c b/server/reds.c
> index a165a9b..c730daa 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -4525,6 +4525,8 @@ red_char_device_vdi_port_finalize(GObject *object)
>  
>     free(dev->priv->mig_data);
>     /* FIXME: need to free the RedVDIReadBuf allocated previously */
> +
> +    G_OBJECT_CLASS(red_char_device_vdi_port_parent_class)->finalize(object);
>  }
>  
>  static void
> diff --git a/server/spicevmc.c b/server/spicevmc.c
> index 615e317..623e34f 100644
> --- a/server/spicevmc.c
> +++ b/server/spicevmc.c
> @@ -914,6 +914,7 @@ red_char_device_spicevmc_dispose(GObject *object)
>          red_channel_destroy(channel);
>          self->channel = NULL;
>      }
> +    G_OBJECT_CLASS(red_char_device_spicevmc_parent_class)->dispose(object);
>  }
>  
>  enum {
> --
> 2.9.3
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
> 
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]