mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Morten Welinder <mwelinder@gmail.com>
To: musl@lists.openwall.com
Subject: Re: printf issues
Date: Fri, 4 Apr 2014 18:50:18 -0400	[thread overview]
Message-ID: <CANv4PNm6wUonre6PXY_9qqPnrPNw7ouL0Rta47Jn8vGC_6ZE=w@mail.gmail.com> (raw)
In-Reply-To: <20140404210837.GS26358@brightrain.aerifal.cx>

> Were you able to determine what data it clobbers (in practice;
> obviously this is compiler-specific) and whether the clobber
> has any observable effects?

It clobbers uninitialized parts of "big".  If you add

    for (i = 0; i < sizeof(big)/sizeof(big[0]); i++) big[i] = 12345678;

then it will consistently print "1.23E+16" which is a bit off, :-)  If
you instead
initialize like this:

    for (i = 0; i < sizeof(big)/sizeof(big[0]); i++) big[i] = 999999999;

then I get "1E+15939" which is fairly impressive.  Also, in this case it will
clobber whatever happened to come before "big".

Morten



On Fri, Apr 4, 2014 at 5:08 PM, Rich Felker <dalias@aerifal.cx> wrote:
> On Fri, Apr 04, 2014 at 04:22:46PM -0400, Morten Welinder wrote:
>> Another printf issue has shown up, this time with memory corruption.
>>
>>     printf ("%.3E\n", 999999999.0);
>>
>> The rounding test correctly decides that it needs to round this value
>> up to 1E+09.  It is, however, utterly unprepared for having nowhere to
>> put the carry.  It happily accesses and changes one or more elements
>> before the one that held 999999999.
>
> I suspect this may be true; if so, it's a very nice catch. Were you
> able to determine what data it clobbers (in practice; obviously this
> is compiler-specific) and whether the clobber has any observable
> effects?
>
> Rich


  reply	other threads:[~2014-04-04 22:50 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-04 13:32 Morten Welinder
2014-04-04 14:12 ` Rich Felker
2014-04-04 14:15 ` Szabolcs Nagy
2014-04-04 14:35   ` Morten Welinder
2014-04-04 14:56     ` Szabolcs Nagy
2014-04-04 15:07     ` Rich Felker
2014-04-04 17:42       ` Morten Welinder
2014-04-04 18:54         ` Szabolcs Nagy
2014-04-04 20:01           ` Morten Welinder
2014-04-04 20:22             ` Morten Welinder
2014-04-04 21:08               ` Rich Felker
2014-04-04 22:50                 ` Morten Welinder [this message]
2014-04-05  0:01                   ` Morten Welinder
2014-04-05  1:41                     ` Rich Felker
2014-04-07  7:29                     ` Rich Felker
2014-04-07 13:40                       ` Morten Welinder
2014-04-07 14:13                         ` Morten Welinder
2014-04-07 15:36                           ` Szabolcs Nagy
2014-04-07 18:04                             ` Rich Felker
2014-04-04 20:54             ` Szabolcs Nagy
2014-04-04 21:02             ` Rich Felker
2014-04-05  2:08               ` Morten Welinder
2014-04-05  2:50                 ` Rich Felker
2014-04-06 23:07                   ` Szabolcs Nagy
2014-04-04 21:00           ` Rich Felker
2014-04-04 21:10             ` Szabolcs Nagy
2014-04-04 20:58         ` Rich Felker

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='CANv4PNm6wUonre6PXY_9qqPnrPNw7ouL0Rta47Jn8vGC_6ZE=w@mail.gmail.com' \
    --to=mwelinder@gmail.com \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).