From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: charles@aurox.ch (Charles A. Roelli) Newsgroups: gmane.emacs.bugs Subject: bug#27706: MacOS: decode-time hang Date: Sat, 30 Sep 2017 21:09:08 +0200 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1506798611 27595 195.159.176.226 (30 Sep 2017 19:10:11 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 30 Sep 2017 19:10:11 +0000 (UTC) To: 27706@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Sep 30 21:10:05 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dyN9I-0006Yd-Jd for geb-bug-gnu-emacs@m.gmane.org; Sat, 30 Sep 2017 21:10:05 +0200 Original-Received: from localhost ([::1]:40142 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dyN9Q-00028E-1L for geb-bug-gnu-emacs@m.gmane.org; Sat, 30 Sep 2017 15:10:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43818) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dyN9L-00026p-4F for bug-gnu-emacs@gnu.org; Sat, 30 Sep 2017 15:10:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dyN9G-0000PE-OH for bug-gnu-emacs@gnu.org; Sat, 30 Sep 2017 15:10:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:32779) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dyN9G-0000Oy-Je for bug-gnu-emacs@gnu.org; Sat, 30 Sep 2017 15:10:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dyN9G-0005YB-Bh for bug-gnu-emacs@gnu.org; Sat, 30 Sep 2017 15:10:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: charles@aurox.ch (Charles A. Roelli) Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 30 Sep 2017 19:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27706 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 27706-submit@debbugs.gnu.org id=B27706.150679857821294 (code B ref 27706); Sat, 30 Sep 2017 19:10:02 +0000 Original-Received: (at 27706) by debbugs.gnu.org; 30 Sep 2017 19:09:38 +0000 Original-Received: from localhost ([127.0.0.1]:41460 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dyN8s-0005XN-KB for submit@debbugs.gnu.org; Sat, 30 Sep 2017 15:09:38 -0400 Original-Received: from sinyavsky.aurox.ch ([37.35.109.145]:43820) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dyN8q-0005Wk-TM for 27706@debbugs.gnu.org; Sat, 30 Sep 2017 15:09:37 -0400 Original-Received: from sinyavsky.aurox.ch (sinyavsky.aurox.ch [127.0.0.1]) by sinyavsky.aurox.ch (Postfix) with ESMTP id 4A30222558 for <27706@debbugs.gnu.org>; Sat, 30 Sep 2017 19:03:02 +0000 (UTC) Authentication-Results: sinyavsky.aurox.ch (amavisd-new); dkim=pass (1024-bit key) reason="pass (just generated, assumed good)" header.d=aurox.ch DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=aurox.ch; h= content-type:content-type:mime-version:references:subject :subject:in-reply-to:to:from:from:message-id:date:date; s=dkim; t=1506798180; x=1507662181; bh=lJjIbwBDGjKBhyDUARe99dauRlrIQTBM +1njhkY73p4=; b=YYgtuJN4WdFUf2agVzbPpy/qrZzm1DMGDwYE/V7FXCX2emys SDt3/U/WYTbIAH0LJOTVHJHwMVash/GpXaTwbl/DuUqAoBQGmpURbHIPozOcVQq3 0ZVsSfO+lSpJm3dsLvUU5tftbykN9R7PD1pco5KpVsnaJPL7uc3CMkWFaJo= X-Virus-Scanned: Debian amavisd-new at test.virtualizor.com Original-Received: from sinyavsky.aurox.ch ([127.0.0.1]) by sinyavsky.aurox.ch (sinyavsky.aurox.ch [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id QcBvu6e1jMC6 for <27706@debbugs.gnu.org>; Sat, 30 Sep 2017 19:03:00 +0000 (UTC) Original-Received: from gray (125.85.192.178.dynamic.wline.res.cust.swisscom.ch [178.192.85.125]) by sinyavsky.aurox.ch (Postfix) with ESMTPSA id 5169F22506 for <27706@debbugs.gnu.org>; Sat, 30 Sep 2017 19:02:58 +0000 (UTC) In-reply-to: (charles@aurox.ch) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:137706 Archived-At: > From: "Charles A. Roelli" > Date: Sat, 15 Jul 2017 16:19:39 +0200 > > Evaluating the following form on my system (macOS 10.6) results in a > hang from Emacs 23 to master: > > (decode-time '(-1034058203136 0)) > > [other values around -1034058203136 don't cause an issue] > > The stack trace (stuck in macOS' libc, I think): > > [...] > > The form is called when compiling the new org-timer.el, which requires > org-clock.el, which itself contains this call that causes the issue: > > (defconst org-clock--oldest-date > (let* ((dichotomy > (lambda (min max pred) > (if (funcall pred min) min > (cl-incf min) > (while (> (- max min) 1) > (let ((mean (+ (ash min -1) (ash max -1) (logand min max 1)))) > (if (funcall pred mean) (setq max mean) (setq min mean))))) > max)) > (high > (funcall dichotomy > most-negative-fixnum > 0 > (lambda (m) (ignore-errors (decode-time (list m 0)))))) > (low > (funcall dichotomy > most-negative-fixnum > 0 > (lambda (m) (ignore-errors (decode-time (list high m))))))) > (list high low)) > "Internal time for oldest date representable on the system.") > > As a result, "make" hangs for me, so I delete org-timer.el locally to > get around the problem for now. But I'd like to find a more permanent > solution to make sure this doesn't happen elsewhere. > > Can anyone reproduce this under macOS, and if so, under which macOS > version? I'd like to know which versions might need a fix for this > problem. I'd like to fix this for emacs-26. Is this fix okay to apply? >From b7a871e126b6e2036dbbe81b5c8b36bfbf6da419 Mon Sep 17 00:00:00 2001 From: "Charles A. Roelli" Date: Sat, 30 Sep 2017 20:42:03 +0200 Subject: [PATCH] Workaround for faulty localtime() under macOS 10.6 * lisp/org/org-clock.el (org-clock--oldest-date): Only execute 'decode-time' on times later than year -2**31 under macOS 10.6. See Bug#27706. --- lisp/org/org-clock.el | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lisp/org/org-clock.el b/lisp/org/org-clock.el index 8df185d..97d9612 100644 --- a/lisp/org/org-clock.el +++ b/lisp/org/org-clock.el @@ -478,7 +478,18 @@ org-clock--oldest-date (funcall dichotomy most-negative-fixnum 0 - (lambda (m) (ignore-errors (decode-time (list m 0)))))) + (lambda (m) + ;; libc in macOS 10.6 hangs when decoding times + ;; around year -2**31. Limit `high' not to go + ;; any earlier than that. + (if (and (featurep 'ns) + (string-match-p + "10\\.6\\.[[:digit:]]" + (shell-command-to-string + "sw_vers -productVersion"))) + (if (> m -1034058203136) + (ignore-errors (decode-time (list m 0)))) + (ignore-errors (decode-time (list m 0))))))) (low (funcall dichotomy most-negative-fixnum -- 2.9.4