From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from elaine.keithp.com (home.keithp.com [63.227.221.253]) by sourceware.org (Postfix) with ESMTPS id 2D9C33858D34 for ; Sat, 13 Jun 2020 00:05:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2D9C33858D34 Received: from localhost (localhost [127.0.0.1]) by elaine.keithp.com (Postfix) with ESMTP id C56733F2BE26; Fri, 12 Jun 2020 17:05:18 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at keithp.com Received: from elaine.keithp.com ([127.0.0.1]) by localhost (elaine.keithp.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id yxukIG8pdkRL; Fri, 12 Jun 2020 17:05:18 -0700 (PDT) Received: from keithp.com (koto.keithp.com [10.0.0.2]) by elaine.keithp.com (Postfix) with ESMTPSA id 27DDA3F2BE1C; Fri, 12 Jun 2020 17:05:18 -0700 (PDT) Received: by keithp.com (Postfix, from userid 1000) id 079571582197; Fri, 12 Jun 2020 17:05:16 -0700 (PDT) From: "Keith Packard" To: Josef Wolf , newlib@sourceware.org Subject: Re: undefined references since newlib-3.2.0 In-Reply-To: <20200612225013.GE15174@raven.inka.de> References: <20200612082111.GD15174@raven.inka.de> <20200612225013.GE15174@raven.inka.de> Date: Fri, 12 Jun 2020 17:05:15 -0700 Message-ID: <87v9jvhltw.fsf@keithp.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Spam-Status: No, score=-9.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_NUMSUBJECT, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Jun 2020 00:05:21 -0000 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Josef Wolf writes: > This patch replaces Balloc() by eBalloc() which calls __assert_func() on > failure which in turn calls exit() and/or abort() As an interim step, having a fix available sooner was a good thing. > Shouldn't those library functions simply report the error by returning NU= LL to > the caller and let the application handle the situation? It's complicated by the libc API which doesn't have defined error return values for all of the affected APIs. Glibc has similar failure modes; using those is probably the best option for newlib. I've patched this code in picolibc (a newlib fork designed for embedded systems) to track the malloc failures and return status information back to applications. Interested parties might want to port those fixes back to newlib. https://github.com/keith-packard/picolibc/commit/dad1bd20fb927fb14a63d7951b= 0441f1cec73bf8 https://github.com/keith-packard/picolibc/commit/9fc3006ef9fec4a72b6dd29d2b= 691c1cc386e8f1 I've also implemented the recent 'ryu' float/string conversion code, which performs exact (i.e. round-trip-able) conversions with much lower precision (128bit for 64-bit floats, 64-bit for 32-bit floats). As a result, that code does all of its operations on the stack and doesn't use malloc at all, eliminating this particular source of errors. That code was not writen for the newlib stdio bits, but instead for the picolibc tinystdio bits. Still, it might serve as a basis for a newlib port. =2D-=20 =2Dkeith --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEw4O3eCVWE9/bQJ2R2yIaaQAAABEFAl7kGDsACgkQ2yIaaQAA ABFKcw/+KL7eygvSiKxvKrTQbSps+hIFnQ9LnewuzvxzeyOwvgppHzGknQxKPhdh xnPZ+0+5//PmLDq3OfPoxUjPeVCGgCw8UCRej+LRur2lbpy9XAPJwpMQZj4vRr3c n95JyO+nhwdm/1lCkECUDlwpiTkaDqSLijKARojHZwRxu545ZXRWymTr0a3R54Ei AbmreQ0W4beEu5Sd4cM/BPE4GmZDHZ3yduXgZRNjXGP20Cv/ip0mo6lQu4KSjNHr qu0ViGLU/n248+V1kBKHYM760Xj1mTzwjTc1hLSHGfpM8cqr+yOC9mPL2IhMyEFW +fIE//6TRUHjjF9eJAYbz/zD44PNyH6vhZ1JDwIqiYG3fyFijU0h4VBW2Z/H6/zh fu7FGejkPFSFgCh6ymJq1QwgHteQDIGB1b84LmfEWFYUnF9GcjspTeO2Gxp+aSK2 M58VPH2jdWkMKuxtez12JJN/N0ip72N068qAhYFaKR7zRm5Gb8Cej7s4nkcZLNIF F3vo12k8FtWWJSKIZgKWp8vfCTee6Y8SpwUl/unL6UQ24RiQGJJQxJl6dl+ctHBt aKV8jBKWrKn43NfmV1Gx89v7Ww3e3gVzANHXvj2krLPlQelQAt9WFO6kIW9TeiMu Zr6EeFhRwzS1NYAhNM+He7s1EfkF9+BfMXZ1ve7eYkuQ0fFoiPU= =kbst -----END PGP SIGNATURE----- --=-=-=--