GNU bug report logs - #21020
24.4; `display-time-world' tampers with TZ

Previous Next

Package: emacs;

Reported by: William G. Gardella <wgg2 <at> member.fsf.org>

Date: Thu, 9 Jul 2015 19:41:02 UTC

Severity: normal

Tags: patch

Found in version 24.4

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Eli Zaretskii <eliz <at> gnu.org>
To: eggert <at> cs.ucla.edu
Cc: 21020 <at> debbugs.gnu.org, wgg2 <at> member.fsf.org
Subject: bug#21020: 24.4; `display-time-world' tampers with TZ
Date: Mon, 27 Jul 2015 20:29:43 +0300
> Date: Mon, 27 Jul 2015 15:29:33 +0300
> From: Eli Zaretskii <eliz <at> gnu.org>
> Cc: 21020 <at> debbugs.gnu.org, wgg2 <at> 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.




This bug report was last modified 9 years and 299 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.