GNU bug report logs - #19868
[w32] restarting compilation hangs trying to kill process

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Richard Copley <rcopley@HIDDEN>; dated Sat, 14 Feb 2015 19:31:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 19868 <at> debbugs.gnu.org:


Received: (at 19868) by debbugs.gnu.org; 15 Aug 2016 22:19:12 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Aug 15 18:19:12 2016
Received: from localhost ([127.0.0.1]:58608 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1bZQDw-0000R9-25
	for submit <at> debbugs.gnu.org; Mon, 15 Aug 2016 18:19:12 -0400
Received: from mail-oi0-f48.google.com ([209.85.218.48]:33307)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <npostavs@HIDDEN>) id 1bZQDv-0000Qy-DA
 for 19868 <at> debbugs.gnu.org; Mon, 15 Aug 2016 18:19:11 -0400
Received: by mail-oi0-f48.google.com with SMTP id c15so77139986oig.0
 for <19868 <at> debbugs.gnu.org>; Mon, 15 Aug 2016 15:19:11 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=mime-version:sender:in-reply-to:references:from:date:message-id
 :subject:to:cc;
 bh=hddMZ/RFGvJyRceXg3ZgEgB7ftTxkizFxkhbeAVKq3w=;
 b=bT2Bf5ETenlaA+d9dW+ioRjTb3p1pL572Q6O+aCzg4OHEyLS/1utesLk2laqztn19p
 0o7hNRWMttoaUBKWZpdTP2UFE+eOWt5vcITu06MnPr+J9YR1l6REyldHqc0OfPK+GN7h
 Wr+dMSZYWzWj3kn/RznhUhCf/gWjFnDIv782Lif2mK1aeBlWSUbHJNlw/+jRJe8QXm4X
 5neiNmKlx1gXxJs1f8nQ7WsY/gnWA0lMkxKWidyd4YnIycBojGq1szDeA8tthZ7ioDKO
 xfEMVkBR9HB9JTYSDHOAMw9xo/FAnO2xmG9wHkdvbY6/LLhBc/anoSxFe8I1iRw0f3Wj
 JF6A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20130820;
 h=x-gm-message-state:mime-version:sender:in-reply-to:references:from
 :date:message-id:subject:to:cc;
 bh=hddMZ/RFGvJyRceXg3ZgEgB7ftTxkizFxkhbeAVKq3w=;
 b=PW4LyLxjFJpCewTy7Qu9lMU5M6kCWqdLENj5xpQ8/yvrQRzKrrx6b63vKFr6qif72p
 cJz7bihgTJMeESBNDSkNLeoI+RfUUZ/z0NmFDBdo5XnPjApkf1Ber5O8sSQKmmOHs0iJ
 4vQxgtpuyEzBWquWWI9NklJsoJ+zxTkDEbwjKzFAwSEktw34JHakZ3fx0gO0RvkjBj++
 r7vTheTWiXP2tmcGKkyHK0LQHn7J3pUfeFdMIXc5wYhhoDwzTlRiK8rN7WZ0SiSEuG1x
 IPxo2mV+diIl5CXSDcm40ZCuRi3w6v3hjGMqKUACtG8lBp/kyJbNPJ9kkC6/UXJD0YtI
 s44w==
X-Gm-Message-State: AEkoouuzdZM58tsTlffUCnDVKjPROjUBTJoK6Dlr+6CylLEmTFyoj7c8V8FyUBPKYiPKmjYV9Tr/JRfafnGCYw==
X-Received: by 10.157.37.241 with SMTP id q104mr14588231ota.112.1471299545750; 
 Mon, 15 Aug 2016 15:19:05 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.157.7.200 with HTTP; Mon, 15 Aug 2016 15:19:05 -0700 (PDT)
In-Reply-To: <83h9apdv76.fsf@HIDDEN>
References: <CAPM58oixb1qR=iAQ9O+ZYAJObYohWBNCTV_5rBajzY60LArjOg@HIDDEN>
 <CAM-tV--EuJiHpdhXba1t1ohkVkDmcOR7h2SdbCob-i1_radspQ@HIDDEN>
 <83h9apdv76.fsf@HIDDEN>
From: Noam Postavsky <npostavs@HIDDEN>
Date: Mon, 15 Aug 2016 18:19:05 -0400
X-Google-Sender-Auth: PWRuuVOTxZPtZbjX0xAdSlt98tg
Message-ID: <CAM-tV-8Xk3T0Muxp-bio4PeaUZx1Ry2yCZmmekcrh8NvS4NgSg@HIDDEN>
Subject: Re: bug#19868: #19868 25.0.50; Compilation eats buffers
To: Eli Zaretskii <eliz@HIDDEN>
Content-Type: text/plain; charset=UTF-8
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 19868
Cc: Richard Copley <rcopley@HIDDEN>, 19868 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

