From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/13701 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: closedir() Date: Thu, 31 Jan 2019 19:27:16 -0500 Message-ID: <20190201002716.GK23599@brightrain.aerifal.cx> References: Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="197921"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.5.21 (2010-09-15) Cc: "De Paula, Judah" To: musl@lists.openwall.com Original-X-From: musl-return-13717-gllmg-musl=m.gmane.org@lists.openwall.com Fri Feb 01 01:27:34 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1gpMg7-000pLI-Oc for gllmg-musl@m.gmane.org; Fri, 01 Feb 2019 01:27:31 +0100 Original-Received: (qmail 5955 invoked by uid 550); 1 Feb 2019 00:27:29 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 5936 invoked from network); 1 Feb 2019 00:27:29 -0000 Content-Disposition: inline In-Reply-To: Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:13701 Archived-At: On Thu, Jan 31, 2019 at 09:58:06PM +0000, De Paula, Judah wrote: > Hi MUSLers, > > Possible bug report? I’m not on your DL, but would like to hear back > if you find this helpful. > > I’m working on an internal corporate application using Docker and > Alpine. Under normal Fedora my app calls closedir(NULL) and a -1 is > returned. Under MUSL, it segfaults. I’m changing the code to not > call closedir() with a null pointer, but I’m not certain segfaults > are considered Working As Designed. > > http://man7.org/linux/man-pages/man3/closedir.3.html Hi, Passing an invalid pointer to closedir is undefined behavior, and in musl the preferred effect for undefined behavior when it's not costly to attempt to detect is a quick crash so that the point of error in the program can be identified and fixed. For what it's worth, glibc has also adopted this view based on text I wrote: https://sourceware.org/glibc/wiki/Style_and_Conventions#Invalid_pointers However I doubt they will change existing functions where they have traditionally accepted null arguments as a nop. Rich