mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Cc: "De Paula, Judah" <judah.depaula@pioneer.com>
Subject: Re: closedir()
Date: Thu, 31 Jan 2019 19:27:16 -0500	[thread overview]
Message-ID: <20190201002716.GK23599@brightrain.aerifal.cx> (raw)
In-Reply-To: <C1411572-ACFD-480B-840C-1B8988B52451@pioneer.com>

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


  reply	other threads:[~2019-02-01  0:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-31 21:58 closedir() De Paula, Judah
2019-02-01  0:27 ` Rich Felker [this message]
2019-02-01  1:03   ` closedir() Jorge Almeida
2019-02-01  2:30     ` closedir() Rich Felker
2019-02-01  9:34       ` closedir() Jorge Almeida

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190201002716.GK23599@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=judah.depaula@pioneer.com \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).