public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Corinna Vinschen <vinschen@redhat.com>
To: Jeff Johnston <jjohnstn@redhat.com>
Cc: Takashi Yano <takashi.yano@nifty.ne.jp>,
	newlib@sourceware.org, Eric Blake <eblake@redhat.com>
Subject: Re: fprintf() crashes on wide-oriented stream.
Date: Thu, 2 Nov 2023 19:53:51 +0100	[thread overview]
Message-ID: <ZUPwP/d0oqG362/N@calimero.vinschen.de> (raw)
In-Reply-To: <CAOox84tss6dd+=7YbQB2yAVFybk0O4Z4N8mMhcPzXQMPgkh3yw@mail.gmail.com>

Hey guys,

On Oct  4 16:16, Jeff Johnston wrote:
> Hi Takashi,
> 
> I finally took a look at this.  The issue is whether POSIX compliance is
> desired.   Corinna would have
> strong opinions that it is desired and thus, I think she should have her
> say when she gets back.  I personally believe that
> newlib should have behaved like glibc.

I took a look into the POSIX docs.  POSIX aligns with ISO/IEC 9899:1999.
The description is slightly vague, in that it only has to say this:

  "Byte input/output functions cannot be applied to a wide-oriented
   stream, and wide-character input/output functions cannot be applied to
   a byte-oriented stream."

It does not explicitely outline what "cannot be applied" means in this
context.

IIUC, this *could* mean that in case of the testcase a crash is as much
standards-compliant as the GLibC behaviour. Not that a crash is desired,
of course...

In how far the BSD behaviour is covered by this description, I really
can't tell.

I wonder if the Austin group could clarify, or if a clarification
already exists and I just missed it.  CC Eric, in case he wants to
follow up on this.

Either way, I think that the safe way forward is actually to behave
as GLibC does.

> I also think the test snippet is
> invalid and should have performed an fwide call on stdout
> to reset the wide-orientation and have the code work properly in all cases.

In terms of ISO/IEC 9899:1999 I agree. However, it also shows the
flaw that newlib crashes with a buffer overflow, which we should
avoid if possible.

Does that make sense?


Thanks,
Corinna


  parent reply	other threads:[~2023-11-02 18:53 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-26  3:41 Takashi Yano
2023-09-26  8:30 ` Takashi Yano
2023-10-03  8:30   ` Takashi Yano
2023-10-03 17:31     ` Jeff Johnston
2023-10-03 20:12       ` Takashi Yano
2023-10-03 18:07     ` Brian Inglis
2023-09-28  3:58 ` Takashi Yano
2023-09-28  8:42   ` Takashi Yano
2023-09-28 20:06     ` Brian Inglis
2023-10-04 20:16   ` Jeff Johnston
2023-10-05 10:18     ` Takashi Yano
2023-10-05 15:18       ` Takashi Yano
2023-10-05 18:20         ` Torbjorn SVENSSON
2023-11-07 13:24         ` Corinna Vinschen
2023-11-07 16:50           ` Brian Inglis
2023-11-07 19:12             ` Corinna Vinschen
2023-11-08 12:05           ` Takashi Yano
2023-11-02 18:53     ` Corinna Vinschen [this message]
2023-11-06 18:26       ` Brian Inglis

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=ZUPwP/d0oqG362/N@calimero.vinschen.de \
    --to=vinschen@redhat.com \
    --cc=eblake@redhat.com \
    --cc=jjohnstn@redhat.com \
    --cc=newlib@sourceware.org \
    --cc=takashi.yano@nifty.ne.jp \
    /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).