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: Wed, 23 Nov 2022 09:57:32 +0100	[thread overview]
Message-ID: <875yf6nj43.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <2cefc4fa95dd439c2581f4f06d520c004cd33708.camel@bonedaddy.net> (Paul Wise via Libc-help's message of "Wed, 23 Nov 2022 10:02:57 +0800")

* Paul Wise via Libc-help:

> readpst from Debian buster in multi-process mode works but readpst from
> Debian bullseye randomly loses some data. Current readpst works on
> Debian buster but not Debian bullseye. The problem isn't related to the
> GCC optimisation level. The problem isn't compiler related, clang
> exhibits the problem too. Upgrading libc6 from 2.28-10 to 2.29-1 caused
> the issue. Bisecting glibc pointed at commit 0b727ed4d, which is titled
> "libio: Flush stream at freopen (BZ#21037)" and looks legitimate as it
> aligns glibc freopen with POSIX specifications. readpst is using
> freopen() after fork() to get new *.pst FILE pointers for child
> processes. Both the parent and child FILE are opened read-only. The
> FILE position is 0 after freopen for both scenarios. readpst seems to
> be skipping some PST file blocks in the broken scenario. The debug logs
> seem to indicate that in the broken scenario it reads data from a wrong
> location, even though the file position is 0 after freopen. Switching
> the readpst code to use fclose()+fopen() after fork() instead of
> freopen() after fork() fixes the issue.

Fork still shares the underlying file description.  It only duplicates
the descriptors.  If the subprocess changes the file pointer back to 0,
it will affect the original process, too.  This is just how file
descriptors work.

Could this explain the issue?

Thanks,
Florian


  reply	other threads:[~2022-11-23  8:57 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 [this message]
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
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=875yf6nj43.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).