All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Cc: "xuyang2018.jy@fujitsu.com" <xuyang2018.jy@fujitsu.com>,
	Theodore Ts'o <tytso@mit.edu>,
	"libc-alpha@sourceware.org" <libc-alpha@sourceware.org>,
	"fstests@vger.kernel.org" <fstests@vger.kernel.org>
Subject: Re: [PATCH] src/ext4_resize.c: set errno to 0 before the strtoull call
Date: Tue, 18 Jan 2022 13:00:20 +0100	[thread overview]
Message-ID: <87h7a1jlt7.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <496a3521-5a0c-b3ae-29bb-02fd0056525b@linaro.org> (Adhemerval Zanella's message of "Tue, 18 Jan 2022 08:49:40 -0300")

* Adhemerval Zanella:

> On 18/01/2022 08:26, Florian Weimer wrote:
>> * Adhemerval Zanella:
>> 
>>>   
>>>
>>> On 18/01/2022 02:27, xuyang2018.jy--- via Libc-alpha wrote:
>>>> on 2022/1/18 11:56, Theodore Ts'o wrote:
>>>>> On Tue, Jan 18, 2022 at 02:43:26AM +0000, xuyang2018.jy@fujitsu.com wrote:
>>>>>>> You're right of course, but out of curiosity, which C library are you
>>>>>>> using?
>>>>>> I use glibc-2.34.
>>>>>
>>>>> Hmm, ok.  I'm using glibc 2.31, and in this particular program, errno
>>>>> shouldn't have been set by any prior system call.  I'm guessing maybe
>>>>> it was something in crt0 which ended up setting errno?
>>>> It maybe a glibc bug.
>>>> I cc glibc mailing list and see whether they have met this problem.
>>>>
>>>> @Florian
>>>>
>>>> Now, I use glibc-2.34 and run the following program[1] but the errno is 
>>>> not 0 in the beginning. So is this a known bug on glibc-2.34(Theodore 
>>>> doesn't meet this problem on glicb-2.31)?
>>>>
>>>> [1]https://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git/tree/src/ext4_resize.c
>>>
>>> The errno should be only set on a failure, no function shall set errno
>>> to 0 (it is a POSIX definition which glibc adheres).  The application
>>> need to explicitly set errno to 0 before the function call to check if 
>>> an error occurs.
>> 
>> While this is true, I think errno should still be 0 at the start of the
>> program.
>
> I think this is a implementation detail, I am not aware that either C or
> POSIX now states it should initialized to any specific value (in fact, 
> POSIX at Issue 5 [1] has removed the 'The value of errno is 0 at program 
> start-up' on its description).

It would be nice to stay compatible with that.

> In any case, we set errno to be an uninitialized TLS variable.  Unless we
> have a bug on .tbss initialization I think the issue is somewhere else.

I suspect it's some additional system call, which is why I requested
strace output.

Thanks,
Florian


  reply	other threads:[~2022-01-18 12:00 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-17  7:36 [PATCH] src/ext4_resize.c: set errno to 0 before the strtoull call Yang Xu
2022-01-17 17:07 ` Darrick J. Wong
2022-01-18  2:32 ` Theodore Ts'o
2022-01-18  2:43   ` xuyang2018.jy
2022-01-18  3:56     ` Theodore Ts'o
2022-01-18  5:27       ` xuyang2018.jy
2022-01-18 11:23         ` Adhemerval Zanella
2022-01-18 11:26           ` Florian Weimer
2022-01-18 11:49             ` Adhemerval Zanella
2022-01-18 12:00               ` Florian Weimer [this message]
2022-01-18 12:04               ` Andreas Schwab
2022-01-18 12:26                 ` Adhemerval Zanella
2022-01-18 14:02         ` Florian Weimer
     [not found]           ` <61E7AC82.8080801@fujitsu.com>
2022-01-19  7:19             ` xuyang2018.jy
2022-01-19 13:57               ` Cristian Rodríguez
2022-01-19 14:07                 ` Cristian Rodríguez
2022-01-19 14:50                   ` Andrew G. Morgan
2022-01-19 20:13                     ` Theodore Ts'o
2022-01-18 14:22         ` Andreas Schwab
2022-01-18 14:29           ` H.J. Lu
2022-01-19  2:07           ` xuyang2018.jy
2022-01-19  8:23             ` Andreas Schwab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h7a1jlt7.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=fstests@vger.kernel.org \
    --cc=libc-alpha@sourceware.org \
    --cc=tytso@mit.edu \
    --cc=xuyang2018.jy@fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.