On Sat, Aug 13, 2016 at 2:44 AM, Eli Zaretskii <eliz@HIDDEN> wrote:
>> From: Noam Postavsky <npostavs@HIDDEN>
>> Date: Fri, 12 Aug 2016 16:47:07 -0400
>> Cc: Richard Copley <rcopley@HIDDEN>
>>
>> I reproduced this (the hanging, not the buffer eating) on Windows 10,
>> Emacs 25.1, MinGW64.  Stepping with gdb I found the the hang occurs in
>> sys_close where it calls _close (fd).  This is being called from
>> deactivate_process:
>>
>>   for (i = 0; i < PROCESS_OPEN_FDS; i++)
>>     close_process_fd (&p->open_fd[i]); // <-- when i == 2
>
> Does it hang in the _close call itself, or somewhere else?

It's in the _close call itself.

>
> And what is the value of fd?
>
> Can you instrument the relevant code with printf's and see this
> happening without stepping through the code with GDB?  Doing the
> latter might change the timing of the calls, so we might be trying to
> use file descriptors when the process (cmdproxy) is already dead, and
> so the other end of the pipe no longer exists.

I put fprintf+fflush before close_process_fd and around _close:

close_process_fd(-1[i = 0])
close_process_fd(4[i = 1])
going to _close(4)...done _close(4)
close_process_fd(5[i = 2])
going to _close(5)... // here Emacs hangs until I kill bug.exe




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#19868; Package emacs. Full text available.

Message received at 19868 <at> debbugs.gnu.org:


Received: (at 19868) by debbugs.gnu.org; 13 Aug 2016 06:44:50 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Aug 13 02:44:50 2016
Received: from localhost ([127.0.0.1]:55648 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1bYSgb-0006bs-QH
	for submit <at> debbugs.gnu.org; Sat, 13 Aug 2016 02:44:49 -0400
Received: from eggs.gnu.org ([208.118.235.92]:44345)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1bYSgZ-0006bg-NM
 for 19868 <at> debbugs.gnu.org; Sat, 13 Aug 2016 02:44:47 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <eliz@HIDDEN>) id 1bYSgT-0005vp-IN
 for 19868 <at> debbugs.gnu.org; Sat, 13 Aug 2016 02:44:42 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.4 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD
 autolearn=disabled version=3.3.2
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:58851)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1bYSgP-0005vH-OA; Sat, 13 Aug 2016 02:44:37 -0400
Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4389
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1bYSgN-0005qA-9E; Sat, 13 Aug 2016 02:44:35 -0400
Date: Sat, 13 Aug 2016 09:44:29 +0300
Message-Id: <83h9apdv76.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Noam Postavsky <npostavs@HIDDEN>
In-reply-to: <CAM-tV--EuJiHpdhXba1t1ohkVkDmcOR7h2SdbCob-i1_radspQ@HIDDEN>
 (message from Noam Postavsky on Fri, 12 Aug 2016 16:47:07 -0400)
Subject: Re: bug#19868: #19868 25.0.50; Compilation eats buffers
References: <CAPM58oixb1qR=iAQ9O+ZYAJObYohWBNCTV_5rBajzY60LArjOg@HIDDEN>
 <CAM-tV--EuJiHpdhXba1t1ohkVkDmcOR7h2SdbCob-i1_radspQ@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2001:4830:134:3::e
X-Spam-Score: -5.5 (-----)
X-Debbugs-Envelope-To: 19868
Cc: rcopley@HIDDEN, 19868 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Reply-To: Eli Zaretskii <eliz@HIDDEN>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.5 (-----)

> From: Noam Postavsky <npostavs@HIDDEN>
> Date: Fri, 12 Aug 2016 16:47:07 -0400
> Cc: Richard Copley <rcopley@HIDDEN>
> 
> I reproduced this (the hanging, not the buffer eating) on Windows 10,
> Emacs 25.1, MinGW64.  Stepping with gdb I found the the hang occurs in
> sys_close where it calls _close (fd).  This is being called from
> deactivate_process:
> 
>   for (i = 0; i < PROCESS_OPEN_FDS; i++)
>     close_process_fd (&p->open_fd[i]); // <-- when i == 2

Does it hang in the _close call itself, or somewhere else?

And what is the value of fd?

Can you instrument the relevant code with printf's and see this
happening without stepping through the code with GDB?  Doing the
latter might change the timing of the calls, so we might be trying to
use file descriptors when the process (cmdproxy) is already dead, and
so the other end of the pipe no longer exists.

