unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: eggert@cs.ucla.edu
Cc: 21020@debbugs.gnu.org, wgg2@member.fsf.org
Subject: bug#21020: 24.4; `display-time-world' tampers with TZ
Date: Mon, 27 Jul 2015 20:29:43 +0300	[thread overview]
Message-ID: <83zj2hy0e0.fsf@gnu.org> (raw)
In-Reply-To: <83fv49zsuq.fsf@gnu.org>

> Date: Mon, 27 Jul 2015 15:29:33 +0300
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: 21020@debbugs.gnu.org, wgg2@member.fsf.org
> 
> After the above commit, Emacs builds and generally seems to work, but
> crashes inside icalendar tests.  Seems like something with heap
> corruption.  I'm looking into that now.

The reason seems to be these assignments in time_rz.c:

  static bool
  revert_tz (timezone_t tz)
  {
    if (tz == local_tz)
      return true;
    else
      {
	int saved_errno = errno;
	bool ok = change_env (tz);
	if (!ok)
	  saved_errno = errno;
  #if HAVE_TZNAME
	if (!ok)
	  tzname_address = NULL;
	if (tzname_address)
	  {
	    char *old_value = *tzname_address;
	    *tzname_address = tzname_value;  <<<<<<<<<<<<<<<<<<<<<<<
	    tzname_value = old_value;
	  }
  #endif
	tzfree (tz);
	errno = saved_errno;
	return ok;
      }
  }

  static void
  restore_tzname (void)
  {
  #if HAVE_TZNAME
    if (tzname_address)
      {
	*tzname_address = tzname_value;    <<<<<<<<<<<<<<<<<<<<<<
	tzname_address = NULL;
      }
  #endif
  }

If I ifdef away the 2 marked lines, the test suite runs flawlessly to
completion.

tzname_address is the address of one of the members of the tzname[]
array, which holds pointers into the bowels of libc.  I don't know why
overwriting them with our values causes such trouble, but even if this
is supposed to work, it makes me nervous.  I'm not even sure I
understand completely why this trick is needed (can you explain?).  In
any case, can we please do this in some less intrusive way, e.g., by
copying the TZ names to our private storage?

Thanks.





  parent reply	other threads:[~2015-07-27 17:29 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-09 19:39 bug#21020: 24.4; `display-time-world' tampers with TZ William G. Gardella
2015-07-26  7:09 ` Paul Eggert
2015-07-26 14:48   ` Eli Zaretskii
2015-07-26 17:05     ` Paul Eggert
2015-07-26 17:34       ` Eli Zaretskii
2015-07-26 17:37         ` Eli Zaretskii
2015-07-26 17:55         ` Paul Eggert
2015-07-26 18:21           ` Eli Zaretskii
2015-07-26 19:48             ` Paul Eggert
2015-07-27 12:29               ` Eli Zaretskii
2015-07-27 15:02                 ` Paul Eggert
2015-07-27 15:22                   ` Eli Zaretskii
2015-07-27 15:38                     ` Eli Zaretskii
2015-07-27 17:29                 ` Eli Zaretskii [this message]
2015-07-28  1:09                   ` Paul Eggert
2015-07-28 10:37                     ` Eli Zaretskii

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=83zj2hy0e0.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=21020@debbugs.gnu.org \
    --cc=eggert@cs.ucla.edu \
    --cc=wgg2@member.fsf.org \
    /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.savannah.gnu.org/cgit/emacs.git

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).