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

Re: [PATCH] trace2: prevent segfault on config collection where no value specified

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 7, 2024, 03:02 UTC
Message-ID
<xmqqikszvj8o.fsf@gitster.g>
In-Reply-To
<20241107020100.GC961214@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 11 quoted lines
> I.e., doing this, with an explicit value for the config option:
>
>   GIT_TRACE2=true GIT_TRACE2_CONFIG_PARAMS=status.* git -c status.relativePaths=true version
>
> should (and does) show:
>
>   20:48:11.662470 trace2.c:437                      def_param scope:command status.relativepaths=true
>
> If we swap that our for "-c status.relativePaths", then the outcome is
> the same: we've turned on that config option. But with your patch, the
> trace won't mention it at all.

which may be improvement, but ideally, the "valueless truth" case should be given differently, perhaps like

   20:48:11.662470 trace2.c:437                      def_param scope:command status.relativepaths

to allow showing what exactly the system has seen. After all, trace output is often used for debugging, and it is not unusual for a buggy code path to behave on explicit truth and valueless truth differently.

Show 30 quoted lines
> So here I think we need to either:
>
>   1. Just quietly substitute "true" for the value. For a bool, the two
>      are equivalent, and this is probably an acceptable fiction for a
>      trace to show. For a non-bool (e.g., something like "author.name"),
>      though, it's an error, and the trace is somewhat misleading.
>
>   2. Put in some special marker for the NULL value. Something like
>      "(null)" works, but it's ambiguous with a config of the same value
>      (which obviously you wouldn't expect in normal use, but since the
>      point of tracing is often to debug, I could see it being
>      misleading).
>
> All of this is made harder by the fact that there are multiple output
> targets. So you'd have to pass the NULL down to them and let them handle
> it. Something like:
> ...
> diff --git a/trace2/tr2_tgt_normal.c b/trace2/tr2_tgt_normal.c
> index baef48aa69..924736ab36 100644
> --- a/trace2/tr2_tgt_normal.c
> +++ b/trace2/tr2_tgt_normal.c
> @@ -307,8 +307,9 @@ static void fn_param_fl(const char *file, int line, const char *param,
>  	enum config_scope scope = kvi->scope;
>  	const char *scope_name = config_scope_name(scope);
>  
> -	strbuf_addf(&buf_payload, "def_param scope:%s %s=%s", scope_name, param,
> -		    value);
> +	strbuf_addf(&buf_payload, "def_param scope:%s %s", scope_name, param);
> +	if (value)
> +		strbuf_addf(&buf_payload, "=%s", value);
Yes, exactly.
Show 5 quoted lines
>  	normal_io_write_fl(file, line, &buf_payload);
>  	strbuf_release(&buf_payload);
>  }
>
> but you'd need to do the same for each target implementation.
Thanks.
Previous: Jeff KingNext: Adam Murray via GitGitGadget
Message 3 of 11 in “trace2: prevent segfault on config collection where no value specified”
  1. trace2: prevent segfault on config collection where no value specifiedAdam Murray via GitGitGadget, Nov 7, 2024
  2. Jeff KingNov 7, 2024
  3. Junio C HamanoNov 7, 2024
  4. trace2: prevent segfault on config collection where no value specifiedAdam Murray via GitGitGadget, Jan 10, 2025
  5. Junio C HamanoJan 10, 2025
  6. Johannes SchindelinJan 22, 2025
  7. Junio C HamanoJan 22, 2025
  8. Junio C HamanoJan 22, 2025
  9. D. Ben KnobleJan 23, 2025
  10. Junio C HamanoJan 23, 2025
  11. D. Ben KnobleJan 23, 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.