In any case, this is a tricky situation, because we kill the shell,
not the program it runs.  When the program run from the shell was
built with -mwindows, it is detached from the shell, and the various
Emacs facilities that try to kill subprocesses are likely to fail in
exciting ways.

IOW, running -mwindows programs from the likes of "M-x compile" is not
really supported on MS-Windows, I think.  Of course, if we can figure
out how to avoid the hang in this case, we should.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#19868; Package emacs. Full text available.
bug Marked as found in versions 25.1. Request was from Noam Postavsky <npostavs@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
Changed bug title to '[w32] restarting compilation hangs trying to kill process' from '25.0.50; Compilation eats buffers' Request was from Noam Postavsky <npostavs@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 19868 <at> debbugs.gnu.org:


Received: (at 19868) by debbugs.gnu.org; 12 Aug 2016 20:47:15 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Aug 12 16:47:15 2016
Received: from localhost ([127.0.0.1]:55462 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1bYJMJ-0002YF-7a
	for submit <at> debbugs.gnu.org; Fri, 12 Aug 2016 16:47:15 -0400
Received: from mail-oi0-f52.google.com ([209.85.218.52]:34891)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <npostavs@HIDDEN>) id 1bYJMH-0002Xx-Tm
 for 19868 <at> debbugs.gnu.org; Fri, 12 Aug 2016 16:47:14 -0400
Received: by mail-oi0-f52.google.com with SMTP id 4so49381861oih.2
 for <19868 <at> debbugs.gnu.org>; Fri, 12 Aug 2016 13:47:13 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=mime-version:sender:from:date:message-id:subject:to:cc;
 bh=m5ORyNPW/QcR48f0Y3itTg5sUPQ42wzeVSSdgYecs0I=;
 b=w6KU5EGYNBVbPUFj/BFsB8nsP0OEpGJ3JMDk3HmJUr3fx2oih3dtKMXu5ir3s5EGZl
 Id2G7wU0mo3Th+Ex/oKznWtfmoUH7sLARQHT1e2Qk+lLgzZeVrU87GfzYevCFoUarnba
 imKQy+h557UnOKxSWPQSsF4sY//SjI0HLXJF1tEOJH1xNFYE4+blMJZvFSbKhFPwJTxi
 zpz+jDcB9f6ma5FGGJAPV+2p+uxpY69Poam/z9cP2nAiyzRk3q5DAFeRMjIDNXYvPpF1
 jy96FV56zl2GDhqvYA8WuGzDNDNCZ0mhzE7jWJUvjM1sCo6p8qAAeBXirtvrXShBVzDm
 GSJg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20130820;
 h=x-gm-message-state:mime-version:sender:from:date:message-id:subject
 :to:cc;
 bh=m5ORyNPW/QcR48f0Y3itTg5sUPQ42wzeVSSdgYecs0I=;
 b=Hv6TGvuucJabWgSnKyb9g8XXt5oG6onFz2StLYEo1DejDldp3yzw9Vy+q88nLtdAUt
 FubSYtbHGrpR0aCC8AsvOENJvzmsR0wxKRBTkABmvIMBkoZRMcLlp1x8VNUa1HO4LfLr
 Mp7p+nN9y2rQaqpjyuhnPBDsZE7KswK4WtQ3zaV/XDRAIkVV38z4M2mNmAtpxCrJNrbU
 MnClVHqF+B62vE4Ho237WrsUA3KjRz6HoxBlFYz7XdDniY85sEzfpraBvv3UYyIcBifX
 VvKlywvMuCtsqhaZsC5MXngrM9P+m2uy57JVE7vm78H8jMBKyFe+wGCBmZEai+cahRM0
 5DLQ==
X-Gm-Message-State: AEkooutnhtfnBbTEsoaqEbvc2jCxg6AZOK3hH2RPM8OybVFbZ9RLvH11jh6p8d6sbfUz9dqr+bEmzNsKQlJP2w==
X-Received: by 10.202.245.88 with SMTP id t85mr8111280oih.202.1471034828223;
 Fri, 12 Aug 2016 13:47:08 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.157.7.200 with HTTP; Fri, 12 Aug 2016 13:47:07 -0700 (PDT)
From: Noam Postavsky <npostavs@HIDDEN>
Date: Fri, 12 Aug 2016 16:47:07 -0400
X-Google-Sender-Auth: 1uoc_YZHdmj63VJUDiB3bpvlRKs
Message-ID: <CAM-tV--EuJiHpdhXba1t1ohkVkDmcOR7h2SdbCob-i1_radspQ@HIDDEN>
Subject: #19868 25.0.50; Compilation eats buffers
To: 19868 <at> debbugs.gnu.org
Content-Type: text/plain; charset=UTF-8
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 19868
Cc: Richard Copley <rcopley@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

