From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Antipov Newsgroups: gmane.emacs.bugs Subject: bug#18403: 24.4.50; emacsclient sometimes hangs on exit with Lucid GUI client Date: Mon, 08 Sep 2014 12:45:46 +0400 Message-ID: <540D6CBA.7090904@yandex.ru> References: <540C0878.8050302@cs.ucla.edu> <540D18E0.4080205@cs.ucla.edu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1410165994 31134 80.91.229.3 (8 Sep 2014 08:46:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 8 Sep 2014 08:46:34 +0000 (UTC) Cc: 18403@debbugs.gnu.org To: Paul Eggert , Christoph Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Sep 08 10:46:27 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XQuaf-0006jX-MZ for geb-bug-gnu-emacs@m.gmane.org; Mon, 08 Sep 2014 10:46:25 +0200 Original-Received: from localhost ([::1]:41559 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XQuae-00015r-Rp for geb-bug-gnu-emacs@m.gmane.org; Mon, 08 Sep 2014 04:46:24 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42364) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XQuaV-00015D-Vz for bug-gnu-emacs@gnu.org; Mon, 08 Sep 2014 04:46:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XQuaJ-0003Ro-0e for bug-gnu-emacs@gnu.org; Mon, 08 Sep 2014 04:46:15 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:41649) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XQuaI-0003Ri-RC for bug-gnu-emacs@gnu.org; Mon, 08 Sep 2014 04:46:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XQuaI-0003sW-DY for bug-gnu-emacs@gnu.org; Mon, 08 Sep 2014 04:46:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Antipov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 08 Sep 2014 08:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18403 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 18403-submit@debbugs.gnu.org id=B18403.141016596014896 (code B ref 18403); Mon, 08 Sep 2014 08:46:02 +0000 Original-Received: (at 18403) by debbugs.gnu.org; 8 Sep 2014 08:46:00 +0000 Original-Received: from localhost ([127.0.0.1]:33213 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XQuaF-0003sB-49 for submit@debbugs.gnu.org; Mon, 08 Sep 2014 04:45:59 -0400 Original-Received: from forward1l.mail.yandex.net ([84.201.143.144]:39794) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XQuaB-0003rv-9k for 18403@debbugs.gnu.org; Mon, 08 Sep 2014 04:45:56 -0400 Original-Received: from smtp16.mail.yandex.net (smtp16.mail.yandex.net [95.108.252.16]) by forward1l.mail.yandex.net (Yandex) with ESMTP id AB71115218A3; Mon, 8 Sep 2014 12:45:48 +0400 (MSK) Original-Received: from smtp16.mail.yandex.net (localhost [127.0.0.1]) by smtp16.mail.yandex.net (Yandex) with ESMTP id 184766A02F9; Mon, 8 Sep 2014 12:45:47 +0400 (MSK) Original-Received: from unknown (unknown [37.139.80.10]) by smtp16.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id Cd05ATcIu8-jl381Umt; Mon, 8 Sep 2014 12:45:47 +0400 (using TLSv1.2 with cipher AES128-SHA (128/128 bits)) (Client certificate not present) X-Yandex-Uniq: b5c84331-d4fb-4dd9-8364-8a6ed7e1853d DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1410165947; bh=RDvax3Wfz1UCnAdWMkJ5OY94yrfL9k8GBtUmid4YDfg=; h=Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject: References:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=Qh4biqCmvr2abqFZvgtCTsuL2VVM1aiJPTPvX/uKhWUU8r1JUvoNQFFsG8eNfM3rG DoBUC5lOmcwR5EnW4D18MMJdayunLBWBSGH7RuU+1IhqTmt8CdjNSKcsUeIkjYjYiQ 9U8nWlTHfsfkTfOdLGQv603tPsNK31JflxO9bN+Q= Authentication-Results: smtp16.mail.yandex.net; dkim=pass header.i=@yandex.ru User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.0 In-Reply-To: <540D18E0.4080205@cs.ucla.edu> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:93142 Archived-At: On 09/08/2014 06:48 AM, Paul Eggert wrote: > Thanks, I can confirm that the attached patch (which reverts that change) does fix > the bug on the trunk for me (trunk bzr 117838). Dmitry, do you have any thoughts? Argh. It looks like we can't free XtDefaultFont, otherwise XtCloseDisplay causes X protocol error, and poor handling of that causes a mess with normal fds listening loop. Thanks. While debugging this issue, I noticed one more error: Breakpoint 1, die (msg=0x717274 "errno != EBADF || fd < 0", file=0x7170e0 "../../trunk/src/sysdep.c", line=2408) at ../../trunk/src/alloc.c:7116 7116 fprintf (stderr, "\r\n%s:%d: Emacs fatal error: assertion failed: %s\r\n", (gdb) bt 10 #0 0x00000000005f6cee in die (msg=0x717274 "errno != EBADF || fd < 0", file=0x7170e0 "../../trunk/src/sysdep.c", line=2408) at ../../trunk/src/alloc.c:7116 #1 0x0000000000598469 in emacs_close (fd=8) at ../../trunk/src/sysdep.c:2408 #2 0x0000000000547834 in x_delete_terminal (terminal=0xfa0218) at ../../trunk/src/xterm.c:11381 #3 0x000000000051f8b6 in Fdelete_terminal (terminal=..., force=...) at ../../trunk/src/terminal.c:348 #4 0x00000000004290ba in delete_frame (frame=..., force=...) at ../../trunk/src/frame.c:1691 #5 0x0000000000429630 in Fdelete_frame (frame=..., force=...) at ../../trunk/src/frame.c:1801 #6 0x0000000000618c95 in Ffuncall (nargs=2, args=0x7fffd6a18ae0) at ../../trunk/src/eval.c:2815 #7 0x0000000000663e4a in exec_byte_code (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=1, args=0x7fffd6a193a0) at ../../trunk/src/bytecode.c:920 #8 0x00000000006194bd in funcall_lambda (fun=..., nargs=1, arg_vector=0x7fffd6a19398) at ../../trunk/src/eval.c:2980 #9 0x0000000000618e4e in Ffuncall (nargs=2, args=0x7fffd6a19390) at ../../trunk/src/eval.c:2861 #10 0x0000000000663e4a in exec_byte_code (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=1, args=0x7fffd6a19c30) at ../../trunk/src/bytecode.c:920 Steps to reproduce: ./src/emacs -Q --daemon ./lib-src/emacsclient -c gdb -p [pid of daemon process] b die c C-x C-x in client window ==> backtrace above IIUC dpyinfo->connection is no longer valid after call to X(t)CloseDisplay (dpyinfo->display). But this fd is still > 0, so we hit eassert at sysdep.c:2408: eassert (errno != EBADF || fd < 0); Since daemon runs in background, there is no way to see this error except using debugger. Also note that the comment above emacs_close says do not use this function for non-negative but closed descriptor. Dmitry