Skip to content
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

refs: print errno for read_raw_ref if GIT_TRACE_REFS is set #1002

Closed
wants to merge 1 commit into from

Conversation

hanwen
Copy link
Contributor

@hanwen hanwen commented Apr 12, 2021

The ref backend API uses errno as a sideband error channel.

Signed-off-by: Han-Wen Nienhuys hanwen@google.com
cc: Han-Wen Nienhuys hanwen@google.com

@hanwen
Copy link
Contributor Author

hanwen commented Apr 12, 2021

/submit

@gitgitgadget-git
Copy link

Submitted as pull.1002.git.git.1618255954484.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git pr-git-1002/hanwen/errno-debug-v1

To fetch this version to local tag pr-git-1002/hanwen/errno-debug-v1:

git fetch --no-tags https://github.com/gitgitgadget/git tag pr-git-1002/hanwen/errno-debug-v1

@gitgitgadget-git
Copy link

On the Git mailing list, Junio C Hamano wrote (reply to this):

"Han-Wen Nienhuys via GitGitGadget" <gitgitgadget@gmail.com> writes:

> diff --git a/refs/debug.c b/refs/debug.c
> index 922e64fa6ad9..576bf98e74ae 100644
> --- a/refs/debug.c
> +++ b/refs/debug.c
> @@ -244,6 +244,7 @@ static int debug_read_raw_ref(struct ref_store *ref_store, const char *refname,
>  	int res = 0;
>  
>  	oidcpy(oid, &null_oid);
> +	errno = 0;
>  	res = drefs->refs->be->read_raw_ref(drefs->refs, refname, oid, referent,
>  					    type);
>  
> @@ -251,7 +252,9 @@ static int debug_read_raw_ref(struct ref_store *ref_store, const char *refname,
>  		trace_printf_key(&trace_refs, "read_raw_ref: %s: %s (=> %s) type %x: %d\n",
>  			refname, oid_to_hex(oid), referent->buf, *type, res);
>  	} else {
> -		trace_printf_key(&trace_refs, "read_raw_ref: %s: %d\n", refname, res);
> +		trace_printf_key(&trace_refs,
> +				 "read_raw_ref: %s: %d (errno %d)\n", refname,
> +				 res, errno);
>  	}

OK.  Between trace_printf_key() and the return of the call to
read_raw_ref() method of the ref backend is only an "if (res == 0)"
condition and I do not see anything that might clobber errno.

I do wonder if we want strerror(errno) instead of the number, but I
can go either way (it's just a trace output).

Thanks, will queue.

@gitgitgadget-git
Copy link

This branch is now known as hn/refs-trace-errno.

@gitgitgadget-git
Copy link

This patch series was integrated into seen via bde274a.

@gitgitgadget-git
Copy link

There was a status update in the "New Topics" section about the branch hn/refs-trace-errno on the Git mailing list:

Show errno in the trace output in the error codepath that calls
read_raw_ref method.

Waiting for reviews to conclude.
cf. <xmqq4kgbb2ic.fsf@gitster.g>

The ref backend API uses errno as a sideband error channel.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
@gitgitgadget-git
Copy link

On the Git mailing list, Han-Wen Nienhuys wrote (reply to this):

On Mon, Apr 12, 2021 at 11:45 PM Junio C Hamano <gitster@pobox.com> wrote:
> > @@ -251,7 +252,9 @@ static int debug_read_raw_ref(struct ref_store *ref_store, const char *refname,
> >               trace_printf_key(&trace_refs, "read_raw_ref: %s: %s (=> %s) type %x: %d\n",
> >                       refname, oid_to_hex(oid), referent->buf, *type, res);
> >       } else {
> > -             trace_printf_key(&trace_refs, "read_raw_ref: %s: %d\n", refname, res);
> > +             trace_printf_key(&trace_refs,
> > +                              "read_raw_ref: %s: %d (errno %d)\n", refname,
> > +                              res, errno);
> >       }
>
> OK.  Between trace_printf_key() and the return of the call to
> read_raw_ref() method of the ref backend is only an "if (res == 0)"
> condition and I do not see anything that might clobber errno.

I don't want to bet on that. Let me send a second round.

> I do wonder if we want strerror(errno) instead of the number, but I
> can go either way (it's just a trace output).

For tracing, it would be most useful if we got the actual symbol (eg.
ENOENT). Is there a way to get at that?


-- 
Han-Wen Nienhuys - Google Munich
I work 80%. Don't expect answers from me on Fridays.
--

Google Germany GmbH, Erika-Mann-Strasse 33, 80636 Munich

Registergericht und -nummer: Hamburg, HRB 86891

Sitz der Gesellschaft: Hamburg

Geschäftsführer: Paul Manicle, Halimah DeLaine Prado

@gitgitgadget-git
Copy link

User Han-Wen Nienhuys <hanwen@google.com> has been added to the cc: list.

@hanwen
Copy link
Contributor Author

hanwen commented Apr 13, 2021

/submit

@gitgitgadget-git
Copy link

Submitted as pull.1002.v2.git.git.1618315838582.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git pr-git-1002/hanwen/errno-debug-v2

To fetch this version to local tag pr-git-1002/hanwen/errno-debug-v2:

git fetch --no-tags https://github.com/gitgitgadget/git tag pr-git-1002/hanwen/errno-debug-v2

@gitgitgadget-git
Copy link

On the Git mailing list, Han-Wen Nienhuys wrote (reply to this):

On Tue, Apr 13, 2021 at 1:58 PM Han-Wen Nienhuys <hanwen@google.com> wrote:
>
> On Mon, Apr 12, 2021 at 11:45 PM Junio C Hamano <gitster@pobox.com> wrote:
> > > @@ -251,7 +252,9 @@ static int debug_read_raw_ref(struct ref_store *ref_store, const char *refname,
> > >               trace_printf_key(&trace_refs, "read_raw_ref: %s: %s (=> %s) type %x: %d\n",
> > >                       refname, oid_to_hex(oid), referent->buf, *type, res);
> > >       } else {
> > > -             trace_printf_key(&trace_refs, "read_raw_ref: %s: %d\n", refname, res);
> > > +             trace_printf_key(&trace_refs,
> > > +                              "read_raw_ref: %s: %d (errno %d)\n", refname,
> > > +                              res, errno);
> > >       }
> >
> > OK.  Between trace_printf_key() and the return of the call to
> > read_raw_ref() method of the ref backend is only an "if (res == 0)"
> > condition and I do not see anything that might clobber errno.
>
> I don't want to bet on that. Let me send a second round.

oh, ugh.  In email, there are two calls, but one is prefixed with '-'.

Nevertheless, a bit of paranoia doesn't hurt here.

-- 
Han-Wen Nienhuys - Google Munich
I work 80%. Don't expect answers from me on Fridays.
--

Google Germany GmbH, Erika-Mann-Strasse 33, 80636 Munich

Registergericht und -nummer: Hamburg, HRB 86891

Sitz der Gesellschaft: Hamburg

Geschäftsführer: Paul Manicle, Halimah DeLaine Prado

@gitgitgadget-git
Copy link

On the Git mailing list, Junio C Hamano wrote (reply to this):

Han-Wen Nienhuys <hanwen@google.com> writes:

>> I do wonder if we want strerror(errno) instead of the number, but I
>> can go either way (it's just a trace output).
>
> For tracing, it would be most useful if we got the actual symbol (eg.
> ENOENT). Is there a way to get at that?

I do not think there is.

And that is the reason why we see everywhere calls to die_errno(),
error(..., strerror(errno)), etc.

As this is interpolated into trace with untranslated string,
I suspect that strerror() is not a good match, so let's live with %d
for now.

Thanks.


@gitgitgadget-git
Copy link

There was a status update in the "Cooking" section about the branch hn/refs-trace-errno on the Git mailing list:

Show errno in the trace output in the error codepath that calls
read_raw_ref method.

Waiting for reviews to conclude.
cf. <xmqq4kgbb2ic.fsf@gitster.g>

@gitgitgadget-git
Copy link

There was a status update in the "Cooking" section about the branch hn/refs-trace-errno on the Git mailing list:

Show errno in the trace output in the error codepath that calls
read_raw_ref method.

Waiting for reviews to conclude.
cf. <xmqq4kgbb2ic.fsf@gitster.g>

@gitgitgadget-git
Copy link

On the Git mailing list, Han-Wen Nienhuys wrote (reply to this):

On Tue, Apr 13, 2021 at 10:08 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> Han-Wen Nienhuys <hanwen@google.com> writes:
>
> >> I do wonder if we want strerror(errno) instead of the number, but I
> >> can go either way (it's just a trace output).
> >
> > For tracing, it would be most useful if we got the actual symbol (eg.
> > ENOENT). Is there a way to get at that?
>
> I do not think there is.
>
> And that is the reason why we see everywhere calls to die_errno(),
> error(..., strerror(errno)), etc.
>
> As this is interpolated into trace with untranslated string,
> I suspect that strerror() is not a good match, so let's live with %d
> for now.

Great!

This topic is marked as

Waiting for reviews to conclude.
cf. <xmqq4kgbb2ic.fsf@gitster.g>

but I don't know what is left to do. Oversight?

-- 
Han-Wen Nienhuys - Google Munich
I work 80%. Don't expect answers from me on Fridays.
--
Google Germany GmbH, Erika-Mann-Strasse 33, 80636 Munich
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Paul Manicle, Halimah DeLaine Prado

@gitgitgadget-git
Copy link

There was a status update in the "Cooking" section about the branch hn/refs-trace-errno on the Git mailing list:

Show errno in the trace output in the error codepath that calls
read_raw_ref method.

Will merge to 'master'

@gitgitgadget-git
Copy link

There was a status update in the "Graduated to 'master'" section about the branch hn/refs-trace-errno on the Git mailing list:

Show errno in the trace output in the error codepath that calls
read_raw_ref method.

@hanwen
Copy link
Contributor Author

hanwen commented May 19, 2021

in master through merge bf0d4c8

@hanwen hanwen closed this May 19, 2021
@hanwen hanwen deleted the errno-debug branch May 19, 2021 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant