public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Paul Wise via Libc-help <libc-help@sourceware.org>
Cc: Paul Wise <pabs3@bonedaddy.net>
Subject: Re: is this a bug in glibc or readpst?
Date: Mon, 07 Aug 2023 10:59:55 +0200	[thread overview]
Message-ID: <874jlbi5x0.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <e4f6ce4730ee14445d67f0699aae180a227d766a.camel@bonedaddy.net> (Paul Wise via Libc-help's message of "Sun, 06 Aug 2023 14:07:09 +0800")

* Paul Wise via Libc-help:

> Looking at the stack traces, the _IO_SYNC call introduced in the commit
> 0b727ed4d that I identified as triggering the readpst bug is definitely
> the source of the lseek call.
>
>    lseek(3, -2138, SEEK_CUR)               = 268198
>     > /lib/x86_64-linux-gnu/libc.so.6(lseek64+0x7) [0xf81b7]
>     > /lib/x86_64-linux-gnu/libc.so.6(_IO_file_sync+0x7e) [0x800ae]
>     > /lib/x86_64-linux-gnu/libc.so.6(freopen+0x8c) [0x7d95c]
>     > /usr/bin/readpst(pst_reopen+0x36) [0x102c6]
>     > /usr/bin/readpst(try_fork+0x88) [0x4398]
>     > /usr/bin/readpst(process+0x121) [0xa451]
>     > /usr/bin/readpst(main+0x555) [0x3cc5]
>     > /lib/x86_64-linux-gnu/libc.so.6(__libc_init_first+0x8a) [0x271ca]
>     > /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x85) [0x27285]
>     > /usr/bin/readpst(_start+0x21) [0x4061]
>
> Based on the same thing happening with fflush+fclose+fopen, I'm not
> entirely sure, but I think that this represents a POSIX compliance bug
> in readpst that was papered over by the earlier behaviour of glibc.

We could perhaps avoid the seek for read-only streams.  We are about to
close the stream anyway, so fflush does not have any useful effect
anyway.  Not sure what others think if it is worth the complexity.  On
the other hand, preserving backwards compatibility here does not appear
to be too onerous.

Thanks,
Florian


  reply	other threads:[~2023-08-07  9:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-23  2:02 Paul Wise
2022-11-23  8:57 ` Florian Weimer
2022-11-24  0:06   ` Paul Wise
2022-12-02 17:37     ` Florian Weimer
2023-08-06  6:07       ` Paul Wise
2023-08-07  8:59         ` Florian Weimer [this message]
2023-08-07 11:00           ` Paul Wise
2023-08-07 11:46             ` Florian Weimer
2023-08-07 11:58               ` Paul Wise

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=874jlbi5x0.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=libc-help@sourceware.org \
    --cc=pabs3@bonedaddy.net \
    /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).