From: Florian Weimer <fweimer@redhat.com>
To: alexandre.ferrieux@orange.com
Cc: "H.J. Lu" <hjl.tools@gmail.com>,
libc-alpha@sourceware.org, carlos@redhat.com
Subject: Re: [PATCH] Fix #27777 - now use a doubly-linked list for _IO_list_all
Date: Fri, 26 Apr 2024 21:16:06 +0200 [thread overview]
Message-ID: <87y190ylxl.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <eb0c128a-5c0f-4d28-875f-309c98ec1d9b@orange.com> (alexandre ferrieux's message of "Fri, 26 Apr 2024 21:04:25 +0200")
* alexandre ferrieux:
> On 26/04/2024 20:50, H.J. Lu wrote:
>>
>> On Fri, Apr 26, 2024 at 10:51 AM Florian Weimer <fweimer@redhat.com> wrote:
>>>
>>> * alexandre ferrieux:
>>>
>>> > diff --git a/libio/bits/types/struct_FILE.h b/libio/bits/types/struct_FILE.h
>>> > index 7cdaae86f8..daebd6ce0a 100644
>>> > --- a/libio/bits/types/struct_FILE.h
>>> > +++ b/libio/bits/types/struct_FILE.h
>>> > @@ -67,7 +67,7 @@ struct _IO_FILE
>>> >
>>> > struct _IO_marker *_markers;
>>> >
>>> > - struct _IO_FILE *_chain;
>>> > + struct _IO_FILE *_chain,**_prevchain;
>>> >
>>> > int _fileno;
>>> > int _flags2;
>>>
>>> Unfortunately, this struct is part of the ABI for several reasons. For
>>> example, _IO_2_1_stdin_ is a global variable exported by libc.so.6, and
>>> it has a struct _IO_FILE member. It cannot change size due to copy
>>> relocations, even if nothing accesses members after _chain.
>>>
>>> I disagree with H.J.'s suggestion that the answer is symbol
>>> versions. 8-)
>> libio/bits/types/struct_FILE.h has
>> __off64_t _offset;
>> /* Wide character stream stuff. */
>> struct _IO_codecvt *_codecvt;
>> struct _IO_wide_data *_wide_data;
>> struct _IO_FILE *_freeres_list;
>> void *_freeres_buf;
>> size_t __pad5;
>> int _mode;
>> /* Make sure we don't get into trouble again. */
>> char _unused2[15 * sizeof (int) - 4 * sizeof (void *) - sizeof (size_t)];
>> };
>> We can add a pointer without changing FILE size.
>
> Ha ! That's a clever trick. Presumably someone was already bitten once ;)
> (Sorry I didn't notice it was present in your corrected patch).
>
> Now, I still have worries about the symbol versioning approach: why
> restrict the version bump to _IO_un_link and _IO_link_in ? Indeed, any
> program calling fclose() ends up calling _IO_un_link(), so the
> version check should apply too, right ? So shouldn't we tag all
> functions using (FILE *) in their arguments or return value ?
No new symbol versions should be needed. You just need to be careful
not to access that part of the struct when it does not exist.
I think the way to check for old-style streams is via _IO_vtable_offset,
as can be seen at the start of the __fgetln function in an (unmerged)
patch I submitted a while back:
[PATCH] stdio-common: Add the fgetln function
<https://inbox.sourceware.org/libc-alpha/871qxbxe2i.fsf@oldenburg.str.redhat.com/>
In your case, you would have to do the full traversal once you encounter
a missing backlink. But that would only happen if old-style file
handles are actually used. Maybe this is even easier to implement than
the hash table or index approach.
Thanks,
Florian
next prev parent reply other threads:[~2024-04-26 19:16 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-26 14:18 [PATCH] Fix #27777 - now use a doubly-linked list for _IO_list_all alexandre.ferrieux
2024-04-26 14:45 ` H.J. Lu
[not found] ` <ffa6e29b-3a7b-4be6-a0d2-327510a7094d@orange.com>
2024-04-26 15:05 ` H.J. Lu
2024-04-26 15:12 ` H.J. Lu
[not found] ` <84cbc4a9-2ddf-45f3-94be-132441db5c8a@orange.com>
2024-04-26 15:16 ` H.J. Lu
[not found] ` <7fa02e06-42b1-463b-a7c4-66600d524186@orange.com>
2024-04-26 16:08 ` H.J. Lu
[not found] ` <5fad7b2e-43a4-4e57-bd10-a9ce1ce38006@orange.com>
2024-04-26 16:24 ` H.J. Lu
2024-04-26 17:51 ` Florian Weimer
2024-04-26 18:20 ` alexandre.ferrieux
2024-04-26 18:44 ` alexandre.ferrieux
2024-04-26 19:08 ` Florian Weimer
2024-04-26 19:08 ` Florian Weimer
2024-04-26 18:50 ` H.J. Lu
2024-04-26 19:04 ` alexandre.ferrieux
2024-04-26 19:16 ` Florian Weimer [this message]
2024-04-26 20:15 ` alexandre.ferrieux
2024-04-29 13:20 ` Florian Weimer
2024-04-29 19:05 ` alexandre.ferrieux
2024-04-30 2:47 ` H.J. Lu
2024-04-30 17:22 ` H.J. Lu
2024-04-26 19:09 ` Florian Weimer
-- strict thread matches above, loose matches on Subject: below --
2024-04-30 17:20 H.J. Lu
2024-04-30 18:00 ` alexandre.ferrieux
2024-04-30 18:11 ` H.J. Lu
2024-04-30 19:37 ` H.J. Lu
2024-04-30 19:52 ` alexandre.ferrieux
2024-04-30 20:02 ` H.J. Lu
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
List information: https://www.gnu.org/software/libc/involved.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y190ylxl.fsf@oldenburg.str.redhat.com \
--to=fweimer@redhat.com \
--cc=alexandre.ferrieux@orange.com \
--cc=carlos@redhat.com \
--cc=hjl.tools@gmail.com \
--cc=libc-alpha@sourceware.org \
/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).