delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2021/11/18/09:32:09

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B70E9385C40A
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1637245928;
bh=Hn6D38zgknJWRhXPfm7EwFcGGJQr4aiqXYjK8P+UVB4=;
h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe:
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:
From;
b=ajVqDWMRpfYWNOjM4xnIXTeCo0GVg8d2wc3CAZeoccSrYM7lQUwfbD2W7pHbdalQE
U9fpT52MzM7HDVxszewpQBKmOb4Rirb8x0Z9kKlsJoM+3ECJ8p0P6cu9zmq3F5cVwN
+r6OaOY1FsUkdEvJjoJzOkWRm3ubW67VNE+LPZ1U=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 10E63385800F
Date: Thu, 18 Nov 2021 15:27:42 +0100
To: cygwin AT cygwin DOT com
Subject: Re: possible snprintf() regression in 3.3.2
Message-ID: <YZZi3rI5msk6ksAV@calimero.vinschen.de>
Mail-Followup-To: cygwin AT cygwin DOT com
References: <20211117003718 DOT GF10332 AT venus DOT tony DOT develop-help DOT com>
<20211117182108 DOT b38599f5e13071bf269a0d48 AT nifty DOT ne DOT jp>
<YZT1S8wDnaBuYf5u AT calimero DOT vinschen DOT de>
<20211118000649 DOT GG10332 AT venus DOT tony DOT develop-help DOT com>
<20211118203538 DOT a049809d57731fe375801c15 AT nifty DOT ne DOT jp>
<YZZSzPhbqF6cQAiu AT calimero DOT vinschen DOT de>
<fa647f83-c5ed-6dea-fcba-c8b799abe12f AT gmail DOT com>
MIME-Version: 1.0
In-Reply-To: <fa647f83-c5ed-6dea-fcba-c8b799abe12f@gmail.com>
X-Provags-ID: V03:K1:AYS9E4bm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
GOOD_FROM_CORINNA_CYGWIN, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_NUMSUBJECT,
RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,
SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.4
X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Corinna Vinschen via Cygwin <cygwin AT cygwin DOT com>
Reply-To: cygwin AT cygwin DOT com
Cc: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>

On Nov 18 16:11, Noel Grandin via Cygwin wrote:
> 
> 
> On 2021/11/18 3:19 pm, Corinna Vinschen via Cygwin wrote:
> > My patch raised NDEC from 43 to 1023 to allow aproximately the same
> > number of digits as glibc.  Newlib strives to support embedded targets
> > and bare metal.  Some of them are lucky if they have a stack size of 1K.
> > The outbuf buffer is created on the stack, so I used ndigits to save
> > stack space.
> > 
> > While that patch fixes the reported problem, it will make users of
> > smaller-than-Cygwin targets pretty unhappy.
> > 
> > A workaround would be to malloc outbuf instead.  Given that printf
> 
> printf is often performance sensitive, and using malloc there would likely be significantly slower.
> 
> Possibly use alloca() to allocate only the necessary amount on stack?

That's kind of what the current code does.

But that's apparently the problem.  The necessary amount is only known to
the current algorithm while populating outbuf already.  So before my
patch, outbuf had a constant size, but it was size restricted.

> Seems unlikely that embedded systems would be printing values that needed such large space anyway.

Perhaps that's a workaround:

Use a constant buffer size, but use NDEC = 1023 only on Cygwin for the
time being, something like NDEC = 64 otherwise...


Corinna

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019