-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
trace2: prevent segfault on config collection where no value specified #1814
base: master
Are you sure you want to change the base?
Conversation
Welcome to GitGitGadgetHi @ad-murray, and welcome to GitGitGadget, the GitHub App to send patch series to the Git mailing list from GitHub Pull Requests. Please make sure that either:
You can CC potential reviewers by adding a footer to the PR description with the following syntax:
NOTE: DO NOT copy/paste your CC list from a previous GGG PR's description, Also, it is a good idea to review the commit messages one last time, as the Git project expects them in a quite specific form:
It is in general a good idea to await the automated test ("Checks") in this Pull Request before contributing the patches, e.g. to avoid trivial issues such as unportable code. Contributing the patchesBefore you can contribute the patches, your GitHub username needs to be added to the list of permitted users. Any already-permitted user can do that, by adding a comment to your PR of the form Both the person who commented An alternative is the channel
Once on the list of permitted usernames, you can contribute the patches to the Git mailing list by adding a PR comment If you want to see what email(s) would be sent for a After you submit, GitGitGadget will respond with another comment that contains the link to the cover letter mail in the Git mailing list archive. Please make sure to monitor the discussion in that thread and to address comments and suggestions (while the comments and suggestions will be mirrored into the PR by GitGitGadget, you will still want to reply via mail). If you do not want to subscribe to the Git mailing list just to be able to respond to a mail, you can download the mbox from the Git mailing list archive (click the curl -g --user "<EMailAddress>:<Password>" \
--url "imaps://imap.gmail.com/INBOX" -T /path/to/raw.txt To iterate on your change, i.e. send a revised patch or patch series, you will first want to (force-)push to the same branch. You probably also want to modify your Pull Request description (or title). It is a good idea to summarize the revision by adding something like this to the cover letter (read: by editing the first comment on the PR, i.e. the PR description):
To send a new iteration, just add another PR comment with the contents: Need help?New contributors who want advice are encouraged to join [email protected], where volunteers who regularly contribute to Git are willing to answer newbie questions, give advice, or otherwise provide mentoring to interested contributors. You must join in order to post or view messages, but anyone can join. You may also be able to find help in real time in the developer IRC channel, |
There are issues in commit 2d4ddcf: |
/allow ad-murray |
User ad-murray is now allowed to use GitGitGadget. WARNING: ad-murray has no public email address set on GitHub; |
2d4ddcf
to
976bdf6
Compare
There are issues in commit 976bdf6: |
976bdf6
to
b696097
Compare
There are issues in commit b696097: |
Please follow the guidance in https://github.blog/2022-06-30-write-better-commits-build-better-projects/ to improve it, in particular with a strong focus on this part:
In this instance, the commit message could explain, for example, why the
The Git project requires you to "sign off" your work, please amend the commit accordingly and force-push. |
b696097
to
9b505b7
Compare
There are issues in commit 9b505b7: |
9b505b7
to
48ffb81
Compare
There are issues in commit 48ffb81: |
48ffb81
to
c35764e
Compare
Commit message updated, is there a way to re-run the failing checks? |
Well, those checks fail because the patch introduces a regression. In particular t1300.131 documents that Speaking of test cases: You described one in the commit message. How about moving it from the commit message into an actual test script, to verify that the described regression is fixed (and to prevent future regressions going unnoticed)? As to the fix for the segmentation fault: I think this diff, or a variation thereof, should be the correct fix: diff --git a/trace2.c b/trace2.c
index f894532d0533..6cae41ca61c4 100644
--- a/trace2.c
+++ b/trace2.c
@@ -259,7 +259,7 @@ static const char *redact_arg(const char *arg)
const char *p, *colon;
size_t at;
- if (!trace2_redact ||
+ if (!trace2_redact || !arg ||
(!skip_prefix(arg, "https://", &p) &&
!skip_prefix(arg, "http://", &p)))
return arg; |
right you are, will do |
0c5d185
to
25cd431
Compare
/submit |
1 similar comment
/submit |
fe611b8
to
b4e30d8
Compare
/submit |
Error: Ignoring PR with empty title and/or body |
@ad-murray This means that GitGitGadget requires a cover letter (which is composed of the PR title, and the PR description, i.e. the initial comment). However, in this instance I am convinced that you do not want to contribute three patches; Instead, you will want to "squash" them into a single commit. Once you do that, you do not need to populate the initial comment with content for a cover letter, as none will be sent for single-patch contributions, as per the Git maintainer's request. |
b4e30d8
to
2253303
Compare
There are issues in commit 627d9b5: |
1 similar comment
There are issues in commit 627d9b5: |
There are issues in commit e48f724: |
e48f724
to
a4d1f1d
Compare
There are issues in commit a4d1f1d: |
a4d1f1d
to
a334b65
Compare
There are issues in commit a334b65: |
0a03293
to
6c358ea
Compare
When TRACE2 analytics is enabled, a git config option that has no value causes a segfault. Steps to Reproduce GIT_TRACE2=true GIT_TRACE2_CONFIG_PARAMS=status.* git -c status.relativePaths version Expected Result git version 2.46.0 Actual Result zsh: segmentation fault GIT_TRACE2=true This adds checks to prevent the segfault and instead return an empty value. Signed-off-by: Adam Murray <[email protected]>
6c358ea
to
fd7bed5
Compare
/submit |
Submitted as [email protected] To fetch this version into
To fetch this version to local tag
|
On the Git mailing list, Junio C Hamano wrote (reply to this): "Adam Murray via GitGitGadget" <[email protected]> writes:
> From: Adam Murray <[email protected]>
>
> When TRACE2 analytics is enabled, a git config option that has no value
> causes a segfault.
We often call this "valueless true syntax". It may techincally
correct to say "has no value", but it is more friendly to readers if
you said "a configuration variable that is set to 'true' with
the valueless true syntax".
> diff --git a/trace2.c b/trace2.c
> index f894532d053..49e7d1db88f 100644
> --- a/trace2.c
> +++ b/trace2.c
> @@ -762,7 +762,7 @@ void trace2_def_param_fl(const char *file, int line, const char *param,
> if (!trace2_enabled)
> return;
>
> - redacted = redact_arg(value);
> + redacted = value ? redact_arg(value): NULL;
>
> for_each_wanted_builtin (j, tgt_j)
> if (tgt_j->pfn_param_fl)
> diff --git a/trace2/tr2_tgt_event.c b/trace2/tr2_tgt_event.c
> index 45b0850a5ec..8e09485c83c 100644
> --- a/trace2/tr2_tgt_event.c
> +++ b/trace2/tr2_tgt_event.c
> @@ -491,7 +491,8 @@ static void fn_param_fl(const char *file, int line, const char *param,
> event_fmt_prepare(event_name, file, line, NULL, &jw);
> jw_object_string(&jw, "scope", scope_name);
> jw_object_string(&jw, "param", param);
> - jw_object_string(&jw, "value", value);
> + if (value)
> + jw_object_string(&jw, "value", value);
> jw_end(&jw);
OK, so for "valueless true", we do not get the "value" element in
the json output, which makes sense. Don't we have documentation
that explains what each element in the output means and when they
are given? Shouldn't we update it?
> - 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);
OK.
The input did not spell the "=value" part and said "[section] key"
to mean that section.key is true, so we report that without "=value"
part. This also makes sense.
> diff --git a/trace2/tr2_tgt_perf.c b/trace2/tr2_tgt_perf.c
> index a6f9a8a193e..19ae7433ef8 100644
> --- a/trace2/tr2_tgt_perf.c
> +++ b/trace2/tr2_tgt_perf.c
> @@ -446,8 +446,9 @@ static void fn_param_fl(const char *file, int line, const char *param,
> struct strbuf scope_payload = STRBUF_INIT;
> enum config_scope scope = kvi->scope;
> const char *scope_name = config_scope_name(scope);
> -
> - strbuf_addf(&buf_payload, "%s:%s", param, value);
> + strbuf_addstr(&buf_payload, param);
> + if (value)
> + strbuf_addf(&buf_payload, ":%s", value);
I am not versed well enough in tgt-parf output format to tell if
this makes sense. We'd need somebody else to review this part.
Thanks. |
On the Git mailing list, Johannes Schindelin wrote (reply to this): Hi Adam,
On Fri, 10 Jan 2025, Adam Murray via GitGitGadget wrote:
> From: Adam Murray <[email protected]>
>
> When TRACE2 analytics is enabled, a git config option that has no value
> causes a segfault.
>
> Steps to Reproduce
> GIT_TRACE2=true GIT_TRACE2_CONFIG_PARAMS=status.*
> git -c status.relativePaths version
> Expected Result
> git version 2.46.0
> Actual Result
> zsh: segmentation fault GIT_TRACE2=true
>
> This adds checks to prevent the segfault and instead return
> an empty value.
>
> Signed-off-by: Adam Murray <[email protected]>
This patch looks good to me!
Thank you for the fix,
Johannes
> ---
> trace2: prevent segfault on config collection where no value specified
>
> cc: Jeff King [email protected]
>
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1814%2Fad-murray%2Ffix-trace2-segfault-v2
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1814/ad-murray/fix-trace2-segfault-v2
> Pull-Request: https://github.com/gitgitgadget/git/pull/1814
>
> Range-diff vs v1:
>
> 1: 24ba9db7aa1 ! 1: fd7bed52dda trace2: prevent segfault on config collection where no value specified
> @@ Commit message
> Actual Result
> zsh: segmentation fault GIT_TRACE2=true
>
> - This adds a null check to prevent the segfault and instead return
> - the "empty config value" error.
> + This adds checks to prevent the segfault and instead return
> + an empty value.
>
> Signed-off-by: Adam Murray <[email protected]>
>
> @@ t/t0210-trace2-normal.sh: test_expect_success 'bug messages followed by BUG() ar
>
> ## trace2.c ##
> @@ trace2.c: void trace2_def_param_fl(const char *file, int line, const char *param,
> - int j;
> - const char *redacted;
> -
> -- if (!trace2_enabled)
> -+ if (!trace2_enabled || !value)
> + if (!trace2_enabled)
> return;
>
> - redacted = redact_arg(value);
> +- redacted = redact_arg(value);
> ++ redacted = value ? redact_arg(value): NULL;
> +
> + for_each_wanted_builtin (j, tgt_j)
> + if (tgt_j->pfn_param_fl)
> +
> + ## trace2/tr2_tgt_event.c ##
> +@@ trace2/tr2_tgt_event.c: static void fn_param_fl(const char *file, int line, const char *param,
> + event_fmt_prepare(event_name, file, line, NULL, &jw);
> + jw_object_string(&jw, "scope", scope_name);
> + jw_object_string(&jw, "param", param);
> +- jw_object_string(&jw, "value", value);
> ++ if (value)
> ++ jw_object_string(&jw, "value", value);
> + jw_end(&jw);
> +
> + tr2_dst_write_line(&tr2dst_event, &jw.json);
> +
> + ## trace2/tr2_tgt_normal.c ##
> +@@ trace2/tr2_tgt_normal.c: 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);
> + normal_io_write_fl(file, line, &buf_payload);
> + strbuf_release(&buf_payload);
> + }
> +
> + ## trace2/tr2_tgt_perf.c ##
> +@@ trace2/tr2_tgt_perf.c: static void fn_param_fl(const char *file, int line, const char *param,
> + struct strbuf scope_payload = STRBUF_INIT;
> + enum config_scope scope = kvi->scope;
> + const char *scope_name = config_scope_name(scope);
> +-
> +- strbuf_addf(&buf_payload, "%s:%s", param, value);
> ++ strbuf_addstr(&buf_payload, param);
> ++ if (value)
> ++ strbuf_addf(&buf_payload, ":%s", value);
> + strbuf_addf(&scope_payload, "%s:%s", "scope", scope_name);
> +
> + perf_io_write_fl(file, line, event_name, NULL, NULL, NULL,
>
>
> t/t0210-trace2-normal.sh | 8 ++++++++
> trace2.c | 2 +-
> trace2/tr2_tgt_event.c | 3 ++-
> trace2/tr2_tgt_normal.c | 5 +++--
> trace2/tr2_tgt_perf.c | 5 +++--
> 5 files changed, 17 insertions(+), 6 deletions(-)
>
> diff --git a/t/t0210-trace2-normal.sh b/t/t0210-trace2-normal.sh
> index b9adc94aab4..4047ab562a4 100755
> --- a/t/t0210-trace2-normal.sh
> +++ b/t/t0210-trace2-normal.sh
> @@ -244,6 +244,14 @@ test_expect_success 'bug messages followed by BUG() are written to trace2' '
> test_cmp expect actual
> '
>
> +test_expect_success 'empty configuration values are handled' '
> + test_when_finished "rm trace2.normal actual expect" &&
> + echo >expect &&
> + GIT_TRACE2="$(pwd)/trace2.normal" GIT_TRACE2_CONFIG_PARAMS=foo.empty \
> + git -c foo.empty config foo.empty >actual &&
> + test_cmp expect actual
> +'
> +
> sane_unset GIT_TRACE2_BRIEF
>
> # Now test without environment variables and get all Trace2 settings
> diff --git a/trace2.c b/trace2.c
> index f894532d053..49e7d1db88f 100644
> --- a/trace2.c
> +++ b/trace2.c
> @@ -762,7 +762,7 @@ void trace2_def_param_fl(const char *file, int line, const char *param,
> if (!trace2_enabled)
> return;
>
> - redacted = redact_arg(value);
> + redacted = value ? redact_arg(value): NULL;
>
> for_each_wanted_builtin (j, tgt_j)
> if (tgt_j->pfn_param_fl)
> diff --git a/trace2/tr2_tgt_event.c b/trace2/tr2_tgt_event.c
> index 45b0850a5ec..8e09485c83c 100644
> --- a/trace2/tr2_tgt_event.c
> +++ b/trace2/tr2_tgt_event.c
> @@ -491,7 +491,8 @@ static void fn_param_fl(const char *file, int line, const char *param,
> event_fmt_prepare(event_name, file, line, NULL, &jw);
> jw_object_string(&jw, "scope", scope_name);
> jw_object_string(&jw, "param", param);
> - jw_object_string(&jw, "value", value);
> + if (value)
> + jw_object_string(&jw, "value", value);
> jw_end(&jw);
>
> tr2_dst_write_line(&tr2dst_event, &jw.json);
> diff --git a/trace2/tr2_tgt_normal.c b/trace2/tr2_tgt_normal.c
> index baef48aa698..924736ab360 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);
> normal_io_write_fl(file, line, &buf_payload);
> strbuf_release(&buf_payload);
> }
> diff --git a/trace2/tr2_tgt_perf.c b/trace2/tr2_tgt_perf.c
> index a6f9a8a193e..19ae7433ef8 100644
> --- a/trace2/tr2_tgt_perf.c
> +++ b/trace2/tr2_tgt_perf.c
> @@ -446,8 +446,9 @@ static void fn_param_fl(const char *file, int line, const char *param,
> struct strbuf scope_payload = STRBUF_INIT;
> enum config_scope scope = kvi->scope;
> const char *scope_name = config_scope_name(scope);
> -
> - strbuf_addf(&buf_payload, "%s:%s", param, value);
> + strbuf_addstr(&buf_payload, param);
> + if (value)
> + strbuf_addf(&buf_payload, ":%s", value);
> strbuf_addf(&scope_payload, "%s:%s", "scope", scope_name);
>
> perf_io_write_fl(file, line, event_name, NULL, NULL, NULL,
>
> base-commit: 8f8d6eee531b3fa1a8ef14f169b0cb5035f7a772
> --
> gitgitgadget
>
> |
User |
On the Git mailing list, Junio C Hamano wrote (reply to this): Johannes Schindelin <[email protected]> writes:
>
> This patch looks good to me!
Thanks. As I punted on reviewing the tgt_perf part, it is very good
to see somebody else step in to look it over.
Will queue.
>> diff --git a/trace2/tr2_tgt_perf.c b/trace2/tr2_tgt_perf.c
>> index a6f9a8a193e..19ae7433ef8 100644
>> --- a/trace2/tr2_tgt_perf.c
>> +++ b/trace2/tr2_tgt_perf.c
>> @@ -446,8 +446,9 @@ static void fn_param_fl(const char *file, int line, const char *param,
>> struct strbuf scope_payload = STRBUF_INIT;
>> enum config_scope scope = kvi->scope;
>> const char *scope_name = config_scope_name(scope);
>> -
>> - strbuf_addf(&buf_payload, "%s:%s", param, value);
>> + strbuf_addstr(&buf_payload, param);
>> + if (value)
>> + strbuf_addf(&buf_payload, ":%s", value);
>> strbuf_addf(&scope_payload, "%s:%s", "scope", scope_name);
>>
>> perf_io_write_fl(file, line, event_name, NULL, NULL, NULL,
>>
>> base-commit: 8f8d6eee531b3fa1a8ef14f169b0cb5035f7a772
>> --
>> gitgitgadget
>>
>> |
On the Git mailing list, Junio C Hamano wrote (reply to this): Junio C Hamano <[email protected]> writes:
> Johannes Schindelin <[email protected]> writes:
>
>>
>> This patch looks good to me!
>
> Thanks. As I punted on reviewing the tgt_perf part, it is very good
> to see somebody else step in to look it over.
>
> Will queue.
The test part used broken indentation and also the use of
test_when_finished was careless, so I'll touch it up before queuing.
No need to resend.
Thanks. |
This patch series was integrated into seen via git@29e775a. |
On the Git mailing list, "D. Ben Knoble" wrote (reply to this): On Wed, Jan 22, 2025 at 1:18 PM Junio C Hamano <[email protected]> wrote:
>
> Junio C Hamano <[email protected]> writes:
>
> > Johannes Schindelin <[email protected]> writes:
> >
> >>
> >> This patch looks good to me!
> >
> > Thanks. As I punted on reviewing the tgt_perf part, it is very good
> > to see somebody else step in to look it over.
> >
> > Will queue.
>
> The test part used broken indentation and also the use of
> test_when_finished was careless, so I'll touch it up before queuing.
>
> No need to resend.
>
> Thanks.
>
I was curious what changed, so I found 792a3850fa (trace2: prevent
segfault on config collection with valueless true, 2025-01-10) and I
noticed this:
- redacted = redact_arg(value);
+ redacted = value ? redact_arg(value): NULL;
I think I expected (based on Documentation/CodingGuidelines) a space
before the ternary conditional's colon. Then again, "git grep '?.*[^
]:' *.[ch]" finds a few other cases with the unspaced style.
--
D. Ben Knoble |
User |
On the Git mailing list, Junio C Hamano wrote (reply to this): "D. Ben Knoble" <[email protected]> writes:
> I was curious what changed, so I found 792a3850fa (trace2: prevent
> segfault on config collection with valueless true, 2025-01-10) and I
> noticed this:
>
> - redacted = redact_arg(value);
> + redacted = value ? redact_arg(value): NULL;
Oh, I do not think I tweaked any of the code, other than fixing the
new test that was not properly formatted. Mostly I touched up the
log message.
Will touch it up. Thanks for a careful reading. |
On the Git mailing list, "D. Ben Knoble" wrote (reply to this): On Thu, Jan 23, 2025 at 1:02 PM Junio C Hamano <[email protected]> wrote:
>
> "D. Ben Knoble" <[email protected]> writes:
>
> > I was curious what changed, so I found 792a3850fa (trace2: prevent
> > segfault on config collection with valueless true, 2025-01-10) and I
> > noticed this:
> >
> > - redacted = redact_arg(value);
> > + redacted = value ? redact_arg(value): NULL;
>
> Oh, I do not think I tweaked any of the code, other than fixing the
> new test that was not properly formatted. Mostly I touched up the
> log message.
I could have been clearer—I think this was in the original. I just
happened to notice it because I was curious about what touch-ups you
performed :)
--
D. Ben Knoble |
This patch series was integrated into seen via git@4530787. |
This patch series was integrated into next via git@7dc4bda. |
This branch is now known as |
This patch series was integrated into seen via git@91c0577. |
cc: Jeff King [email protected]
cc: Johannes Schindelin [email protected]
cc: "D. Ben Knoble" [email protected]