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

Re: [PATCH v2] maintenance --unregister: fix uninit'd data use & -Wdeclaration-after-statement

From
Taylor Blau <me@ttaylorr.com>
Date
Nov 15, 2022, 17:34 UTC
Message-ID
<Y3PNolwofKgbkLh5@nand.local>
In-Reply-To
<patch-v2-1.1-f37e99c9d59-20221115T160240Z-avarab@gmail.com>
On Tue, Nov 15, 2022 at 05:04:27PM +0100, Ævar Arnfjörð Bjarmason wrote:
Show 29 quoted lines
> Since (maintenance: add option to register in a specific config,
> 2022-11-09) we've been unable to build with "DEVELOPER=1" without
> "DEVOPTS=no-error", as the added code triggers a
> "-Wdeclaration-after-statement" warning.
>
> And worse than that, the data handed to git_configset_clear() is
> uninitialized, as can be spotted with e.g.:
>
> 	./t7900-maintenance.sh -vixd --run=23 --valgrind
> 	[...]
> 	+ git maintenance unregister --force
> 	Conditional jump or move depends on uninitialised value(s)
> 	   at 0x6B5F1E: git_configset_clear (config.c:2367)
> 	   by 0x4BA64E: maintenance_unregister (gc.c:1619)
> 	   by 0x4BD278: cmd_maintenance (gc.c:2650)
> 	   by 0x409905: run_builtin (git.c:466)
> 	   by 0x40A21C: handle_builtin (git.c:721)
> 	   by 0x40A58E: run_argv (git.c:788)
> 	   by 0x40AF68: cmd_main (git.c:926)
> 	   by 0x5D39FE: main (common-main.c:57)
> 	 Uninitialised value was created by a stack allocation
> 	   at 0x4BA22C: maintenance_unregister (gc.c:1557)
>
> Let's fix both of these issues, and also move the scope of the
> variable to the "if" statement it's used in, to make it obvious where
> it's used.
>
> Helped-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>

Thanks, both. I could have sworn I picked up the right version of this topic when queuing, but apparently not.

I pushed this out to 'next' and rebuilt jch and seen based on the new version. The result now should be OK. Thanks again for noticing and working together.

Thanks, Taylor

Previous: Taylor Blau
Message 10 of 10 in “builtin/gc.c: fix -Wdeclaration-after-statement”
  1. builtin/gc.c: fix -Wdeclaration-after-statementÆvar Arnfjörð Bjarmason, Nov 15, 2022
  2. Johannes SchindelinNov 15, 2022
  3. Johannes SchindelinNov 15, 2022
  4. Ævar Arnfjörð BjarmasonNov 15, 2022
  5. maintenance --unregister: fix uninit'd data use & -Wdeclaration-after-statementÆvar Arnfjörð Bjarmason, Nov 15, 2022
  6. ronan@rjp.ieNov 15, 2022
  7. Taylor BlauNov 15, 2022
  8. ronan@rjp.ieNov 15, 2022
  9. Taylor BlauNov 15, 2022
  10. Taylor BlauNov 15, 2022

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.