public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Michael Enright <mike@kmcardiff.com>
To: cygwin@cygwin.com
Subject: Re: Seg Fault in strftime
Date: Sat, 01 Aug 2015 00:47:00 -0000	[thread overview]
Message-ID: <CAOC2fq97RZEi6PW98st7AvnYmo4N=m7xbYbp5_8HMagQFoZsnQ@mail.gmail.com> (raw)
In-Reply-To: <55BB6F59.8060905@dronecode.org.uk>

On Fri, Jul 31, 2015 at 5:51 AM, Jon TURNEY wrote:
> It would be very helpful if you could tweak the testcase there and produce
> one which reproduces your problem.
>
> [1]
> https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=commitdiff;h=75d5f68aabf62c42884ff935f888b12bbcd00001
> [2] https://sourceware.org/ml/newlib/2015/msg00321.html
>
I took one more shot at reproduction and I think the problem is that
if code does a member-by-member initialization based on the fields
defined by POSIX, it is likely that tm_zone won't be initialized and
it could end up with a really bad value. Then strftime is likely to
dereference it.

You can improve the likelihood of a crash by filling a struct tm with
0x54, like I did, but random circumstances could also effectively
cause the same thing.

We could implore the local Cygwin maintainer of mozjs to make sure
that the code I mentioned earlier in that library zeros the struct tm,
but there is only defensive programming recommending that, not a
specification. And there could be other libraries or applications
already tripping over this but not yet spending time on investigating
it.

If I took the time to think it through I think the additional logic
for handling a NULL tm_zone is not necessarily the cause of the
regression I'm facing, because the code I'm using through mozjs was
not setting that field to NULL in the first place.

I'm going to be away from the machines where I have this code at hand
for the next two weeks, reading email but not equipped to do anything
complicated about it.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

  parent reply	other threads:[~2015-08-01  0:47 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-31  0:16 Michael Enright
2015-07-31 12:51 ` Jon TURNEY
2015-07-31 19:50   ` Michael Enright
2015-07-31 23:43     ` Michael Enright
2015-08-01  0:47   ` Michael Enright [this message]
2015-08-01 21:47 ` Brian Inglis
2015-08-02  1:47   ` Michael Enright
2015-08-03  3:37     ` Brian Inglis
2015-08-03  8:36     ` Corinna Vinschen
2015-08-03 10:54       ` Michael Enright
2015-08-03 13:42         ` Corinna Vinschen
2015-08-03 15:52           ` Michael Enright
2015-08-04  5:33             ` Michael Enright
2015-08-05  8:02               ` Corinna Vinschen
2015-08-17  3:00                 ` Michael Enright
2015-08-17  8:11                   ` js185 package problem (was Re: Seg Fault in strftime) Corinna Vinschen
2015-08-24 17:39                     ` Yaakov Selkowitz
2015-08-25 17:17                       ` Michael Enright
2015-08-25 18:27                         ` Yaakov Selkowitz

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='CAOC2fq97RZEi6PW98st7AvnYmo4N=m7xbYbp5_8HMagQFoZsnQ@mail.gmail.com' \
    --to=mike@kmcardiff.com \
    --cc=cygwin@cygwin.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.
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 read-only IMAP folder(s) and NNTP newsgroup(s).