Invalid handle error in fhandler_pty_master::close
Ken Brown
kbrown@cornell.edu
Thu Oct 7 14:30:32 GMT 2021
I'm occasionally seeing what appears to be an Invalid Handle error in
fhandler_pty_master::close at fhandler_tty.cc:2044.
CloseHandle (attach_mutex);
This sometimes happens when I exit emacs while a process is running. (It's
always been a compilation process when I've seen this, but that may or may not
be relevant.) Here's a recent example where I caught this under gdb:
Thread 1 "emacs" received signal SIGSEGV, Segmentation fault.
0x00007ff8ebae1548 in ntdll!RtlVirtualUnwind ()
from /c/WINDOWS/SYSTEM32/ntdll.dll
(gdb) bt
#0 0x00007ff8ebae1548 in ntdll!RtlVirtualUnwind ()
from /c/WINDOWS/SYSTEM32/ntdll.dll
#1 0x00007ff8ebae1040 in ntdll!RtlVirtualUnwind ()
from /c/WINDOWS/SYSTEM32/ntdll.dll
#2 0x00007ff8ebae0e7b in ntdll!RtlVirtualUnwind ()
from /c/WINDOWS/SYSTEM32/ntdll.dll
#3 0x00007ff8ebb013a8 in ntdll!RtlRaiseException ()
from /c/WINDOWS/SYSTEM32/ntdll.dll
#4 0x00007ff8ebb50bfe in ntdll!KiUserExceptionDispatcher ()
from /c/WINDOWS/SYSTEM32/ntdll.dll
#5 0x00007ff8ebb50c7a in ntdll!KiRaiseUserExceptionDispatcher ()
from /c/WINDOWS/SYSTEM32/ntdll.dll
#6 0x00007ff8e966a3c5 in KERNELBASE!CloseHandle ()
from /c/WINDOWS/System32/KERNELBASE.dll
#7 0x00000001800bb4d8 in fhandler_pty_master::close (this=0x18036ec90)
at
/usr/src/debug/cygwin-3.3.0-0.2.6c1f49f83fde/winsup/cygwin/fhandler_tty.cc:2044
#8 0x000000018006b7e5 in fhandler_base::close_with_arch (this=0x18036f2b0)
at /usr/src/debug/cygwin-3.3.0-0.2.6c1f49f83fde/winsup/cygwin/fhandler.cc:1185
#9 0x000000018014207d in close (fd=15)
at /usr/src/debug/cygwin-3.3.0-0.2.6c1f49f83fde/winsup/cygwin/syscalls.cc:1652
#10 0x000000018018f3eb in _sigfe () at sigfe.s:35
#11 0x000000010058b787 in posix_close (fd=15, flag=1)
at ../../emacs-28/src/sysdep.c:2421
#12 0x000000010058b7c1 in emacs_close (fd=15)
at ../../emacs-28/src/sysdep.c:2439
#13 0x0000000100688597 in close_process_fd (fd_addr=0x800dcdf9c)
at ../../emacs-28/src/process.c:2023
#14 0x000000010068d990 in deactivate_process (proc=XIL(0x800dcded5))
at ../../emacs-28/src/process.c:4683
#15 0x0000000100685ba6 in remove_process (proc=XIL(0x800dcded5))
at ../../emacs-28/src/process.c:937
[...]
Lisp Backtrace:
"yes-or-no-p" (0xffffb758)
0xff4760 PVEC_COMPILED
"save-buffers-kill-emacs" (0xffffbe88)
"save-buffers-kill-terminal" (0xffffc1a0)
"funcall-interactively" (0xffffc198)
Thread 1 "emacs" received signal SIGSEGV, Segmentation fault.
0x00000000ffff9050 in ?? ()
The program being debugged was signaled while in a function called from GDB.
GDB remains in the frame where the signal was received.
To change this behavior use "set unwindonsignal on".
Evaluation of the expression containing the function
(backtrace_function) will be abandoned.
When the function is done executing, GDB will silently stop.
Even though gdb reports SIGSEGV, that seems to be a result of something that
happened while gdb was evaluating a function defined in emacs's .gdbinit. On a
different occasion, I explicitly see an Invalid Handle exception while running
under gdb. Here's an example of that:
gdb: unknown target exception 0xc0000008 at 0x7ff8ebb50c7a
Thread 1 "emacs" received signal ?, Unknown signal.
0x00007ff8ebb50c7a in ntdll!KiRaiseUserExceptionDispatcher ()
from /c/WINDOWS/SYSTEM32/ntdll.dll
(gdb) bt
#0 0x00007ff8ebb50c7a in ntdll!KiRaiseUserExceptionDispatcher ()
from /c/WINDOWS/SYSTEM32/ntdll.dll
#1 0x00007ff8e966a3c5 in KERNELBASE!CloseHandle ()
from /c/WINDOWS/System32/KERNELBASE.dll
#2 0x00000001800bb4d8 in fhandler_pty_master::close (this=0x180358370)
at
/usr/src/debug/cygwin-3.3.0-0.2.6c1f49f83fde/winsup/cygwin/fhandler_tty.cc:2044
#3 0x000000018006b7e5 in fhandler_base::close_with_arch (this=0x180358060)
at /usr/src/debug/cygwin-3.3.0-0.2.6c1f49f83fde/winsup/cygwin/fhandler.cc:1185
#4 0x000000018013ea3f in close_all_files (norelease=norelease@entry=false)
at /usr/src/debug/cygwin-3.3.0-0.2.6c1f49f83fde/winsup/cygwin/syscalls.cc:102
#5 0x0000000180048243 in do_exit (status=0)
at /usr/src/debug/cygwin-3.3.0-0.2.6c1f49f83fde/winsup/cygwin/dcrt0.cc:1180
#6 0x000000018004841f in _exit (n=<optimized out>)
at /usr/src/debug/cygwin-3.3.0-0.2.6c1f49f83fde/winsup/cygwin/dcrt0.cc:1297
#7 0x00000001801ad68d in exit (code=0)
at /usr/src/debug/cygwin-3.3.0-0.2.6c1f49f83fde/newlib/libc/stdlib/exit.c:64
#8 0x0000000180048403 in cygwin_exit (n=0)
at /usr/src/debug/cygwin-3.3.0-0.2.6c1f49f83fde/winsup/cygwin/dcrt0.cc:1291
#9 0x000000018018f3eb in _sigfe () at sigfe.s:35
#10 0x0000000100520797 in Fkill_emacs (arg=XIL(0))
at ../../emacs-28/src/emacs.c:2669
[...]
Lisp Backtrace:
"kill-emacs" (0xffff9450)
"save-buffers-kill-emacs" (0xffff99f8)
"save-buffers-kill-terminal" (0xffffa060)
[...]
If it would help, I can give more details about exactly what I was doing in
emacs when these errors occurred, but I don't have a reliable reproduction
recipe, and I don't have any way of reproducing it that doesn't involve emacs.
Ken
More information about the Cygwin-developers
mailing list