Subject: bug#70914: 29.3; Crashes often on Windows

From: Simen Endsjø <[email-masked]>
Date: Wed, 15 May 2024 20:13:22 +0200

> >  Would you mind running Emacs from GDB after setting this option:
> >
> >   (gdb) set debugexceptions on
>
> This seems to trigger often, so I'm not able to use emacs while it's on. Here's
> a few exceptions I caught before turning it off again.

That's strange.  Did you start GDB from the src directory of the Emacs
source tree, perhaps?  If so, try starting GDB from another directory.

No, started from my home folder; c:/Users/simend. Started it from a PowerShell 7
(pwsh) shell in a Windows Terminal.

Ran gdb with
    $ rlwrap gdb
    (gdb) target exec c:/programs/emacs/latest/bin/emacs.exe
    (gdb) run --init-directory=d:/.emacs.d

> If debugexceptions doesn't help even when you start GDB from a
> different directory, I need to think about something else.  What
> happens on your system is very strange.  These are not "normal"
> crashes, AFAICT.  Something else is at work on your system.  Do you
> have some unusual software running there, perhaps, or some Windows
> feature(s) enabled that is/are usually disabled?

For the gdb debugging here, I've only been running async compilation and copilot
(node.exe) according to `list-processes`. Normally I'm running emacs as a
background daemon.

gcc comes from msys2.

I'm running emacs on a VHD ReFs Dev Drive, but I experienced the same crashes
when running just on NTFS too. My emacs is a stock build downloaded from the
main gnu ftp.

This is a corporate computer though, so there might be various policies I'm not
aware of, although I cannot think of anything strange running other than Windows
Defender which I'm doing my best at disabling as much as possible.

> Why are the callstacks smashed (those zero addresses)?  The callstack
> of thread 1 (the main thread, a.k.a. "Lisp thread") is completely
> ruined -- how did that happen?  And why do you have so many threads in
> Emacs?  Are you starting subprocesses a lot or something?  I see 2
> reader threads waiting for subprocesses in this backtrace.  What kind
> of programs or network connections do you routinely run from Emacs?

For the last crash I didn't do much before it crashed. Ran an org-roam db sync,
then opened a large org-mode file, and it crashed while opening the
org-mode file.
I usually run ripgrep, fd, node (copilot), sbcl (sly) from this emacs machine,
but it I cannot seem to correlate the crashes with any of that work. It often
crashes while writing in org-mode buffers, which points towards copilot/node.

On Wed, May 15, 2024 at 5:25 PM Eli Zaretskii <[email-masked]> wrote:
>
> > From: Simen Endsjø <[email-masked]>
> > Date: Wed, 15 May 2024 15:36:15 +0200
> > Cc: [email-masked]
> >
> > Got a segfault when opening an org file when running under gdb. But doesn't seem
> > like there is any useful information there.
> >
> >     Thread 1 received signal SIGSEGV, Segmentation fault.
> >     [Switching to Thread 21772.0x4058]
> >     0x0000000000000000 in ?? ()
> >     (gdb) thread apply all bt
> >
> >     Thread 148 (Thread 21772.0x4f4c):
> >     #0  0x00007fffdabf35a4 in ntdll!ZwWaitForWorkViaWorkerFactory ()
> > from C:\WINDOWS\SYSTEM32\ntdll.dll
> >     #1  0x00007fffdab8537e in ntdll!RtlClearThreadWorkOnBehalfTicket
> > () from C:\WINDOWS\SYSTEM32\ntdll.dll
> >     #2  0x00007fffd993257d in KERNEL32!BaseThreadInitThunk () from
> > C:\WINDOWS\System32\kernel32.dll
> >     #3  0x00007fffdabaaa48 in ntdll!RtlUserThreadStart () from
> > C:\WINDOWS\SYSTEM32\ntdll.dll
> >     #4  0x0000000000000000 in ?? ()
>
> Curiouser and curiouser.
>
> Why are the callstacks smashed (those zero addresses)?  The callstack
> of thread 1 (the main thread, a.k.a. "Lisp thread") is completely
> ruined -- how did that happen?  And why do you have so many threads in
> Emacs?  Are you starting subprocesses a lot or something?  I see 2
> reader threads waiting for subprocesses in this backtrace.  What kind
> of programs or network connections do you routinely run from Emacs?