From unknown Sat Jun 21 10:37:45 2025 X-Loop: help-debbugs@gnu.org Subject: bug#78846: Emacs hangs non-deterministically when eglot and clangd are used Resent-From: "admin@sonictk.com" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 20 Jun 2025 05:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 78846 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 78846@debbugs.gnu.org X-Debbugs-Original-To: "bug-gnu-emacs@gnu.org" Received: via spool by submit@debbugs.gnu.org id=B.17503961662330 (code B ref -1); Fri, 20 Jun 2025 05:10:02 +0000 Received: (at submit) by debbugs.gnu.org; 20 Jun 2025 05:09:26 +0000 Received: from localhost ([127.0.0.1]:43986 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uSU0E-0000bT-3t for submit@debbugs.gnu.org; Fri, 20 Jun 2025 01:09:26 -0400 Received: from lists.gnu.org ([2001:470:142::17]:56346) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uSU0B-0000aT-F5 for submit@debbugs.gnu.org; Fri, 20 Jun 2025 01:09:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uSU03-0000Hn-Bc for bug-gnu-emacs@gnu.org; Fri, 20 Jun 2025 01:09:15 -0400 Received: from caracal.ash.relay.mailchannels.net ([23.83.222.30]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uSU00-0007yr-MF for bug-gnu-emacs@gnu.org; Fri, 20 Jun 2025 01:09:14 -0400 X-Sender-Id: dreamhost|x-authsender|admin@sonictk.com Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 638CE2C4C42 for ; Fri, 20 Jun 2025 05:09:07 +0000 (UTC) Received: from pdx1-sub0-mail-a203.dreamhost.com (trex-green-2.trex.outbound.svc.cluster.local [100.96.75.209]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 0DACE2C5DD6 for ; Fri, 20 Jun 2025 05:09:07 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1750396147; a=rsa-sha256; cv=none; b=C3naDW2KwY7YAsnrWRxkXXX5QGgpYzx/YRaWjmRCW2cMaJC5hM7g0Wbi8iFeO/lkCpX+Vx 75O/ce+/e0vSlfspaisxPK9xRF/6cKwN48Bt+IoiDp4/QWFmvlErP6cbQRwo6U6u9JVFIB Sx46edRIRw41txuinxRVRRJhTc2n4xxqK2qklPy5laK2YVgx9tacge4Avq76fd5qyF527d baOTsQIEvTjPQgYdMCSYA2M3ag5rUxfbNm2i2WbRx2CjIk8uqpGYiDEv4NcH7O3Wg8l8Hl f37Ulybs8wikuHFkQoWkyr2asIeeQ9oMVA7LZoriXt34lt3IaNE4lhO/1rHXVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1750396147; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding:dkim-signature; bh=X3ZlldxicZfMOYlxmjtdkFzYRfvpBISfqIFUpCC2KAk=; b=BX0I3isbXUzgZcT4vuqx4sYy6JYWw8NNuj1OxwkKFgWjvQ3itSGXhpjo9/r407q2F5AKIx qM1dc2ct8bUHClU0ox2BSiSWyG8nusijPV0DXO+K28KM5gh/wrJY46T9F+uWaTEuOsO56l XM9Kq9hAP4bcMOP6Aenj95udrLeNMUadCrKpB3NrW0596sM7G/jend9WMNuLkkCmDuBvfx HQ+ojMsF2jbC/HjY3fqKdqppKouXTPsQOvTyJ4wZXqtJhz1Z4oS/lC0VLX+7k1YPPdjxHu gSmFFastMJhOwfygAWtxkuqEHGYQFwL7Fi8EqJQLpwncvyWFBI5ASlH1SbsWxg== ARC-Authentication-Results: i=1; rspamd-6597f9cdc7-pqms9; auth=pass smtp.auth=dreamhost smtp.mailfrom=admin@sonictk.com X-Sender-Id: dreamhost|x-authsender|admin@sonictk.com X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|admin@sonictk.com X-MailChannels-Auth-Id: dreamhost X-Chemical-Oafish: 3486943f7e0a93e3_1750396147256_145218882 X-MC-Loop-Signature: 1750396147256:1120351296 X-MC-Ingress-Time: 1750396147256 Received: from pdx1-sub0-mail-a203.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.96.75.209 (trex/7.0.3); Fri, 20 Jun 2025 05:09:07 +0000 Received: from MN2PR20MB3133.namprd20.prod.outlook.com (unknown [52.96.64.37]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: admin@sonictk.com) by pdx1-sub0-mail-a203.dreamhost.com (Postfix) with ESMTPSA id 4bNlrL5hX3z27 for ; Thu, 19 Jun 2025 22:09:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sonictk.com; s=dreamhost; t=1750396146; bh=X3ZlldxicZfMOYlxmjtdkFzYRfvpBISfqIFUpCC2KAk=; h=From:To:Subject:Date:Content-Type:Content-Transfer-Encoding; b=FaEQvRMAMqtJSTobSld/ItMr2b/UoQ8RVfRldjHdKYYn1kHAWPbGE5lbP5H/Po99R LalVIv3Ky+z6sIhr1IAAvbBCFS6JjH5MAONhQ3Oekp379jtRTUI3odVvfZn8g1oFTi gI455rtHltk01Z1KmjVd0tZ4VfU4J/EYpowAQt6h16fRcy+J0gsn7ytPHtbvNpgZ4H SZmJonXnquZRxCqB18O4T9xFHVVk5pof8s/uVENDc7cSfIVEKgzg26J8mXaQmJtcZV 2a50lHZsOZ2Pq6nYgZs3IgjtFThGVdCgXbzmGlWyVBmUp3zBSwJW8fsHCA6j58Rzzb sxIerEGLLIITQ== From: "admin@sonictk.com" Thread-Topic: Emacs hangs non-deterministically when eglot and clangd are used Thread-Index: AQHb4aBjT5QqzDCOz0eKbpbsg4uYUg== X-MS-Exchange-MessageSentRepresentingType: 1 Date: Fri, 20 Jun 2025 05:09:06 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-Exchange-Organization-SCL: -1 X-MS-TNEF-Correlator: X-MS-Exchange-Organization-RecordReviewCfmType: 0 msip_labels: Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Received-SPF: pass client-ip=23.83.222.30; envelope-from=admin@sonictk.com; helo=caracal.ash.relay.mailchannels.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.1 (/) Hi:=0A= =0A= This has been a problem ever since as long as I can remember, but using `eg= lot`=A0with `clangd` results in Emacs sometimes just=A0hanging. I work in t= he Unreal Engine codebase, which results in some pretty massive `clangd` me= mory usage (sometimes 200+ GB) and thus response times, along with having t= o spin up multiple `clangd` servers simultaneously.=0A= =0A= As far as I can tell, Emacs can hang in cases with as little as two `clangd= ` servers spun up, but generally this problem repros more often when I have= multiple servers spun up. It usually happens on some LSP request, and it's= not always deterministic which request it is.=0A= =0A= I work on Windows, and I grabbed a callstack of Emacs's main thread when th= e hang occurs in WinDbg:=0A= =0A= ```=0A= [0x0] ntdll!NtWaitForMultipleObjects+0x14 0x3df75fdea8 0x7ffdf18abaf0= =0A= [0x1] KERNELBASE!WaitForMultipleObjectsEx+0xf0 0x3df75fdeb0 0x7ffdf18= ab9ee =0A= [0x2] KERNELBASE!WaitForMultipleObjects+0xe 0x3df75fe1a0 0x7ff635a921= f7 =0A= [0x3] emacs!sys_select+0x12b7 0x3df75fe1e0 0x7ff635a1147e =0A= [0x4] emacs!really_call_select+0x5e 0x3df75fe2a0 0x7ff635a1273d =0A= [0x5] emacs!thread_select+0x9d 0x3df75fe300 0x7ff6359d9aec =0A= [0x6] emacs!wait_reading_process_output+0x111c 0x3df75fe450 0x7ff6359= db4c9 =0A= [0x7] emacs!send_process+0x269 0x3df75fe9c0 0x7ff6359dbd11 =0A= [0x8] emacs!Fprocess_send_string+0xb1 0x3df75fea70 0x7ff6359b5c5e = =0A= [0x9] emacs!exec_byte_code+0x7ee 0x3df75feab0 0x7ff63592eefe =0A= [0xa] emacs!Ffuncall+0xfe 0x3df75feb90 0x7ff63592f3a1 =0A= [0xb] emacs!Fapply+0x141 0x3df75fec20 0x7ff6359b5c5e =0A= [0xc] emacs!exec_byte_code+0x7ee 0x3df75fed00 0x7ff63592eefe =0A= [0xd] emacs!Ffuncall+0xfe 0x3df75fede0 0x7ffd967e587e =0A= [0xe] jsonrpc_e62a9c36_c0dd1fe3!F6a736f6e7270632d6e6f74696679_jsonrpc_not= ify_0+0x4e 0x3df75fee70 0x7ff63592eefe =0A= [0xf] emacs!Ffuncall+0xfe 0x3df75feed0 0x7ffd96ebc1b7 =0A= [0x10] eglot_3726620f_1a2b9d18!F65676c6f742d2d63616e63656c2d696e666c69676= 8742d6173796e632d7265717565737473_eglot__cancel_inflight_async_requests_0+0= x1a7 0x3df75fef60 0x7ff63592eefe =0A= [0x11] emacs!Ffuncall+0xfe 0x3df75ff030 0x7ffd96ec657e =0A= [0x12] eglot_3726620f_1a2b9d18!F65676c6f742d2d7072652d636f6d6d616e642d686= f6f6b_eglot__pre_command_hook_0+0x3e 0x3df75ff0c0 0x7ff63592eefe =0A= [0x13] emacs!Ffuncall+0xfe 0x3df75ff100 0x7ff635927a05 =0A= [0x14] emacs!internal_condition_case_n+0x45 0x3df75ff190 0x7ff63584f3= 84 =0A= [0x15] emacs!safe_run_hook_funcall+0xa4 0x3df75ff1d0 0x7ff635927ffb = =0A= [0x16] emacs!run_hook_with_args+0x9b 0x3df75ff260 0x7ff635868e7c = =0A= [0x17] emacs!command_loop_1+0x3cc 0x3df75ff2d0 0x7ff635927839 =0A= [0x18] emacs!internal_condition_case+0x39 0x3df75ff4b0 0x7ff63584ca56= =0A= [0x19] emacs!command_loop_2+0x26 0x3df75ff4f0 0x7ff6359277a7 =0A= [0x1a] emacs!internal_catch+0x37 0x3df75ff520 0x7ff63584c9ec =0A= [0x1b] emacs!command_loop+0x15c 0x3df75ff560 0x7ff6358571e7 =0A= [0x1c] emacs!recursive_edit_1+0x87 0x3df75ff670 0x7ff6358575e4 =0A= [0x1d] emacs!Frecursive_edit+0xe4 0x3df75ff6c0 0x7ff635aeac77 =0A= [0x1e] emacs!main+0x2787 0x3df75ff6f0 0x7ff635701318 =0A= [0x1f] emacs!__tmainCRTStartup+0x168 0x3df75ffc20 0x7ff635701426 = =0A= [0x20] emacs!mainCRTStartup+0x16 0x3df75ffc70 0x7ffdf3d37374 =0A= [0x21] KERNEL32!BaseThreadInitThunk+0x14 0x3df75ffca0 0x7ffdf3edcc91 = =0A= [0x22] ntdll!RtlUserThreadStart+0x21 0x3df75ffcd0 0x0 =0A= ```=0A= =0A= The only workaround, without killing Emacs, is to kill all `clangd.exe` pro= cesses - this usually gets Emacs unstuck after a second or so. Sometimes, t= hough, this trick doesn't work, and then the only recourse I have is to kil= l Emacs.exe entirely.=0A= =0A= I've been trying to find time on and off to debug this properly, but today = I finally gave up and decided to report this in the hope that maybe someone= will see this callstack and know immediately where the bug is.=0A= =0A= My emacs build was built from source. Version information is as follows:=0A= =0A= ```=0A= In GNU Emacs 31.0.50 (build 5, x86_64-w64-mingw32) of 2025-06-03 built=0A= on CDW-AQRHE1HHT39=0A= Repository revision: eb788fd8fd2026fa4d29b918ff95b12d8e3e0bab=0A= Repository branch: master=0A= Windowing system distributor 'Microsoft Corp.', version 10.0.19045=0A= System Description: Microsoft Windows 10 Enterprise (v10.0.2009.19045.5965)= =0A= =0A= Configured using:=0A= 'configure --without-pop --with-imagemagick=0A= --without-compress-install -without-dbus --with-gnutls=0A= --with-tree-sitter --without-gconf --with-rsvg --without-gsettings=0A= --with-mailutils --with-native-compilation --with-modules --with-xml2=0A= --with-wide-int 'CFLAGS=3D-O3 -ggdb -fno-math-errno=0A= -funsafe-math-optimizations -fno-finite-math-only -fno-trapping-math=0A= -freciprocal-math -fno-rounding-math -fno-signaling-nans=0A= -fassociative-math -fno-signed-zeros -frename-registers=0A= -funroll-loops -mtune=3Dnative -march=3Dnative -fomit-frame-pointer=0A= -fallow-store-data-races -fno-semantic-interposition=0A= -floop-parallelize-all -ftree-parallelize-loops=3D4'=0A= PKG_CONFIG_PATH=3D/mingw64/lib/pkgconfig:/mingw64/share/pkgconfig'=0A= ```=0A= =0A= I haven't been able to find an isolated test case for this to happen determ= inistically.=0A= =0A= Anyone who has ideas for me to try/look in debugging this issue, happy to g= ive them a go. I encounter this fairly frequently, so I should be able to c= atch it in action.=0A= =0A= Thanks.=0A= =0A= - Yi Liang= From unknown Sat Jun 21 10:37:45 2025 X-Loop: help-debbugs@gnu.org Subject: bug#78846: Emacs hangs non-deterministically when eglot and clangd are used Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 20 Jun 2025 07:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 78846 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: "admin@sonictk.com" Cc: 78846@debbugs.gnu.org Received: via spool by 78846-submit@debbugs.gnu.org id=B78846.17504056427320 (code B ref 78846); Fri, 20 Jun 2025 07:48:02 +0000 Received: (at 78846) by debbugs.gnu.org; 20 Jun 2025 07:47:22 +0000 Received: from localhost ([127.0.0.1]:45976 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uSWT3-0001tz-Ou for submit@debbugs.gnu.org; Fri, 20 Jun 2025 03:47:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41844) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uSWSz-0001tf-Ou for 78846@debbugs.gnu.org; Fri, 20 Jun 2025 03:47:19 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uSWSs-00033z-Il; Fri, 20 Jun 2025 03:47:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=YfU7AGSB7d28fDa0/s/IjsaruVtPEV+x2VNGEJBis8k=; b=hz+5o1rKRyUFZXQfWk69 FVRqI/8AWNsAvkf06IVWzfS2hXLluxU7VYF05Nso9AAezyvy7f1K9rA2Mwr4H95JoOvwsIUzSVgBE h4xpPheRfIyb1bzXf0DW4MfeGd92W44yKRgF7scB2T6gYewsBCFY7YEoptUEsmtLGXlrGPY5AKkhN 5FuT1QfaXrwFww9uO2435YUq3pO33rMrwhXCWi+u3CBk9bFkmUJNAw1AIA7C4z+GjtSnxfo4VEjiE VbDhqmHyvw9HbUU3FPrH1jHTwR2e5MKIvOCUB2q6Xq+gQe2G55+ShdB/qzKwoUEC2bNAGz27JZPrx b2IS/OhZG9tkeQ==; Date: Fri, 20 Jun 2025 10:46:51 +0300 Message-Id: <86y0tmkg7o.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: (admin@sonictk.com) References: MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: "admin@sonictk.com" > Date: Fri, 20 Jun 2025 05:09:06 +0000 > > This has been a problem ever since as long as I can remember, but > using `eglot` with `clangd` results in Emacs sometimes just hanging. Does this happen only in Emacs 31, or did you see that in older versions as well? > I work in the Unreal Engine codebase, which results in some pretty massive `clangd` memory usage (sometimes 200+ GB) and thus response times, along with having to spin up multiple `clangd` servers simultaneously. How much VM do you have on that system, if memory consumption can be 200+ GB? And what is the memory footprint of Emacs in those cases? > As far as I can tell, Emacs can hang in cases with as little as two `clangd` servers spun up, but generally this problem repros more often when I have multiple servers spun up. It usually happens on some LSP request, and it's not always deterministic which request it is. How many LSP servers could you have simultaneously? > I work on Windows, and I grabbed a callstack of Emacs's main thread when the hang occurs in WinDbg: This doesn't tell the whole story, because there must be other threads of interest in this case (since one or more clangd processes are being read from and written to). > ``` > [0x0] ntdll!NtWaitForMultipleObjects+0x14 0x3df75fdea8 0x7ffdf18abaf0 > [0x1] KERNELBASE!WaitForMultipleObjectsEx+0xf0 0x3df75fdeb0 0x7ffdf18ab9ee > [0x2] KERNELBASE!WaitForMultipleObjects+0xe 0x3df75fe1a0 0x7ff635a921f7 > [0x3] emacs!sys_select+0x12b7 0x3df75fe1e0 0x7ff635a1147e > [0x4] emacs!really_call_select+0x5e 0x3df75fe2a0 0x7ff635a1273d > [0x5] emacs!thread_select+0x9d 0x3df75fe300 0x7ff6359d9aec > [0x6] emacs!wait_reading_process_output+0x111c 0x3df75fe450 0x7ff6359db4c9 > [0x7] emacs!send_process+0x269 0x3df75fe9c0 0x7ff6359dbd11 > [0x8] emacs!Fprocess_send_string+0xb1 0x3df75fea70 0x7ff6359b5c5e This says that Emacs called process-send-string, and it loops waiting for the queue of sent material to be emptied. This information is not enough to analyze the reason for the hang. > The only workaround, without killing Emacs, is to kill all `clangd.exe` processes - this usually gets Emacs unstuck after a second or so. Sometimes, though, this trick doesn't work, and then the only recourse I have is to kill Emacs.exe entirely. > > I've been trying to find time on and off to debug this properly, but today I finally gave up and decided to report this in the hope that maybe someone will see this callstack and know immediately where the bug is. > > My emacs build was built from source. Version information is as follows: > > ``` > In GNU Emacs 31.0.50 (build 5, x86_64-w64-mingw32) of 2025-06-03 built > on CDW-AQRHE1HHT39 > Repository revision: eb788fd8fd2026fa4d29b918ff95b12d8e3e0bab > Repository branch: master > Windowing system distributor 'Microsoft Corp.', version 10.0.19045 > System Description: Microsoft Windows 10 Enterprise (v10.0.2009.19045.5965) This build is from 2 weeks ago. Please update from master and rebuild, so that the source-level information you report will be easy to follow by looking at the current sources. > Configured using: > 'configure --without-pop --with-imagemagick > --without-compress-install -without-dbus --with-gnutls > --with-tree-sitter --without-gconf --with-rsvg --without-gsettings > --with-mailutils --with-native-compilation --with-modules --with-xml2 > --with-wide-int 'CFLAGS=-O3 -ggdb -fno-math-errno First, please remove the --with-wide-int, it is not needed for 64-bit builds (and is supposed to be a no-op, but who knows?). Also, please don't use -O3, but -O2 instead. The -O3 switch could cause unsafe optimizations. > -funsafe-math-optimizations -fno-finite-math-only -fno-trapping-math > -freciprocal-math -fno-rounding-math -fno-signaling-nans > -fassociative-math -fno-signed-zeros -frename-registers > -funroll-loops -mtune=native -march=native -fomit-frame-pointer > -fallow-store-data-races -fno-semantic-interposition > -floop-parallelize-all -ftree-parallelize-loops=4' Please also drop all these -fSOMETHING and -f-noSOMETHING switches; they are not needed with -O2. And fomit-frame-pointer is actually dangerous in Emacs. > PKG_CONFIG_PATH=/mingw64/lib/pkgconfig:/mingw64/share/pkgconfig' Don't know what that is, or why do you need it. > Anyone who has ideas for me to try/look in debugging this issue, happy to give them a go. I encounter this fairly frequently, so I should be able to catch it in action. Next time Emacs hangs like that, attach GDB to it, then type at the GDB prompt: (gdb) thread apply all bt and post here everything that GDB produces as result. This will show us the C-level backtraces of all the threads that run in the process, not only of the main thread. When Emacs communicates with external processes, it uses additional threads for that purpose, and it is important to know their state and status. (Let me know if you need instructions about attaching GDB to a running Emacs process.) Thanks.