git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 0/2] Plug two memory leaks exposed via Meson

From
Patrick Steinhardt <ps@pks.im>
Date
Jan 30, 2025, 06:04 UTC
Message-ID
<Z5sWbg_0ri3V_yDm@pks.im>
In-Reply-To
<20250129200509.GA2331283@coredump.intra.peff.net>
On Wed, Jan 29, 2025 at 03:05:09PM -0500, Jeff King wrote:
Show 18 quoted lines
> On Wed, Jan 29, 2025 at 05:24:13PM +0100, Patrick Steinhardt wrote:
> 
> > I've had the need to play around with the memory leak sanitizer today
> > and for the first time used it with Meson. Interestingly enough, a test
> > run with Meson flags two memory leaks that our Makefile doesn't. I
> > haven't found the time yet to figure out why that is, but this small
> > patch series fixes both of these leaks.
> 
> At least for the first one, it depends on how long the path to your
> trash directory is. Doing this:
> 
>   make SANITIZE=leak
>   cd t
>   ./t0301-credential-cache.sh --root=/tmp/this_is_a_very_long_path/the_size_of_sockaddr_un_sun_path_is_usually_108
> 
> will fail reliably (it's not 108, but with the trash directory and xdg
> boilerplate tacked on, it is).  The failed chdir() triggers because it's
> trying the xdg path to see if it exists.

That makes sense indeed, thanks for digging. I'll add that info to the commit message.

[snip]
Show 23 quoted lines
> This test would trigger it reliably, but it's weirdly specific:
> 
> diff --git a/t/t0301-credential-cache.sh b/t/t0301-credential-cache.sh
> index dc30289f75..0ef8ce4e60 100755
> --- a/t/t0301-credential-cache.sh
> +++ b/t/t0301-credential-cache.sh
> @@ -134,6 +134,13 @@ test_expect_success SYMLINKS 'use user socket if user directory is a symlink to
>  	test_path_is_socket "$HOME/.git-credential-cache/socket"
>  '
>  
> +test_expect_success 'error path for chdir of long socket name' '
> +	A=aaaaaaaaaaaaaaaa &&
> +	LONG=$A/$A/$A/$A/$A/$A/$A/$A &&
> +	# do not create $LONG; we want to trigger the error
> +	git credential-cache --socket "$PWD/$LONG/socket" exit
> +'
> +
>  helper_test_timeout cache --timeout=1
>  
>  test_done
> 
> So I don't know if it's worth adding in to your patch. The fix itself is
> obviously correct.
Yeah, it doesn't really feel worth it from my perspective.
Patrick
Previous: Jeff KingNext: Patrick Steinhardt
Message 9 of 13 in “Plug two memory leaks exposed via Meson”
  1. 0/2 Plug two memory leaks exposed via MesonPatrick Steinhardt, Jan 29, 2025
  2. 1/2 unix-socket: fix memory leak when chdir(3p) failsPatrick Steinhardt, Jan 29, 2025
  3. Junio C HamanoJan 29, 2025
  4. Jeff KingJan 29, 2025
  5. Patrick SteinhardtJan 30, 2025
  6. Junio C HamanoJan 30, 2025
  7. 2/2 scalar: free result of `remote_default_branch()`Patrick Steinhardt, Jan 29, 2025
  8. Jeff KingJan 29, 2025
  9. Patrick SteinhardtJan 30, 2025
  10. 0/2 Plug two memory leaks exposed via MesonPatrick Steinhardt, Jan 30, 2025
  11. 1/2 unix-socket: fix memory leak when chdir(3p) failsPatrick Steinhardt, Jan 30, 2025
  12. 2/2 scalar: free result of `remote_default_branch()`Patrick Steinhardt, Jan 30, 2025
  13. Junio C HamanoJan 30, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.