From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/4955 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: looking at fmtmsg-is dprintf oom-safe? Date: Fri, 25 Apr 2014 10:50:36 -0400 Message-ID: <20140425145036.GP26358@brightrain.aerifal.cx> References: <20140424165743.GA643@muslin> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1398437459 13151 80.91.229.3 (25 Apr 2014 14:50:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 25 Apr 2014 14:50:59 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-4959-gllmg-musl=m.gmane.org@lists.openwall.com Fri Apr 25 16:50:51 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 1WdhSl-0003Mc-BB for gllmg-musl@plane.gmane.org; Fri, 25 Apr 2014 16:50:51 +0200 Original-Received: (qmail 9857 invoked by uid 550); 25 Apr 2014 14:50:50 -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 9848 invoked from network); 25 Apr 2014 14:50:49 -0000 Content-Disposition: inline In-Reply-To: <20140424165743.GA643@muslin> User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:4955 Archived-At: On Thu, Apr 24, 2014 at 09:57:44AM -0700, Isaac Dunham wrote: > Hello, > I've been poking at fmtmsg(), since if I added that and used sdbm for > dbm.h, I'd have XSI coverage. > Due to the use case for fmtmsg (reporting errors, including terminal > errors), I expect it needs to work even when malloc() fails. > My understanding is that this would exclude using fopen(). > > I could use several calls to write() (I currently have a preliminary > version that does this), but dprintf() would be more optimal. > As far as I can tell, dprintf() should still work when malloc() fails, > but I'd like to confirm this. Yes, dprintf runs in O(1) memory (stack) and is async-signal-safe. The stack usage is tiny unless you're printing floating point, and in the fp case, something like 512 bytes to 8k depending on arch the size of long double. Rich