Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sat, 19 Apr 2014 21:59:12 -0400
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: Re: asctime(0) Segmentation fault

On Sun, Apr 20, 2014 at 03:43:39AM +0200, Szabolcs Nagy wrote:
> * John Mudd <johnbmudd@...il.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

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.