retitle 19868 [w32] restarting compilation hangs trying to kill process
found 19868 25.1
quit

> I tried this on Windows 7 and XP, and both show the same correct
> behavior.
>
> It could be that what you see is specific to Windows 8, or to 64-bit
> programs, or to how MinGW64 sets up the process in its startup code (I
> used MinGW32).
>
> You say above that Emacs hangs inside the delete-process call -- can
> you show a backtrace in that state, preferably from an unoptimized
> build?  I'd like to see where exactly it hangs.

I reproduced this (the hanging, not the buffer eating) on Windows 10,
Emacs 25.1, MinGW64.  Stepping with gdb I found the the hang occurs in
sys_close where it calls _close (fd).  This is being called from
deactivate_process:

  for (i = 0; i < PROCESS_OPEN_FDS; i++)
    close_process_fd (&p->open_fd[i]); // <-- when i == 2




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#19868; Package emacs. Full text available.
Removed tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 19868 <at> debbugs.gnu.org:


Received: (at 19868) by debbugs.gnu.org; 17 Feb 2015 00:25:50 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Feb 16 19:25:50 2015
Received: from localhost ([127.0.0.1]:45731 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1YNVz3-0007Zb-Ej
	for submit <at> debbugs.gnu.org; Mon, 16 Feb 2015 19:25:50 -0500
Received: from mail-yk0-f173.google.com ([209.85.160.173]:41063)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <rcopley@HIDDEN>) id 1YNVz0-0007ZE-U1
 for 19868 <at> debbugs.gnu.org; Mon, 16 Feb 2015 19:25:48 -0500
Received: by mail-yk0-f173.google.com with SMTP id 19so14542008ykq.4
 for <19868 <at> debbugs.gnu.org>; Mon, 16 Feb 2015 16:25:41 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=mime-version:in-reply-to:references:date:message-id:subject:from:to
 :cc:content-type;
 bh=w64/QOwNb4gT3eIgm3RF0MZHJuQb1ir6pDHdgCqmKy0=;
 b=OwMyHrPyAc/dsPPtExVfprWFp5yaUjPmy56D09VRfQTa5ZYrvw4DxqFTWws/xKmfNX
 J7wQNnLbM+TPsTPgbO+/ifoqEV/R/AQTUH9SBOQaWz8fk2nvDYG+6ANJ2htPOI2qICYJ
 WdAUB2GWnaAM1K/5YgkiBILH73aXt4u24xviu5xHqhAJ/IDp88rAXo37XUEySiFeDuyd
 UHhZ/yFVEgmgiemnW5ihTW32MY+VblFp46z71ecTOl+4BmpD+QZq+eZD/aGfLZ+oYS0v
 g99IX+ChArAghU72xQ5AmlQ7o9ao4BczT9yfyrw6ehc2pQeMJPYMbWV5TZ0RRBa/U+lD
 VFhA==
MIME-Version: 1.0
X-Received: by 10.236.1.38 with SMTP id 26mr618173yhc.163.1424132741147; Mon,
 16 Feb 2015 16:25:41 -0800 (PST)
Received: by 10.170.63.135 with HTTP; Mon, 16 Feb 2015 16:25:41 -0800 (PST)
In-Reply-To: <83k2zjukmr.fsf@HIDDEN>
References: <CAPM58oixb1qR=iAQ9O+ZYAJObYohWBNCTV_5rBajzY60LArjOg@HIDDEN>
 <83k2zjukmr.fsf@HIDDEN>
Date: Tue, 17 Feb 2015 00:25:41 +0000
Message-ID: <CAPM58oiOa8_wBO=R8q+yESmjX3bUgEam3ujA59D35iBv4xaDFg@HIDDEN>
Subject: Re: bug#19868: 25.0.50; Compilation eats buffers
From: Richard Copley <rcopley@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Content-Type: multipart/mixed; boundary=001a1132e9ca271079050f3dbe37
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 19868
Cc: 19868 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

--001a1132e9ca271079050f3dbe37
Content-Type: text/plain; charset=UTF-8

