From unknown Mon Jun 23 02:22:22 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#30738 <30738@debbugs.gnu.org> To: bug#30738 <30738@debbugs.gnu.org> Subject: Status: Invalid timezone (tzalloc failure) treated as out-of-memory Reply-To: bug#30738 <30738@debbugs.gnu.org> Date: Mon, 23 Jun 2025 09:22:22 +0000 retitle 30738 Invalid timezone (tzalloc failure) treated as out-of-memory reassign 30738 emacs submitter 30738 Valery Ushakov severity 30738 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 06 18:33:25 2018 Received: (at submit) by debbugs.gnu.org; 6 Mar 2018 23:33:25 +0000 Received: from localhost ([127.0.0.1]:48233 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1etM5F-0008D7-Lr for submit@debbugs.gnu.org; Tue, 06 Mar 2018 18:33:25 -0500 Received: from eggs.gnu.org ([208.118.235.92]:44270) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1etLTD-0007F8-0q for submit@debbugs.gnu.org; Tue, 06 Mar 2018 17:54:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etLT6-0004qW-St for submit@debbugs.gnu.org; Tue, 06 Mar 2018 17:54:01 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:47152) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1etLT6-0004pz-Oa for submit@debbugs.gnu.org; Tue, 06 Mar 2018 17:54:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35241) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etLT5-0005Ye-PO for bug-gnu-emacs@gnu.org; Tue, 06 Mar 2018 17:54:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etLT2-0004np-OS for bug-gnu-emacs@gnu.org; Tue, 06 Mar 2018 17:53:59 -0500 Received: from pony.stderr.spb.ru ([212.113.112.78]:64551) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etLT2-0004mg-Ep for bug-gnu-emacs@gnu.org; Tue, 06 Mar 2018 17:53:56 -0500 Received: by pony.stderr.spb.ru (Postfix, from userid 1000) id 5A7D91F0D22; Wed, 7 Mar 2018 01:53:46 +0300 (MSK) Date: Wed, 7 Mar 2018 01:53:46 +0300 From: Valery Ushakov To: bug-gnu-emacs@gnu.org Subject: Invalid timezone (tzalloc failure) treated as out-of-memory Message-ID: <20180306225346.GA22072@pony.stderr.spb.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.2 (2017-12-15) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Tue, 06 Mar 2018 18:33:25 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) Emacs 25 treats tzalloc(3) failure as out-of-memory condition. E.g. when an invalid timezone is specified, it fails to start with: $ TZ=FOOBAR emacs -nw emacs: Memory exhausted--use M-x save-some-buffers then exit and restart Emacs The code in tzlookup() also assumes that tzalloc(3) understands the direct zone specification in the name/offset format. I haven't checked tzcode history, but this support is only a few years old (around 2014, I'd estimate). E.g. NetBSD-6 has older tzcode(3) that doesn't support this feature. This leads to a lot of "Memory exhausted" errors when trying to use e.g. vc.el "encode-time" (0xffffa2d4) "apply" (0xffffa3fc) "vc-cvs-parse-entry" (0xffffa718) "vc-cvs-registered" (0xffffa9b0) "progn" (0xffffab44) "if" (0xffffac24) "vc-cvs-registered" (0xffffae7c) "apply" (0xffffae78) "vc-call-backend" (0xffffb188) 0x1c65360 PVEC_COMPILED "mapc" (0xffffb5c8) "vc-registered" (0xffffb8d8) "vc-backend" (0xffffbbe8) "vc-refresh-state" (0xffffbfa0) "run-hooks" (0xffffc08c) "after-find-file" (0xffffc3b4) ... -uwe From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 11 04:33:11 2018 Received: (at 30738-done) by debbugs.gnu.org; 11 Mar 2018 08:33:11 +0000 Received: from localhost ([127.0.0.1]:54662 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1euwPn-0002yX-FW for submit@debbugs.gnu.org; Sun, 11 Mar 2018 04:33:11 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:41984) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1euwPl-0002yI-VG for 30738-done@debbugs.gnu.org; Sun, 11 Mar 2018 04:33:10 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 983401616C5; Sun, 11 Mar 2018 00:33:04 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id jsUBRLTFLQnb; Sun, 11 Mar 2018 00:33:03 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id AF59F1616D3; Sun, 11 Mar 2018 00:33:03 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Wii6AD47R_rw; Sun, 11 Mar 2018 00:33:03 -0800 (PST) Received: from [192.168.1.9] (unknown [47.154.30.119]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 897E11616C5; Sun, 11 Mar 2018 00:33:03 -0800 (PST) Subject: Re: Invalid timezone (tzalloc failure) treated as out-of-memory From: Paul Eggert To: Valery Ushakov References: <1370cc81-6aea-ed58-fcc0-1adc32f4252c@cs.ucla.edu> Organization: UCLA Computer Science Department Message-ID: Date: Sun, 11 Mar 2018 00:33:03 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <1370cc81-6aea-ed58-fcc0-1adc32f4252c@cs.ucla.edu> Content-Type: multipart/mixed; boundary="------------9EDCB85ED47E0C4B3150A0F5" Content-Language: en-US X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 30738-done Cc: 30738-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) This is a multi-part message in MIME format. --------------9EDCB85ED47E0C4B3150A0F5 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit [resending, I hope to the right place this time] Thanks for reporting the problem. I have installed the attached two patches, which I think should fix the problem so I'm closing the bug report. Please give them a try on NetBSD (as I typically don't use NetBSD). --------------9EDCB85ED47E0C4B3150A0F5 Content-Type: text/x-patch; name="0001-Fix-minor-timezone-memory-leak.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Fix-minor-timezone-memory-leak.patch" >From f7c07930b581b1bcfdfb1874b6883233516bdf11 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 16 May 2017 14:19:36 -0700 Subject: [PATCH] Fix minor timezone memory leak * src/editfns.c (wall_clock_tz): Remove; unused. --- src/editfns.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/editfns.c b/src/editfns.c index ecb8e3f083..75eb75a729 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -81,10 +81,8 @@ static Lisp_Object styled_format (ptrdiff_t, Lisp_Object *, bool); enum { tzeqlen = sizeof "TZ=" - 1 }; -/* Time zones equivalent to current local time, to wall clock time, - and to UTC, respectively. */ +/* Time zones equivalent to current local time and to UTC, respectively. */ static timezone_t local_tz; -static timezone_t wall_clock_tz; static timezone_t const utc_tz = 0; /* The cached value of Vsystem_name. This is used only to compare it @@ -269,7 +267,6 @@ init_editfns (bool dumping) /* Set the time zone rule now, so that the call to putenv is done before multiple threads are active. */ - wall_clock_tz = xtzalloc (0); tzlookup (tz ? build_string (tz) : Qwall, true); pw = getpwuid (getuid ()); -- 2.14.3 --------------9EDCB85ED47E0C4B3150A0F5 Content-Type: text/x-patch; name="0001-Port-to-NetBSD-tzalloc.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Port-to-NetBSD-tzalloc.patch" >From 46844ad78968cd804d0e5fc98ce49b46b3d8a53d Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 11 Mar 2018 00:18:34 -0800 Subject: [PATCH] Port to NetBSD tzalloc Problem reported by Valery Ushakov (Bug#30738). * src/editfns.c (xtzalloc): Remove. (invalid_time_zone_specification): New function. (tzlookup): Port to NetBSD, where tzalloc can fail when the TZ string has an invalid value. --- src/editfns.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/editfns.c b/src/editfns.c index 3a34dd0980..debe10572d 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -117,14 +117,10 @@ emacs_mktime_z (timezone_t tz, struct tm *tm) return t; } -/* Allocate a timezone, signaling on failure. */ -static timezone_t -xtzalloc (char const *name) +static _Noreturn void +invalid_time_zone_specification (Lisp_Object zone) { - timezone_t tz = tzalloc (name); - if (!tz) - memory_full (SIZE_MAX); - return tz; + xsignal2 (Qerror, build_string ("Invalid time zone specification"), zone); } /* Free a timezone, except do not free the time zone for local time. @@ -205,9 +201,15 @@ tzlookup (Lisp_Object zone, bool settz) } } else - xsignal2 (Qerror, build_string ("Invalid time zone specification"), - zone); - new_tz = xtzalloc (zone_string); + invalid_time_zone_specification (zone); + + new_tz = tzalloc (zone_string); + if (!new_tz) + { + if (errno == ENOMEM) + memory_full (SIZE_MAX); + invalid_time_zone_specification (zone); + } } if (settz) -- 2.14.3 --------------9EDCB85ED47E0C4B3150A0F5-- From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 12 15:10:13 2018 Received: (at 30738-done) by debbugs.gnu.org; 12 Mar 2018 19:10:13 +0000 Received: from localhost ([127.0.0.1]:57517 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1evSpp-0000a7-G4 for submit@debbugs.gnu.org; Mon, 12 Mar 2018 15:10:13 -0400 Received: from pony.stderr.spb.ru ([212.113.112.78]:64146) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1evSpn-0000Zq-ML for 30738-done@debbugs.gnu.org; Mon, 12 Mar 2018 15:10:12 -0400 Received: by pony.stderr.spb.ru (Postfix, from userid 1000) id 949EB1F0D29; Mon, 12 Mar 2018 22:10:02 +0300 (MSK) Date: Mon, 12 Mar 2018 22:10:02 +0300 From: Valery Ushakov To: Paul Eggert Subject: Re: Invalid timezone (tzalloc failure) treated as out-of-memory Message-ID: <20180312191002.GA3278@pony.stderr.spb.ru> References: <1370cc81-6aea-ed58-fcc0-1adc32f4252c@cs.ucla.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 30738-done Cc: 30738-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) On Sun, Mar 11, 2018 at 00:33:03 -0800, Paul Eggert wrote: > Thanks for reporting the problem. I have installed the attached two > patches, which I think should fix the problem so I'm closing the bug > report. Please give them a try on NetBSD (as I typically don't use > NetBSD). Thank you for your prompt response. This helps but only partially. Now emacs doesn't freak out with a scary message when tzalloc() returns NULL, but tzlookup() still calls tzalloc("XXXhh:mm:ss") for integer "zone". Unfortunately, as I mentioned in the original submission, tzcode in NetBSD-6 doesn't grok that (support for that appeared in tzcode only around 2014 I think), so each time you open a file under CVS control you get the "Invalid time zone" error. Perhaps in the long term configure should try to detect if host's tzalloc() understands that kind of direct timezone specification. However in the case of CVS the offending zone value is zero that comes from parsed-time-string, so the following quick hack can be used --- editfns.c.dist 2017-04-14 18:02:47.000000000 +0300 +++ editfns.c 2018-03-12 21:46:58.000000000 +0300 @@ -153,7 +147,8 @@ if (NILP (zone)) return local_tz; - else if (EQ (zone, Qt)) + else if (EQ (zone, Qt) + || (INTEGERP (zone) && XINT (zone) == 0)) { zone_string = "UTC0"; new_tz = utc_tz; I don't know if CVS always uses UTC or it's just because the CVS repos I work with all use UTC as an adminsitrative decision. Though I guess it can be argued that special-casing zone 0 like that to return utc_tz is the right thing to do regardless. Thanks. -uwe From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 15 12:43:40 2018 Received: (at 30738) by debbugs.gnu.org; 15 Mar 2018 16:43:40 +0000 Received: from localhost ([127.0.0.1]:35335 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ewVyc-0002E3-7l for submit@debbugs.gnu.org; Thu, 15 Mar 2018 12:43:38 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:58814) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ewVya-0002Dp-63 for 30738@debbugs.gnu.org; Thu, 15 Mar 2018 12:43:36 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id E229E1616D8; Thu, 15 Mar 2018 09:43:29 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id zt9S5vmRq8fO; Thu, 15 Mar 2018 09:43:24 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id E7D381616E3; Thu, 15 Mar 2018 09:43:23 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id ZJr_OpuHGV8V; Thu, 15 Mar 2018 09:43:23 -0700 (PDT) Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id CA8E61616D8; Thu, 15 Mar 2018 09:43:23 -0700 (PDT) Subject: Re: Invalid timezone (tzalloc failure) treated as out-of-memory To: Valery Ushakov References: <1370cc81-6aea-ed58-fcc0-1adc32f4252c@cs.ucla.edu> <20180312191002.GA3278@pony.stderr.spb.ru> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: Date: Thu, 15 Mar 2018 09:43:20 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180312191002.GA3278@pony.stderr.spb.ru> Content-Type: multipart/mixed; boundary="------------C298D57F5684528018729DE9" Content-Language: en-US X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 30738 Cc: 30738@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) This is a multi-part message in MIME format. --------------C298D57F5684528018729DE9 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 03/12/2018 12:10 PM, Valery Ushakov wrote: > - else if (EQ (zone, Qt)) > + else if (EQ (zone, Qt) > + || (INTEGERP (zone) && XINT (zone) == 0)) Thanks for diagnosing the problem. If I understand things correctly, we can do a more-general fix, which should work for any used-in-practice time zone that is an integer hour offset from UTC. I installed the attached patch into master; please give it a try. I don't have easy access to NetBSD and would appreciate your testing it on NetBSD 6 and 7. I think this problem is limited to older NetBSD and so is not worth testing for in configure.ac (as 'configure' is pretty slow already). --------------C298D57F5684528018729DE9 Content-Type: text/plain; charset=UTF-8; name="0001-Improve-port-to-NetBSD-tzalloc.txt" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="0001-Improve-port-to-NetBSD-tzalloc.txt" RnJvbSA2NGExZGE0OTg5YjA1NTE0ODE2MDBmYWNiMTc4MWFjOTIwODlkMTgyIE1vbiBTZXAg MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBQYXVsIEVnZ2VydCA8ZWdnZXJ0QGNzLnVjbGEuZWR1 PgpEYXRlOiBUaHUsIDE1IE1hciAyMDE4IDA5OjM1OjMzIC0wNzAwClN1YmplY3Q6IFtQQVRD SF0gSW1wcm92ZSBwb3J0IHRvIE5ldEJTRCB0emFsbG9jCk1JTUUtVmVyc2lvbjogMS4wCkNv bnRlbnQtVHlwZTogdGV4dC9wbGFpbjsgY2hhcnNldD1VVEYtOApDb250ZW50LVRyYW5zZmVy LUVuY29kaW5nOiA4Yml0CgpQcm9ibGVtIHJlcG9ydGVkIGJ5IFZhbGVyeSBVc2hha292IChC dWcjMzA3MzgjMTMpLgoqIHNyYy9lZGl0Zm5zLmMgKHR6bG9va3VwKSBbX19OZXRCU0RfVmVy c2lvbl9fIDwgNzAwMDAwMDAwXToKSWYgdHphbGxvYyBmYWlscyBmb3IgYW55IHJlYXNvbiBv dGhlciB0aGFuIG1lbW9yeSBleGhhdXN0aW9uLAphc3N1bWUgaXTigJlzIGJlY2F1c2UgTmV0 QlNEIDYgZG9lcyBub3Qgc3VwcG9ydCB0emFsbG9jIG9uClBPU0lYLWZvcm1hdCBUWiBzdHJp bmdzLCBhbmQgZmFsbCBiYWNrIG9uIHR6ZGIgaWYgcG9zc2libGUuCi0tLQogc3JjL2VkaXRm bnMuYyB8IDEyICsrKysrKysrKysrKwogMSBmaWxlIGNoYW5nZWQsIDEyIGluc2VydGlvbnMo KykKCmRpZmYgLS1naXQgYS9zcmMvZWRpdGZucy5jIGIvc3JjL2VkaXRmbnMuYwppbmRleCA2 ZWNjODNmYzMwLi5kMjYzMTk0NDFiIDEwMDY0NAotLS0gYS9zcmMvZWRpdGZucy5jCisrKyBi L3NyYy9lZGl0Zm5zLmMKQEAgLTIwNCw2ICsyMDQsMTggQEAgdHpsb29rdXAgKExpc3BfT2Jq ZWN0IHpvbmUsIGJvb2wgc2V0dHopCiAJaW52YWxpZF90aW1lX3pvbmVfc3BlY2lmaWNhdGlv biAoem9uZSk7CiAKICAgICAgIG5ld190eiA9IHR6YWxsb2MgKHpvbmVfc3RyaW5nKTsKKwor I2lmIGRlZmluZWQgX19OZXRCU0RfVmVyc2lvbl9fICYmIF9fTmV0QlNEX1ZlcnNpb25fXyA8 IDcwMDAwMDAwMAorICAgICAgLyogTmV0QlNEIDYgdHphbGxvYyBtaXNoYW5kbGVzIFBPU0lY IFRaIHN0cmluZ3MgKEJ1ZyMzMDczOCkuCisJIElmIHBvc3NpYmxlLCBmYWxsIGJhY2sgb24g dHpkYi4gICovCisgICAgICBpZiAoIW5ld190eiAmJiBlcnJubyAhPSBFTk9NRU0gJiYgcGxh aW5faW50ZWdlcgorCSAgJiYgWElOVCAoem9uZSkgJSAoNjAgKiA2MCkgPT0gMCkKKwl7CisJ ICBzcHJpbnRmICh0emJ1ZiwgIkV0Yy9HTVQlKyJwSSJkIiwgLSAoWElOVCAoem9uZSkgLyAo NjAgKiA2MCkpKTsKKwkgIG5ld190eiA9IHR6YWxsb2MgKHpvbmVfc3RyaW5nKTsKKwl9Cisj ZW5kaWYKKwogICAgICAgaWYgKCFuZXdfdHopCiAJewogCSAgaWYgKGVycm5vID09IEVOT01F TSkKLS0gCjIuMTQuMwoK --------------C298D57F5684528018729DE9-- From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 19 12:29:55 2018 Received: (at 30738) by debbugs.gnu.org; 19 Mar 2018 16:29:55 +0000 Received: from localhost ([127.0.0.1]:42069 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1exxfX-0005FV-L8 for submit@debbugs.gnu.org; Mon, 19 Mar 2018 12:29:55 -0400 Received: from pony.stderr.spb.ru ([212.113.112.78]:63608) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1exxfV-0005FG-Mz for 30738@debbugs.gnu.org; Mon, 19 Mar 2018 12:29:54 -0400 Received: by pony.stderr.spb.ru (Postfix, from userid 1000) id BBF741F0D29; Mon, 19 Mar 2018 19:29:43 +0300 (MSK) Date: Mon, 19 Mar 2018 19:29:43 +0300 From: Valery Ushakov To: Paul Eggert Subject: Re: Invalid timezone (tzalloc failure) treated as out-of-memory Message-ID: <20180319162943.GN3278@pony.stderr.spb.ru> References: <1370cc81-6aea-ed58-fcc0-1adc32f4252c@cs.ucla.edu> <20180312191002.GA3278@pony.stderr.spb.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 30738 Cc: 30738@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) On Thu, Mar 15, 2018 at 09:43:20 -0700, Paul Eggert wrote: > On 03/12/2018 12:10 PM, Valery Ushakov wrote: > > - else if (EQ (zone, Qt)) > > + else if (EQ (zone, Qt) > > + || (INTEGERP (zone) && XINT (zone) == 0)) > > Thanks for diagnosing the problem. If I understand things correctly, we can > do a more-general fix, which should work for any used-in-practice time zone > that is an integer hour offset from UTC. I installed the attached patch into > master; please give it a try. Sorry, I still haven't got around to test it, but I used exactly the same approach with Etc/GMT* zones as a kludge when I first ran into this problem and needed a working emacs asap. I'll try to actually test your patch this week. I'd say special casing 0 is still a good idea as it saves a call to tzalloc(). I also suspect that zone == 0 from parsed-time-string is the most common case. -uwe From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 19 16:24:36 2018 Received: (at 30738) by debbugs.gnu.org; 19 Mar 2018 20:24:36 +0000 Received: from localhost ([127.0.0.1]:42230 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ey1Kd-0002Xx-Q1 for submit@debbugs.gnu.org; Mon, 19 Mar 2018 16:24:35 -0400 Received: from pony.stderr.spb.ru ([212.113.112.78]:63596) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ey1Kb-0002Xh-Vb for 30738@debbugs.gnu.org; Mon, 19 Mar 2018 16:24:34 -0400 Received: by pony.stderr.spb.ru (Postfix, from userid 1000) id AD4701F0D29; Mon, 19 Mar 2018 23:24:25 +0300 (MSK) Date: Mon, 19 Mar 2018 23:24:25 +0300 From: Valery Ushakov To: Paul Eggert Subject: Re: Invalid timezone (tzalloc failure) treated as out-of-memory Message-ID: <20180319202425.GO3278@pony.stderr.spb.ru> References: <1370cc81-6aea-ed58-fcc0-1adc32f4252c@cs.ucla.edu> <20180312191002.GA3278@pony.stderr.spb.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 30738 Cc: 30738@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) On Thu, Mar 15, 2018 at 09:43:20 -0700, Paul Eggert wrote: > On 03/12/2018 12:10 PM, Valery Ushakov wrote: > > - else if (EQ (zone, Qt)) > > + else if (EQ (zone, Qt) > > + || (INTEGERP (zone) && XINT (zone) == 0)) > > Thanks for diagnosing the problem. If I understand things correctly, we can > do a more-general fix, which should work for any used-in-practice time zone > that is an integer hour offset from UTC. I installed the attached patch into > master; please give it a try. I don't have easy access to NetBSD and would > appreciate your testing it on NetBSD 6 and 7. I've tested it and this patch also needs to #include where __NetBSD_Version__ is defined. PS: As an aside, that %+ made me realize that tzbuf_format can probably drop that artisanal &"-"[...] and its corresponding %s, and just pass -hour instead. -uwe From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 19 19:55:38 2018 Received: (at 30738) by debbugs.gnu.org; 19 Mar 2018 23:55:38 +0000 Received: from localhost ([127.0.0.1]:42380 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ey4cr-0001FK-LJ for submit@debbugs.gnu.org; Mon, 19 Mar 2018 19:55:37 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:43194) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ey4co-0001F5-7L for 30738@debbugs.gnu.org; Mon, 19 Mar 2018 19:55:34 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 10AE41616D5; Mon, 19 Mar 2018 16:55:28 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 27yaj93kcNVU; Mon, 19 Mar 2018 16:55:25 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id E15FE1616EF; Mon, 19 Mar 2018 16:55:25 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Gl2BEQucRVg3; Mon, 19 Mar 2018 16:55:25 -0700 (PDT) Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id C31361616D5; Mon, 19 Mar 2018 16:55:25 -0700 (PDT) Subject: Re: Invalid timezone (tzalloc failure) treated as out-of-memory To: Valery Ushakov References: <1370cc81-6aea-ed58-fcc0-1adc32f4252c@cs.ucla.edu> <20180312191002.GA3278@pony.stderr.spb.ru> <20180319162943.GN3278@pony.stderr.spb.ru> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: <381f3193-822c-7a08-bb22-07fde655861f@cs.ucla.edu> Date: Mon, 19 Mar 2018 16:55:25 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180319162943.GN3278@pony.stderr.spb.ru> Content-Type: multipart/mixed; boundary="------------0561F5C00CEA63DA65FC78FC" Content-Language: en-US X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 30738 Cc: 30738@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) This is a multi-part message in MIME format. --------------0561F5C00CEA63DA65FC78FC Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 03/19/2018 09:29 AM, Valery Ushakov wrote: > special casing 0 is still a good idea as it saves a call to > tzalloc(). Fair enough; I installed the first attached patch. > this patch also needs to #include > where __NetBSD_Version__ is defined. Thanks, I installed the second attached patch to do that. > tzbuf_format can > probably drop that artisanal &"-"[...] and its corresponding %s, and > just pass -hour instead. That would mishandle time zones like -00:30:00 (i.e., 30 minutes behind UTC). That is, the sign is a property of the minutes and the seconds too, not just the hours. --------------0561F5C00CEA63DA65FC78FC Content-Type: text/x-patch; name="0001-Tune-time-zone-0.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Tune-time-zone-0.patch" >From 7a7ee53dbdcf489050653f04ba3d0c491245c5fa Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 19 Mar 2018 13:29:22 -0700 Subject: [PATCH] Tune time zone 0 * src/editfns.c (tzlookup): Treat time zone 0 like t, for speed. Suggested by Valery Ushakov (Bug#30738#19). --- src/editfns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/editfns.c b/src/editfns.c index d26319441b..cb7353a48c 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -147,7 +147,7 @@ tzlookup (Lisp_Object zone, bool settz) if (NILP (zone)) return local_tz; - else if (EQ (zone, Qt)) + else if (EQ (zone, Qt) || EQ (zone, make_number (0))) { zone_string = "UTC0"; new_tz = utc_tz; -- 2.14.3 --------------0561F5C00CEA63DA65FC78FC Content-Type: text/x-patch; name="0001-Improve-port-to-NetBSD-tzalloc.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Improve-port-to-NetBSD-tzalloc.patch" >From 6d12e7af88b8287b8dd520aa3a3470f7f112cfe0 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 19 Mar 2018 16:49:09 -0700 Subject: [PATCH] Improve port to NetBSD tzalloc Problem reported by Valery Ushakov (Bug#30738#22). * src/editfns.c (HAVE_TZALLOC_BUG): New macro. (tzlookup): Use it. Compile on all platforms, not just on NetBSD. --- src/editfns.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/editfns.c b/src/editfns.c index cb7353a48c..7e35fe8797 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -48,6 +48,16 @@ along with GNU Emacs. If not, see . */ #include #include +#ifdef HAVE_TIMEZONE_T +# include +# if defined __NetBSD_Version__ && __NetBSD_Version__ < 700000000 +# define HAVE_TZALLOC_BUG true +# endif +#endif +#ifndef HAVE_TZALLOC_BUG +# define HAVE_TZALLOC_BUG false +#endif + #include #include #include @@ -205,16 +215,14 @@ tzlookup (Lisp_Object zone, bool settz) new_tz = tzalloc (zone_string); -#if defined __NetBSD_Version__ && __NetBSD_Version__ < 700000000 - /* NetBSD 6 tzalloc mishandles POSIX TZ strings (Bug#30738). - If possible, fall back on tzdb. */ - if (!new_tz && errno != ENOMEM && plain_integer + if (HAVE_TZALLOC_BUG && !new_tz && errno != ENOMEM && plain_integer && XINT (zone) % (60 * 60) == 0) { + /* tzalloc mishandles POSIX strings; fall back on tzdb if + possible (Bug#30738). */ sprintf (tzbuf, "Etc/GMT%+"pI"d", - (XINT (zone) / (60 * 60))); new_tz = tzalloc (zone_string); } -#endif if (!new_tz) { -- 2.14.3 --------------0561F5C00CEA63DA65FC78FC-- From unknown Mon Jun 23 02:22:22 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 17 Apr 2018 11:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator