mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: Re: asctime(0) Segmentation fault
Date: Sat, 19 Apr 2014 21:59:12 -0400	[thread overview]
Message-ID: <20140420015912.GU26358@brightrain.aerifal.cx> (raw)
In-Reply-To: <20140420014339.GA12324@port70.net>

On Sun, Apr 20, 2014 at 03:43:39AM +0200, Szabolcs Nagy wrote:
> * John Mudd <johnbmudd@gmail.com> [2014-04-19 18:46:42 -0400]:
> > It looks like asctime(0) should return 0 instead of Segmentation fault.
> 
> no

To elaborate, 0 is not a valid pointer to struct tm, so the behavior
is undefined. The preferred response to undefined behavior is always
an immediate crash. In some cases that's not possible, or at least
would involve significant additional effort to achieve. But here, like
many places, it's the automatic natural behavior.

It's definitely not acceptable to bury undefined behavior that would
otherwise be caught by special-casing it with code to ignore it. The
proposed behavior (returning a null string pointer) would propagate
the error further and it would be more work to determine the origin of
the error (or it might not be detected at all).

> what was the python test failure?
> 
> my guess is that they pass something to asctime without checking for 0
> 
> that something being 0 may be a musl bug or a python test framework bug

Indeed, this would be interesting to know, as it might reveal a real
bug (either a bug in musl we need to fix, or a portability bug in
python that's affecting its use on musl).

Rich


  reply	other threads:[~2014-04-20  1:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-19 22:16 John Mudd
2014-04-19 22:36 ` Jens Gustedt
2014-04-19 22:46 ` John Mudd
2014-04-20  1:43   ` Szabolcs Nagy
2014-04-20  1:59     ` Rich Felker [this message]
2014-04-20  2:43   ` John Mudd
2014-04-20  2:51     ` John Mudd
2014-04-20  3:15       ` Rich Felker
2014-04-20  3:33       ` John Mudd
2014-04-20  3:35         ` Rich Felker

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=20140420015912.GU26358@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --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).