On 15 February 2015 at 17:53, Eli Zaretskii <eliz@HIDDEN> wrote:
>>
>> On Windows, with MinGW gcc.exe installed and on the path, save a file
>> "c:\temp\bug.c" containing these two lines:
>>
>> #include <windows.h>
>> int main () { Sleep (5000); }
>>
>> Compile with "M-x compile RET", supplying this compile-command:
>> gcc -mwindows -o bug.exe bug.c && bug.exe
>>
>> Within 5 seconds, execute "M-x compile" again and answer "yes" to kill
>> the existing process. The process doesn't respond to the signal,
>
> There are no signals on Windows.  Emacs simulates SIGINT and SIGKILL
> by other means, see sys_kill.
>
>> and Emacs hangs inside the call to `delete-process' in
>> `compilation-start'.
>>
>> When the process does eventually die and the `delete-process' call
>> returns, the current buffer has changed from *compilation* to the buffer
>> from which the compilation was launched (which will often be a source
>> code buffer).
>>
>> `compilation-start' then proceeds to erase the buffer and discard its
>> undo history. This is potentially very bad news for the user's source
>> code.
>
> I cannot reproduce this: for me, Emacs doesn't hang at all.  As soon
> as I answer YES to the kill process question, I see in Process
> Explorer that cmdproxy, cmd.exe, and the program that sleeps are all
> terminated, and the new compilation begins.  Like I'd expect.
>
> If I instrument the sys_kill function, I see that we first send a
> simulated Ctrl-C keystroke to the process, and a second afterwards
> terminate it forcefully, which is consistent with the calls to
> interrupt-process and delete-process in compilation-start.
>
> I tried this on Windows 7 and XP, and both show the same correct
> behavior.
>
> It could be that what you see is specific to Windows 8, or to 64-bit
> programs, or to how MinGW64 sets up the process in its startup code (I
> used MinGW32).

I see my problem no matter what compiler I use to build "bug.exe"
(old-fashioned MinGW32, and both the 32- and 64-bit MinGW-W64
GCC 4.9.2 toolchains). I'll try on Windows 7, and if I get time,
with 32-bit Emacs.

when building "bug.exe" with good old MinGW and with
both the 32- and 64-bit toolchains from MinGW-W64. I haven't tried it
with a 32-bit Emacs. I will try that, and on Windows 7, when I have time.

> You say above that Emacs hangs inside the delete-process call -- can
> you show a backtrace in that state, preferably from an unoptimized
> build?  I'd like to see where exactly it hangs.

I tried to work out how to control the optimization level when building
Emacs but I'm stumped. How do you do that? (If there are configure
flags, can they be mentioned in "configure --help"?)

FWIW, attached is the result of "thread apply all bt full" after typing
Ctrl-C in GDB while debugging an optimized Emacs that was hanging.
Looks like I'm doing something horribly wrong. Sorry about that.

> Also, is the -mwindows compiler switch a factor here, i.e. does the
> problem happen with a console application that sleeps?

Yes, -mwindows is needed. Console applications die as expected.

> (I'm not sure it should matter, because the process that we are
> killing is cmdproxy, not the program you compiled.)

Then I don't understand why a GUI program would ever die in response
to that. (Would runemacs.exe?) Really I didn't expect it to; that's
not the bug I was reporting (though I'm happy to help fix it if it is
a bug).

> In addition, can you look at the relevant processes in Process
> Explorer and seed if any of them are killed when you answer YES?

"cmdproxy.exe" and its descendants "cmd.exe" and "conhost.exe"
are killed, leaving just the orphaned "bug.exe".

>> I'm not sure where the buffer gets changed (presumably in a sentinel,
>> but `compilation-sentinel' looks OK to me).
>
> Run all this under GDB, put a breakpoint on a low-level function that
> switches buffers (e.g., in set_buffer_internal), and you will see in
> the backtrace which Lisp function triggers that.  It is advisable to
> manually load compile.el in advance, so that xbacktrace shows more
> details.

I'm sorry to say that, mysteriously, I can no longer reproduce the
effect where the current buffer changes during the `delete-process'
call and causes work to be lost. I can't see what I'm doing differently.
I might have to get back to you another time.

>> In GNU Emacs 25.0.50.1 (x86_64-w64-mingw32)
>>  of 2015-02-09 on MACHINE
>> Repository revision: 21d1f8b85eec8fc1f87bb30398e449f6b20b6ecc
>> Windowing system distributor `Microsoft Corp.', version 6.3.9600
>> Configured using:
>>  `configure --prefix /c/emacs/emacs-20150209-192633
>>  --disable-dependency-tracking
>>  --enable-locallisppath=%emacs_dir%/../site-lisp --with-wide-int
>>  --build=x86_64-w64-mingw32 'CPPFLAGS=-I G:/usr/include -I
>>  C:/GnuWin32/include' 'LDFLAGS=-L G:/usr/lib -L C:/GnuWin32/lib''
>
> Any idea why you are building --with-wide-int?  It's supposed to be a
> no-op in a 64-bit build.  (This is not related to the bug.)

