From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/4796 Path: news.gmane.org!not-for-mail From: Morten Welinder Newsgroups: gmane.linux.lib.musl.general Subject: Re: printf issues Date: Fri, 4 Apr 2014 18:50:18 -0400 Message-ID: References: <20140404141515.GD3034@port70.net> <20140404150705.GN26358@brightrain.aerifal.cx> <20140404185413.GH3034@port70.net> <20140404210837.GS26358@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1396651847 22749 80.91.229.3 (4 Apr 2014 22:50:47 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 4 Apr 2014 22:50:47 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-4800-gllmg-musl=m.gmane.org@lists.openwall.com Sat Apr 05 00:50:40 2014 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1WWCwW-0005HC-DF for gllmg-musl@plane.gmane.org; Sat, 05 Apr 2014 00:50:36 +0200 Original-Received: (qmail 28135 invoked by uid 550); 4 Apr 2014 22:50:35 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 28127 invoked from network); 4 Apr 2014 22:50:35 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=31ChpQbzfZ0lffgJ5Z5IbyVL2E+Pzbw7w0wRk9EMT2Q=; b=AsR9uFjTwmXvbGu2TpWnlLyAAdt7vhkwOpNfGMcJZA/VKi/MApZY/pQta7Q3HzY/2l coWAs6E4D4KKdLYDjQxByiff8lMIEVKE+8eAKUojFSn6Sxn9hXyJVv6LS2cFICR3V1OF 2FinfUHwPFhQbVWLDXs8FQFbxIsbV9YrZAakrIWtwJohSSb8t1GeqUiuwEx9s9Ypz1FW TpYijfoq4QWkNL9jypxa0smxt9Uwalgj7+gE1bRf0fRmIT/LM32BMXzmqt9D13TGR6qZ bgMK/Gd/pxZIn9CY2RQnzhVGT31cs0ho2BeJ2nIZLSIktj3Aw6Qzx+TFLN+3PexMuFpe 8IZw== X-Received: by 10.180.211.207 with SMTP id ne15mr7815559wic.31.1396651818778; Fri, 04 Apr 2014 15:50:18 -0700 (PDT) In-Reply-To: <20140404210837.GS26358@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:4796 Archived-At: > 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 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