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

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AC2D03857C5F
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1637269757;
bh=kjvLwE5D9ZKzOj/h3gjvJTMcj1cKFe5cY1374z9ueIU=;
h=Date:To:References:Subject:In-Reply-To:List-Id:List-Unsubscribe:
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:
From;
b=P3EHhQUTwTqbHrkiN3lQcrrsWyIXG+O6zVPAtzuJR8vwHy/wNWdkmlxWeZ08e0cEt
EjZ8hQY5WSlvGE5urXEkTAHPVuloiZ1pNY0Z7n2vbrdfw8j4KiT1yf+NFZAb27jI9C
dzc40X0e0W2jzy6hlD4hslAAZKJhv3/al60KLCuw=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 40F1C3858422
X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c
Message-ID: <7545bb24-43de-cd7d-0764-55c85f1af957@gmx.com>
Date: Thu, 18 Nov 2021 21:08:40 +0000
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.3.1
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>
<YZZi3rI5msk6ksAV AT calimero DOT vinschen DOT de>
Subject: Re: possible snprintf() regression in 3.3.2
In-Reply-To: <YZZi3rI5msk6ksAV@calimero.vinschen.de>
X-Provags-ID: V03:K1:6W/N7BNuB4+ag38UTureyojqklLtr1EDByb6m2YuiGm+WYcSueA
n80B9n9G0C1p/j8Rz4cv/r0TiheW3sWBq55/V8tXUhZCYnBjOBTuKh/G4u2fY+avxc0Sf2M
fZdlTg6j7GuhB8M2YKpKiYHfgAF7SV99iqNdn/ZcqpAj0zN+I3ePu3HPCq6AzSHyUTNBqMo
xofoRUhzpsflV80SEKK3w==
X-UI-Out-Filterresults: notjunk:1;V03:K0:++ZNrr0pIQY=:+5P5wkN1Ld+hyRmCWrrY/K
78haoRc+DEuD5YzZBBjkG9SNbCPNw6/lcDgqz/l0Z7KY5oXfbKzEV8cFfuR1es1RrW6j+c0wd
uS+IZ8l98yuZohhwJBtMgiY8OjpXYkDODf1H33bGtmKBT008ktDTIRRUsNEIwZZAt9V7yEnYM
dz47noKj49Lt8LSKzzL5STM617SBamXja7/ul2tcIId53siRAtQ2psWJ/wcdnv/ONKFV2lQ+O
SpCBtYwV/Ja27CIw2a1/K5hbBkjFkLQAksmUGOX1ByWgQ9Fk0tySmudK3Vw4VDtMGwplrDHvo
v0HPsdhltOmDtBiPRD/DpLbai9ozIAow+JxfO2lpZrBftc5sBNmnApBt0+bxKXn0KZJ/IU8dK
BYReCYrUPKwSKsv8MwIXmpEQNDMQD6hDOLCu1szin8T4U+FQuraS2B8JnGV3wzZbTQWc2d1sE
AaqG09cYJfdj2jdKcFvodwF2rJ85hwNnDSfeK8EwcSw+8vXw7Dcxyq6gawcpsNyoMB1/B2ZSY
1o4FKak1VwpkFbL4hmcqW+iY6KSYryXJ8kUMRg4A4VYh/bnKhOD03jOryijl+8GbrIgSXz2q8
xGGU01jVKW/SrkTBCFe6l2osPES98eOZs5hmZr+2QAcggSPwO4GWAkz7Beiai3QOfHCuLCm00
JvjiGEMkvZiDyvEKzneHdcpSsPlNSroXtGezbGnpcc8kbt9ngq4rWi4sgyC1FGLCFNy/0Nzby
+GlAfacTq4RbU/WDdTJMt70lXB+1ZXHlm+Bga8gtUEuYI6i3DmrOXIz2Gng9fBEzvG9c2dInl
PEQq3/jmWNKjcu09Rj2Ce7vyIL8YljTkCjXBckS9H/D5Vns0+7AiofWxDh9/sO/LO57T1hY+T
l+lAqW2DcpH/8WxO92L9Wo+/Q6cJbS0v2iUr191EcVIYRtp5obixq0TXHuO5/N+H3+DAuzASW
iIlmtNmzLunolSu1BR3trGMy6KcqiBY7xqsiS40UQmdUGfyoyhN9IZvdNAKXP0oTx2QhyxZ39
uPO4oQdUK1B/ptE6t881aWsnkb5EifCp2ub5dayBmWngH9pfHzZLXXfmdDrjUmQujW7Y2sA1w
RFV765Z2MhKcwU=
X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00, DKIM_SIGNED,
DKIM_VALID, FREEMAIL_FROM, KAM_NUMSUBJECT, NICE_REPLY_A, RCVD_IN_DNSWL_LOW,
RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS,
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: Sam Edge via Cygwin <cygwin AT cygwin DOT com>
Reply-To: Sam Edge <sam DOT edge AT gmx 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 18/11/2021 14:27, Corinna Vinschen via Cygwin wrote:

> 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


Hi all.

I use newlib on embedded with threading libs that have predetermined
fixed thread stack sizes. While we tend to have more RAM than in former
times we also have multiple thread stacks. Use of alloca() or variable
length automatic arrays makes me wince especially in code I might not be
able to avoid calling which is often the case with XXXprintf() in
third-party libraries' debug output. I'd usually rather take the
performance hit from using heap instead of having to make all my stacks
bigger.

Just my two penn'orth.

Cheers.
--
Sam


-- 
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