I'll remove it, thanks.

--001a1132e9ca271079050f3dbe37
Content-Type: text/plain; charset=US-ASCII; name="bt.txt"
Content-Disposition: attachment; filename="bt.txt"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_i68ho4rl0

UHJvZ3JhbSByZWNlaXZlZCBzaWduYWwgU0lHSU5ULCBJbnRlcnJ1cHQuDQpbU3dpdGNoaW5nIHRv
IFRocmVhZCA4NTY4LjB4MTUxOF0NCjB4MDAwMDdmZjljNWNjMzIzMyBpbiBSZWdMb2FkTVVJU3Ry
aW5nQSAoKQ0KICAgZnJvbSBDOlxXSU5ET1dTXHN5c3RlbTMyXEtlcm5lbEJhc2UuZGxsDQooZ2Ri
KSB0aHJlYWQgYXBwbHkgYWxsIGJ0IGZ1bGwNCg0KVG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xIChUaHJlYWQg
ODU2OC4weDEwYzgpOg0KIzAgIDB4MDAwMDdmZjljOGFhMGUxYSBpbiBudGRsbCFad1dhaXRGb3JT
aW5nbGVPYmplY3QgKCkNCiAgIGZyb20gQzpcV0lORE9XU1xTWVNURU0zMlxudGRsbC5kbGwNCk5v
IHN5bWJvbCB0YWJsZSBpbmZvIGF2YWlsYWJsZS4NCiMxICAweDAwMDA3ZmY5YzhhNDlhODUgaW4g
bnRkbGwhUnRsSW1hZ2VOdEhlYWRlckV4ICgpDQogICBmcm9tIEM6XFdJTkRPV1NcU1lTVEVNMzJc
bnRkbGwuZGxsDQpObyBzeW1ib2wgdGFibGUgaW5mbyBhdmFpbGFibGUuDQojMiAgMHgwMDAwN2Zm
OWM4YTQ3ZjQ0IGluIG50ZGxsIVJ0bEVudGVyQ3JpdGljYWxTZWN0aW9uICgpDQogICBmcm9tIEM6
XFdJTkRPV1NcU1lTVEVNMzJcbnRkbGwuZGxsDQpObyBzeW1ib2wgdGFibGUgaW5mbyBhdmFpbGFi
bGUuDQpCYWNrdHJhY2Ugc3RvcHBlZDogcHJldmlvdXMgZnJhbWUgaW5uZXIgdG8gdGhpcyBmcmFt
ZSAoY29ycnVwdCBzdGFjaz8pDQooZ2RiKQ0K
--001a1132e9ca271079050f3dbe37--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#19868; Package emacs. Full text available.

Message received at 19868 <at> debbugs.gnu.org:


Received: (at 19868) by debbugs.gnu.org; 15 Feb 2015 17:53:22 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 15 12:53:22 2015
Received: from localhost ([127.0.0.1]:44897 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1YN3Ni-0005js-5y
	for submit <at> debbugs.gnu.org; Sun, 15 Feb 2015 12:53:22 -0500
Received: from mtaout28.012.net.il ([80.179.55.184]:33066)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <eliz@HIDDEN>) id 1YN3Ne-0005jd-Uf
 for 19868 <at> debbugs.gnu.org; Sun, 15 Feb 2015 12:53:20 -0500
Received: from conversion-daemon.mtaout28.012.net.il by mtaout28.012.net.il
 (HyperSendmail v2007.08) id <0NJT00800QQTMI00@HIDDEN> for
 19868 <at> debbugs.gnu.org; Sun, 15 Feb 2015 19:51:32 +0200 (IST)
Received: from HOME-C4E4A596F7 ([87.69.4.28]) by mtaout28.012.net.il
 (HyperSendmail v2007.08) with ESMTPA id
 <0NJT006X3QXW6X20@HIDDEN>; Sun, 15 Feb 2015 19:51:32 +0200 (IST)
Date: Sun, 15 Feb 2015 19:53:16 +0200
From: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#19868: 25.0.50; Compilation eats buffers
In-reply-to: <CAPM58oixb1qR=iAQ9O+ZYAJObYohWBNCTV_5rBajzY60LArjOg@HIDDEN>
X-012-Sender: halo1@HIDDEN
To: Richard Copley <rcopley@HIDDEN>
Message-id: <83k2zjukmr.fsf@HIDDEN>
References: <CAPM58oixb1qR=iAQ9O+ZYAJObYohWBNCTV_5rBajzY60LArjOg@HIDDEN>
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 19868
Cc: 19868 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
Reply-To: Eli Zaretskii <eliz@HIDDEN>
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)

