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

Re: [XEN PATCH] tools/console/daemon: fix log_dir memory leak in xenconsoled


  • To: Andrew Mbugua <andrewprecious388@xxxxxxxxx>
  • From: Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • Date: Mon, 12 Oct 2026 15:35:38 +0200
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=vates.tech header.i="@vates.tech" header.h="From:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type:In-Reply-To:References:Feedback-ID"
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Mon, 12 Oct 2026 13:36:00 +0000
  • Feedback-id: default:8631fc262581453bbf619ec5b2062170:Sweego
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Fri, Aug 14, 2026 at 12:27:23AM +0300, Andrew Mbugua wrote:
> Valgrind reports that 21 bytes are "still reachable" from the (XEN_LOG_DIR 
> "/console") allocation:
> 
> HEAP SUMMARY:
>     in use at exit: 21 bytes in 1 blocks
>     total heap usage: 9 allocs, 8 frees, 4,799 bytes allocated
> 
> Since the dynamic memory allocation for the default log directory path 
> happens before the process
> forks into the background, the parent and intermediate processes exit during 
> daemonize()
> with the memory still reachable.
> 
> Move the strdup() allocation down below the daemonize() block. This ensures 
> only the final
> background daemon allocates the default path, matching the lifetime of the 
> free(log_dir)
> cleanup loop at the exit of main().
> 
> With this change, Valgrind reports a clean heap summary
> 
> HEAP SUMMARY:
>     in use at exit: 0 bytes in 0 blocks
>     total heap usage: 8 allocs, 8 frees, 4,778 bytes allocated
> 
> Signed-off-by: Andrew Mbugua <andrewprecious388@xxxxxxxxx>

Reviewed-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>

I'll try to remember to fix the indentation on commit.

Thanks,


--
Anthony Perard | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.