public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/110574] New: --enable-cstdio=stdio_pure is incompatible with LFS
Date: Thu, 06 Jul 2023 15:11:59 +0000	[thread overview]
Message-ID: <bug-110574-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110574

            Bug ID: 110574
           Summary: --enable-cstdio=stdio_pure is incompatible with LFS
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
                CC: keithp at keithp dot com
  Target Milestone: ---

Using --enable-cstdio=stdio_pure on x86_64-pc-linux-gnu results in test
failures:

FAIL: 27_io/basic_filebuf/imbue/char/13171-2.cc execution test
FAIL: 27_io/basic_filebuf/seekoff/12790-3.cc execution test
FAIL: 27_io/basic_filebuf/seekoff/45628-2.cc execution test
FAIL: 27_io/basic_filebuf/seekoff/char/1-in.cc execution test
FAIL: 27_io/basic_filebuf/seekoff/char/1-io.cc execution test
FAIL: 27_io/basic_filebuf/seekoff/char/1-out.cc execution test
FAIL: 27_io/basic_filebuf/seekoff/char/2-in.cc execution test
FAIL: 27_io/basic_filebuf/seekoff/char/2-io.cc execution test
FAIL: 27_io/basic_filebuf/seekoff/char/2-out.cc execution test
FAIL: 27_io/basic_filebuf/seekoff/char/26777.cc execution test
FAIL: 27_io/basic_filebuf/seekoff/char/4.cc execution test
FAIL: 27_io/basic_filebuf/seekoff/wchar_t/4.cc execution test
FAIL: 27_io/basic_filebuf/seekpos/12790-2.cc execution test
FAIL: 27_io/basic_filebuf/seekpos/12790-3.cc execution test
FAIL: 27_io/basic_filebuf/seekpos/char/1-in.cc execution test
FAIL: 27_io/basic_filebuf/seekpos/char/1-io.cc execution test
FAIL: 27_io/basic_filebuf/seekpos/char/1-out.cc execution test
FAIL: 27_io/basic_filebuf/seekpos/char/2-in.cc execution test
FAIL: 27_io/basic_filebuf/seekpos/char/2-io.cc execution test
FAIL: 27_io/basic_filebuf/seekpos/char/2-out.cc execution test
FAIL: 27_io/basic_filebuf/seekpos/wchar_t/9874.cc execution test
FAIL: 27_io/basic_filebuf/seekpos/wchar_t/9875_seekpos.cc execution test
FAIL: 27_io/basic_filebuf/sgetn/char/2-in.cc execution test
FAIL: 27_io/basic_filebuf/sgetn/char/2-io.cc execution test
FAIL: 27_io/basic_filebuf/sputbackc/char/1-io.cc execution test
FAIL: 27_io/basic_filebuf/sputbackc/char/2-io.cc execution test
FAIL: 27_io/basic_filebuf/sungetc/char/1-io.cc execution test
FAIL: 27_io/basic_filebuf/sungetc/char/2-io.cc execution test
FAIL: 27_io/basic_filebuf/underflow/char/10097.cc execution test
FAIL: 27_io/basic_filebuf/underflow/wchar_t/5.cc execution test
FAIL: 27_io/basic_fstream/53984.cc execution test
FAIL: 27_io/basic_istream/peek/char/6414.cc execution test
FAIL: 27_io/basic_istream/peek/wchar_t/6414.cc execution test
FAIL: 27_io/basic_istream/seekg/char/fstream.cc execution test
FAIL: 27_io/basic_istream/seekg/wchar_t/fstream.cc execution test
FAIL: 27_io/basic_istream/tellg/char/fstream.cc execution test
FAIL: 27_io/basic_istream/tellg/wchar_t/fstream.cc execution test
FAIL: 27_io/objects/wchar_t/12.cc execution test

This seems to be because of code like:

  streamoff
  __basic_file<char>::seekoff(streamoff __off, ios_base::seekdir __way) throw
()
  {
#ifdef _GLIBCXX_USE_LFS
    return lseek64(this->fd(), __off, __way);
#else
    if (__off > numeric_limits<off_t>::max()
        || __off < numeric_limits<off_t>::min())
      return -1L;
#ifdef _GLIBCXX_USE_STDIO_PURE
    return fseek(this->file(), __off, __way);
#else
    return lseek(this->fd(), __off, __way);
#endif
#endif

If LFS is being used then the STDIO_PURE config is ignored, and we use lseek64
on the file descriptor unconditionally. Then when we read we do respect the
STDIO_PURE config:

  streamsize
  __basic_file<char>::xsgetn(char* __s, streamsize __n)
  {
    streamsize __ret;
    do
#ifdef _GLIBCXX_USE_STDIO_PURE
      __ret = fread(__s, 1, __n, this->file());
#else
      __ret = read(this->fd(), __s, __n);
#endif
    while (__ret == -1L && errno == EINTR);
    return __ret;
  }

But now we're seeking on the file descriptor and reading from the FILE. We need
to use fseek before fread.

             reply	other threads:[~2023-07-06 15:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-06 15:11 redi at gcc dot gnu.org [this message]
2023-07-06 15:28 ` [Bug libstdc++/110574] " cvs-commit at gcc dot gnu.org
2023-07-06 15:38 ` redi at gcc dot gnu.org
2023-07-06 16:24 ` redi at gcc dot gnu.org
2023-07-06 18:01 ` redi at gcc dot gnu.org
2023-07-07  5:54 ` keithp at keithp dot com
2023-07-12 20:04 ` cvs-commit at gcc dot gnu.org
2023-07-18 11:00 ` cvs-commit at gcc dot gnu.org

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=bug-110574-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.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).