Re: fprintf() crashes on wide-oriented stream.

Corinna Vinschen <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <ZUPwP/d0oqG362/[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.