> Date: Sat, 14 Feb 2015 19:30:45 +0000
> From: Richard Copley <rcopley@HIDDEN>
> 
> On Windows, with MinGW gcc.exe installed and on the path, save a file
> "c:\temp\bug.c" containing these two lines:
> 
> #include <windows.h>
> int main () { Sleep (5000); }
> 
> Compile with "M-x compile RET", supplying this compile-command:
> gcc -mwindows -o bug.exe bug.c && bug.exe
> 
> Within 5 seconds, execute "M-x compile" again and answer "yes" to kill
> the existing process. The process doesn't respond to the signal,

There are no signals on Windows.  Emacs simulates SIGINT and SIGKILL
by other means, see sys_kill.

> and Emacs hangs inside the call to `delete-process' in
> `compilation-start'.
> 
> When the process does eventually die and the `delete-process' call
> returns, the current buffer has changed from *compilation* to the buffer
> from which the compilation was launched (which will often be a source
> code buffer).
> 
> `compilation-start' then proceeds to erase the buffer and discard its
> undo history. This is potentially very bad news for the user's source
> code.

I cannot reproduce this: for me, Emacs doesn't hang at all.  As soon
as I answer YES to the kill process question, I see in Process
Explorer that cmdproxy, cmd.exe, and the program that sleeps are all
terminated, and the new compilation begins.  Like I'd expect.

If I instrument the sys_kill function, I see that we first send a
simulated Ctrl-C keystroke to the process, and a second afterwards
terminate it forcefully, which is consistent with the calls to
interrupt-process and delete-process in compilation-start.

I tried this on Windows 7 and XP, and both show the same correct
behavior.

It could be that what you see is specific to Windows 8, or to 64-bit
programs, or to how MinGW64 sets up the process in its startup code (I
used MinGW32).

You say above that Emacs hangs inside the delete-process call -- can
you show a backtrace in that state, preferably from an unoptimized
build?  I'd like to see where exactly it hangs.

Also, is the -mwindows compiler switch a factor here, i.e. does the
problem happen with a console application that sleeps?  (I'm not sure
it should matter, because the process that we are killing is cmdproxy,
not the program you compiled.)

In addition, can you look at the relevant processes in Process
Explorer and seed if any of them are killed when you answer YES?

