From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#13065: Bug in x-file-dialog with GetOpenFileName Date: Wed, 16 Jan 2013 20:54:05 +0200 Message-ID: <83fw217ycy.fsf@gnu.org> References: <83liddr5u8.fsf@gnu.org> <87pq1fhlbo.fsf@gnu.org> <83r4lvgydf.fsf@gnu.org> <87fw251bzq.fsf@gnu.org> <83boctrqg2.fsf@gnu.org> <83wqve8gsz.fsf@gnu.org> <87sj61uxjc.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1358362480 2478 80.91.229.3 (16 Jan 2013 18:54:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 16 Jan 2013 18:54:40 +0000 (UTC) Cc: 13065@debbugs.gnu.org, duyanning@gmail.com To: Jason Rumney Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jan 16 19:54:57 2013 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 1TvY8P-0008TV-DB for geb-bug-gnu-emacs@m.gmane.org; Wed, 16 Jan 2013 19:54:49 +0100 Original-Received: from localhost ([::1]:44536 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvY89-000736-1e for geb-bug-gnu-emacs@m.gmane.org; Wed, 16 Jan 2013 13:54:33 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:47848) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvY84-000705-VJ for bug-gnu-emacs@gnu.org; Wed, 16 Jan 2013 13:54:31 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TvY82-0007cK-Qj for bug-gnu-emacs@gnu.org; Wed, 16 Jan 2013 13:54:28 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:58363) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvY82-0007cE-NE for bug-gnu-emacs@gnu.org; Wed, 16 Jan 2013 13:54:26 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TvY8c-00020u-Je for bug-gnu-emacs@gnu.org; Wed, 16 Jan 2013 13:55:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 16 Jan 2013 18:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13065 X-GNU-PR-Package: emacs,w32 X-GNU-PR-Keywords: Original-Received: via spool by 13065-submit@debbugs.gnu.org id=B13065.13583624977728 (code B ref 13065); Wed, 16 Jan 2013 18:55:02 +0000 Original-Received: (at 13065) by debbugs.gnu.org; 16 Jan 2013 18:54:57 +0000 Original-Received: from localhost ([127.0.0.1]:35593 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TvY8V-00020a-NJ for submit@debbugs.gnu.org; Wed, 16 Jan 2013 13:54:56 -0500 Original-Received: from mtaout23.012.net.il ([80.179.55.175]:54622) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TvY8S-00020Q-3Y for 13065@debbugs.gnu.org; Wed, 16 Jan 2013 13:54:54 -0500 Original-Received: from conversion-daemon.a-mtaout23.012.net.il by a-mtaout23.012.net.il (HyperSendmail v2007.08) id <0MGQ00400F5HG100@a-mtaout23.012.net.il> for 13065@debbugs.gnu.org; Wed, 16 Jan 2013 20:54:11 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout23.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MGQ00423F62AL50@a-mtaout23.012.net.il>; Wed, 16 Jan 2013 20:54:03 +0200 (IST) In-reply-to: <87sj61uxjc.fsf@gnu.org> X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.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:69874 Archived-At: > From: Jason Rumney > Cc: 13065@debbugs.gnu.org, duyanning@gmail.com > Date: Wed, 16 Jan 2013 20:23:19 +0800 > > Eli Zaretskii writes: > > > Failing that, I'm beginning to think that the problem is elsewhere in > > Emacs. But what could that be? Is it possible that one of our > > message pumps somehow interferes with the dialog interaction, e.g., by > > intercepting some of the messages that were supposed to wind up in our > > hook procedure? > > That seems like the most likely candidate. Do you have Spy++, or an > equivalent that can show the Windows messages going to and from your > sample program and the Open/Save dialog in Emacs? > > > Could it be due to the fact that our main message > > pump uses Unicode APIs, while the file selector uses ANSI APIs? > > Since that's quite a recent change, it should be easy to test by trying > an older version of Emacs on Windows 7. Yes, I also had the idea to check older versions. It was a good idea, because it allowed me to find the reason for the problem. It wasn't an interference between message pumps. It was memory. Here are the details. In preparation for Emacs 24.1, we changed the amount of memory we reserve at startup: where Emacs 23 asked the OS to reserve 256MB, we now try to reserve as much as possible, starting with 2GB and gradually decreasing the amount until the OS grants the request. On XP, we typically end up with 1.1 to 1.5GB, but on Windows 7 we get more: about 1.8GB. Now, when we launch the file selector dialog, Windows starts several threads in our process to support that (I see 4 threads on XP and between 6 and 7 on Windows 7). My guess is that with so much of the address space reserved, these threads fail to reserve enough memory for themselves, probably for their stack (which is set to 8MB in Emacs), and misbehave as result of that. We already had a similar problem with the threads we ourselves create to support subprocesses, see http://lists.gnu.org/archive/html/emacs-devel/2012-03/msg00119.html. In that case, we were able to fix the problem without decreasing the amount of memory we ask at startup. But here, these are threads that are started outside our control, so a similar solution is not possible, AFAIU. So, unless someone has a better idea, I will soon commit to the emacs-24 branch the patch shown below. It fixes the problem on Windows 7 and does not affect XP in any visible way. The initial amount of memory to reserve was found by trial and error. (After this patch, the original recipe still doesn't work: you need to type "abc" _after_ clicking "Desktop". But the same happens with Emacs 23, so I guess this is just a minor change in behavior of Windows 7.) === modified file 'src/w32heap.c' --- src/w32heap.c 2013-01-01 09:11:05 +0000 +++ src/w32heap.c 2013-01-16 18:34:38 +0000 @@ -98,7 +98,11 @@ allocate_heap (void) #ifdef _WIN64 size_t size = 0x4000000000i64; /* start by asking for 32GB */ #else - size_t size = 0x80000000; /* start by asking for 2GB */ + /* We used to start with 2GB here, but on Windows 7 that would leave + too little room in the address space for threads started by + Windows on our behalf, e.g. when we pop up the file selection + dialog. */ + size_t size = 0x68000000; /* start by asking for 1.7GB */ #endif void *ptr = NULL;