From: "xuyang2018.jy@fujitsu.com" <xuyang2018.jy@fujitsu.com>
To: "morgan@kernel.org" <morgan@kernel.org>
Cc: "xuyang2018.jy@fujitsu.com" <xuyang2018.jy@fujitsu.com>,
Florian Weimer <fweimer@redhat.com>,
Theodore Ts'o <tytso@mit.edu>,
"fstests@vger.kernel.org" <fstests@vger.kernel.org>,
"libc-alpha@sourceware.org" <libc-alpha@sourceware.org>
Subject: Re: [PATCH] src/ext4_resize.c: set errno to 0 before the strtoull call
Date: Wed, 19 Jan 2022 07:19:48 +0000 [thread overview]
Message-ID: <61E7BBD6.3010706@fujitsu.com> (raw)
In-Reply-To: <61E7AC82.8080801@fujitsu.com>
Hi Andrew
errno doesn't be initialized to 0 when c program link with lcap since
libcap-2.30 (commit f1f62a748d7c Refactor the way we do the psx linkage
in libcap introduced this bug.)
The c example code as below:
-------------------------------------------
#include <stdio.h>
#include <errno.h>
int main(int argc, char **argv)
{
printf("errno %d\n", errno);
return 0;
}
---------------------------------------
#gcc test.c -lcap -o test
#./test
errno 1
Best Regards
Yang Xu
> on 2022/1/18 22:02, Florian Weimer wrote:
>> * xuyang2018.jy:
>>
>>> 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
>>
>> I'm not aware of this issue. Could you run strace or strace -k to see
>> where the failing system call is coming from? Thanks.
> Even before open call, errno is also 1.
>
> The strace output see attachment.
>
> I found the following difference(compare with glibc-2.28, search 'err'
> keywords)
>
> bad(glibc-2.34):
>
> map(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
> = 0x7fdf815a3000
> > /usr/lib64/ld-linux-x86-64.so.2(__mmap+0x26) [0x21c56]
> > /usr/lib64/ld-linux-x86-64.so.2(rtld_malloc+0xa0) [0x1dc50]
> > /usr/lib64/ld-linux-x86-64.so.2(_dl_check_map_versions+0x4ec) [0x121fc]
> > /usr/lib64/ld-linux-x86-64.so.2(_dl_check_all_versions+0x3e) [0x124de]
> > /usr/lib64/ld-linux-x86-64.so.2(version_check_doit+0x1b) [0x1cab]
> > /usr/lib64/ld-linux-x86-64.so.2(_dl_receive_error+0x31) [0x1e811]
> > /usr/lib64/ld-linux-x86-64.so.2(dl_main+0x1e46) [0x4416]
> > /usr/lib64/ld-linux-x86-64.so.2(_dl_sysdep_start+0x3f6) [0x1d696]
> > /usr/lib64/ld-linux-x86-64.so.2(_dl_start+0x217) [0x2097]
> > /usr/lib64/ld-linux-x86-64.so.2(_start+0x7) [0x1097]
> > no matching address range
> arch_prctl(ARCH_SET_FS, 0x7fdf815a4480) = 0
>
> good(glibc-2.28):
>
> map(NULL, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
> = 0x7febd628b000
> > /usr/lib64/ld-2.28.so(__mmap+0x47) [0x1c377]
> > /usr/lib64/ld-2.28.so(malloc+0x8a) [0x1a94a]
> > /usr/lib64/ld-2.28.so(_dl_allocate_tls_storage+0x23) [0x12ac3]
> > /usr/lib64/ld-2.28.so(init_tls+0xa5) [0x1da5]
> > /usr/lib64/ld-2.28.so(dl_main+0x2c6d) [0x51ed]
> > /usr/lib64/ld-2.28.so(_dl_sysdep_start+0x48e) [0x1a14e]
> > /usr/lib64/ld-2.28.so(_dl_start+0x275) [0x2135]
> > /usr/lib64/ld-2.28.so(_start+0x7) [0x1087]
> > No DWARF information found
> arch_prctl(ARCH_SET_FS, 0x7febd628b740) = 0
>
> Also if use gcc to compile this c program directly instead of using make
> in xfstests testsuite, the errno value is normal(0).
>
> After tried, I found if using the following command, errno is still 0
> gcc ext4_resize.c -g -O2 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
> -funsigned-char -fno-strict-aliasing -Wall -o ext4_resize
>
> But if I used link with lcap, then errno becomes 1 in the beginning.
>
> Even I use lastest upstream libcap, this problem still occurs.
>
> I am still looking into it .
>
> Best Regards
> Yang Xu
>
>>
>> Florian
>>
>
next prev parent reply other threads:[~2022-01-19 7:19 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1642405014-3287-1-git-send-email-xuyang2018.jy@fujitsu.com>
[not found] ` <YeYmzJG5M0y9BcMc@mit.edu>
[not found] ` <61E6298D.80006@fujitsu.com>
[not found] ` <YeY6Uh8I7RlsCicw@mit.edu>
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
2022-01-18 12:04 ` Andreas Schwab
2022-01-18 12:26 ` Adhemerval Zanella
2022-01-18 14:02 ` Florian Weimer
2022-01-19 6:14 ` xuyang2018.jy
2022-01-19 7:19 ` xuyang2018.jy [this message]
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-18 14:43 ` Yann Droneaud
2022-01-18 14:54 ` H.J. Lu
2022-01-18 15:30 ` Andreas Schwab
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=61E7BBD6.3010706@fujitsu.com \
--to=xuyang2018.jy@fujitsu.com \
--cc=fstests@vger.kernel.org \
--cc=fweimer@redhat.com \
--cc=libc-alpha@sourceware.org \
--cc=morgan@kernel.org \
--cc=tytso@mit.edu \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).