> I'm not sure where the buffer gets changed (presumably in a sentinel,
> but `compilation-sentinel' looks OK to me).

Run all this under GDB, put a breakpoint on a low-level function that
switches buffers (e.g., in set_buffer_internal), and you will see in
the backtrace which Lisp function triggers that.  It is advisable to
manually load compile.el in advance, so that xbacktrace shows more
details.

> In GNU Emacs 25.0.50.1 (x86_64-w64-mingw32)
>  of 2015-02-09 on MACHINE
> Repository revision: 21d1f8b85eec8fc1f87bb30398e449f6b20b6ecc
> Windowing system distributor `Microsoft Corp.', version 6.3.9600
> Configured using:
>  `configure --prefix /c/emacs/emacs-20150209-192633
>  --disable-dependency-tracking
>  --enable-locallisppath=%emacs_dir%/../site-lisp --with-wide-int
>  --build=x86_64-w64-mingw32 'CPPFLAGS=-I G:/usr/include -I
>  C:/GnuWin32/include' 'LDFLAGS=-L G:/usr/lib -L C:/GnuWin32/lib''

Any idea why you are building --with-wide-int?  It's supposed to be a
no-op in a 64-bit build.  (This is not related to the bug.)




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#19868; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 14 Feb 2015 19:31:01 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Feb 14 14:31:01 2015
Received: from localhost ([127.0.0.1]:44185 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1YMiQf-0007QN-2U
	for submit <at> debbugs.gnu.org; Sat, 14 Feb 2015 14:31:01 -0500
Received: from eggs.gnu.org ([208.118.235.92]:35100)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <rcopley@HIDDEN>) id 1YMiQd-0007QC-JH
 for submit <at> debbugs.gnu.org; Sat, 14 Feb 2015 14:30:59 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <rcopley@HIDDEN>) id 1YMiQV-0007pU-KV
 for submit <at> debbugs.gnu.org; Sat, 14 Feb 2015 14:30:54 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM,
 T_DKIM_INVALID autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:50030)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <rcopley@HIDDEN>) id 1YMiQV-0007pO-Hq
 for submit <at> debbugs.gnu.org; Sat, 14 Feb 2015 14:30:51 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:36698)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <rcopley@HIDDEN>) id 1YMiQT-0004HJ-Lf
 for bug-gnu-emacs@HIDDEN; Sat, 14 Feb 2015 14:30:51 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <rcopley@HIDDEN>) id 1YMiQQ-0007ky-Sb
 for bug-gnu-emacs@HIDDEN; Sat, 14 Feb 2015 14:30:49 -0500
Received: from mail-yk0-x229.google.com ([2607:f8b0:4002:c07::229]:38744)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <rcopley@HIDDEN>) id 1YMiQQ-0007ki-OL
 for bug-gnu-emacs@HIDDEN; Sat, 14 Feb 2015 14:30:46 -0500
Received: by mail-yk0-f169.google.com with SMTP id 79so10377176ykr.0
 for <bug-gnu-emacs@HIDDEN>; Sat, 14 Feb 2015 11:30:46 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=mime-version:date:message-id:subject:from:to:content-type;
 bh=JafEGS2DUJ02CpEJ/v6yIZ+jpu66tVznLbRsRDne0so=;
 b=e7MDGSAQZ/tgYJymFCZ1spX+SEqXuDw3ek4oIZxaET9PllRCJAPSrd0s0qMuafELY/
 OOlhkRtZu4Sf0uXytaF9eDQHpYo1fjs+3RFWxSqbZndH0Xq9Mg0iAV7ZG1jtuDJK4aUd
 GP+1O73IMNpQIo2H5z4TPMzr12PLbxHYTWCv88955Qgc7holAeMA1syKPK+Hv5OFMJwh
 AGwa+XElidwwjMspS80dOF4plML5YPLtdkw4jC8RqN3gcpsbKx+cBYEH+bdWxVNEXnIN
 qbO2CjZ6AievUBs4auzs9pGPbfDOrLWZmCrlaEH8kl9KB4lxanvrBwOfjE05UaqZYfYH
 Tmvw==
MIME-Version: 1.0
X-Received: by 10.236.38.66 with SMTP id z42mr12219054yha.151.1423942245981;
 Sat, 14 Feb 2015 11:30:45 -0800 (PST)
Received: by 10.170.63.135 with HTTP; Sat, 14 Feb 2015 11:30:45 -0800 (PST)
Date: Sat, 14 Feb 2015 19:30:45 +0000
Message-ID: <CAPM58oixb1qR=iAQ9O+ZYAJObYohWBNCTV_5rBajzY60LArjOg@HIDDEN>
Subject: 25.0.50; Compilation eats buffers
From: Richard Copley <rcopley@HIDDEN>
To: "bug-gnu-emacs@HIDDEN" <bug-gnu-emacs@HIDDEN>
Content-Type: text/plain; charset=UTF-8
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -4.0 (----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -4.0 (----)

On Windows, with MinGW gcc.exe installed and on the path, save a file
"c:\temp\bug.c" containing these two lines:

#include <windows.h>
int main () { Sleep (5000); }

Compile with "M-x compile RET", supplying this compile-command:
gcc -mwindows -o bug.exe bug.c && bug.exe

Within 5 seconds, execute "M-x compile" again and answer "yes" to kill
the existing process. The process doesn't respond to the signal,
and Emacs hangs inside the call to `delete-process' in
`compilation-start'.

When the process does eventually die and the `delete-process' call
returns, the current buffer has changed from *compilation* to the buffer
from which the compilation was launched (which will often be a source
code buffer).

`compilation-start' then proceeds to erase the buffer and discard its
undo history. This is potentially very bad news for the user's source
code.

I'm not sure where the buffer gets changed (presumably in a sentinel,
but `compilation-sentinel' looks OK to me). Wrapping the
`delete-process' call inside a `save-excursion' fixes (or hides?) the
problem.


In GNU Emacs 25.0.50.1 (x86_64-w64-mingw32)
 of 2015-02-09 on MACHINE
Repository revision: 21d1f8b85eec8fc1f87bb30398e449f6b20b6ecc
Windowing system distributor `Microsoft Corp.', version 6.3.9600
Configured using:
 `configure --prefix /c/emacs/emacs-20150209-192633
 --disable-dependency-tracking
 --enable-locallisppath=%emacs_dir%/../site-lisp --with-wide-int
 --build=x86_64-w64-mingw32 'CPPFLAGS=-I G:/usr/include -I
 C:/GnuWin32/include' 'LDFLAGS=-L G:/usr/lib -L C:/GnuWin32/lib''

Configured features:
XPM JPEG TIFF GIF PNG SOUND NOTIFY ACL GNUTLS LIBXML2 ZLIB




Acknowledgement sent to Richard Copley <rcopley@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#19868; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 15 Aug 2016 22:30:02 UTC

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