[PATCH] Fix #27777 - now use a doubly-linked list for _IO_list_all

alexandre.ferrieux@orange.com alexandre.ferrieux@orange.com
Fri Apr 26 19:04:25 GMT 2024



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 ?
____________________________________________________________________________________________________________
Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc
pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler
a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration,
Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci.

This message and its attachments may contain confidential or privileged information that may be protected by law;
they should not be distributed, used or copied without authorisation.
If you have received this email in error, please notify the sender and delete this message and its attachments.
As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified.
Thank you.


More information about the Libc-alpha mailing list