From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Ken Brown Newsgroups: gmane.emacs.bugs Subject: bug#25875: 26.0.50; Hang logging out of MS-Windows Date: Sun, 26 Feb 2017 13:04:18 -0500 Message-ID: References: <83lgsuqacv.fsf@gnu.org> <83efylq7m4.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1488132321 8496 195.159.176.226 (26 Feb 2017 18:05:21 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 26 Feb 2017 18:05:21 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 Cc: 25875@debbugs.gnu.org To: Eli Zaretskii , Richard Copley Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Feb 26 19:05:17 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 1ci3C7-0001Nf-9a for geb-bug-gnu-emacs@m.gmane.org; Sun, 26 Feb 2017 19:05:15 +0100 Original-Received: from localhost ([::1]:47777 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ci3C8-0003nl-5Q for geb-bug-gnu-emacs@m.gmane.org; Sun, 26 Feb 2017 13:05:16 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58812) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ci3Bx-0003mP-E7 for bug-gnu-emacs@gnu.org; Sun, 26 Feb 2017 13:05:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ci3Bu-0007oS-8z for bug-gnu-emacs@gnu.org; Sun, 26 Feb 2017 13:05:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:58814) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ci3Bu-0007oI-5w for bug-gnu-emacs@gnu.org; Sun, 26 Feb 2017 13:05:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ci3Bt-0001M7-PD for bug-gnu-emacs@gnu.org; Sun, 26 Feb 2017 13:05:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Ken Brown Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 26 Feb 2017 18:05:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25875 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 25875-submit@debbugs.gnu.org id=B25875.14881322725173 (code B ref 25875); Sun, 26 Feb 2017 18:05:01 +0000 Original-Received: (at 25875) by debbugs.gnu.org; 26 Feb 2017 18:04:32 +0000 Original-Received: from localhost ([127.0.0.1]:57013 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ci3BP-0001LN-RJ for submit@debbugs.gnu.org; Sun, 26 Feb 2017 13:04:32 -0500 Original-Received: from limerock03.mail.cornell.edu ([128.84.13.243]:56528) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ci3BO-0001LA-4M for 25875@debbugs.gnu.org; Sun, 26 Feb 2017 13:04:30 -0500 X-CornellRouted: This message has been Routed already. Original-Received: from authusersmtp.mail.cornell.edu (granite4.serverfarm.cornell.edu [10.16.197.9]) by limerock03.mail.cornell.edu (8.14.4/8.14.4_cu) with ESMTP id v1QI4Nxe032084; Sun, 26 Feb 2017 13:04:23 -0500 Original-Received: from [192.168.1.6] (mta-68-175-148-36.twcny.rr.com [68.175.148.36] (may be forged)) (authenticated bits=0) by authusersmtp.mail.cornell.edu (8.14.4/8.12.10) with ESMTP id v1QI4K4Y013501 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Sun, 26 Feb 2017 13:04:22 -0500 In-Reply-To: <83efylq7m4.fsf@gnu.org> X-PMX-Cornell-Gauge: Gauge=XXXXX X-PMX-CORNELL-AUTH-RESULTS: dkim-out=none; 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:129830 Archived-At: On 2/26/2017 10:44 AM, Eli Zaretskii wrote: >> From: Richard Copley >> Yes indeed. Hence "when shutting down or logging out". In this >> case shutting down the computer. > > OK, supporting that is a relatively new feature, so it's little > surprise it needs more work. Ken, could you please take a look? > > As I understand it, this happens because when the input thread gets > the WM_ENDSESSION message, it posts it to the main thread and goes on > to sleep for 1000 sec, to avoid ending the Emacs process before it > finishes orderly shutdown. But if the main thread happens to be > inside redisplay, it could invoke one of the function that send > messages to the input thread via SendMessage, which waits for the > input thread to respond. So we do have a kind of deadlock. The problem might be that 1000 sec is too long for the input thread to sleep. I chose that number arbitrarily, not realizing that the main thread could get stuck waiting for the input thread. What about something like this? --- a/src/w32fns.c +++ b/src/w32fns.c @@ -4801,8 +4801,10 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case WM_ENDSESSION: my_post_msg (&wmsg, hwnd, msg, wParam, lParam); - /* If we return, the process will be terminated immediately. */ - sleep (1000); + /* Allow time for Emacs to attempt an orderly shutdown. If we + return, the process will be terminated immediately. */ + sleep (5); + return 0; case WM_WINDOWPOSCHANGING: /* Don't restrict the sizing of any kind of frames. If the window With this change, I think Emacs will be killed in at most 5 seconds no matter what state it is in. But I can't test this because I don't know how to reproduce Richard's problem. Ken