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

From: Eli Zaretskii <[email-masked]>
Date: Sun, 19 May 2024 08:50:10 +0300

> From: Simen Endsjø <[email-masked]>
> Date: Sat, 18 May 2024 23:45:12 +0200
> Cc: [email-masked], [email-masked]
> 
> > Hmm... does your MinGW installation produce programs linked against
> > UCRT or against MSVCRT?  I see both loaded, which looks strange to me.
> 
> Ref https://www.msys2.org/docs/environments/
> MSVC (Microsoft Visual C++ Runtime) is legacy and UCRT (Universal C Runtime) is
> a newer, but backwards compatible, runtime? I haven't paid any attention to this
> at all, so maybe I've destroyed my msys install? I just reinstalled msys
> though, so it's pretty bare-bones:
> 
>     $ paclist mingw64
>     mingw-w64-x86_64-SDL2 2.30.2-1
>     mingw-w64-x86_64-aom 3.9.0-2
>     mingw-w64-x86_64-binutils 2.42-2
>     mingw-w64-x86_64-brotli 1.1.0-1
>     mingw-w64-x86_64-bzip2 1.0.8-3
>     mingw-w64-x86_64-c-ares 1.28.1-1
>     mingw-w64-x86_64-ca-certificates 20240203-1
>     mingw-w64-x86_64-cairo 1.18.0-2
>     mingw-w64-x86_64-crt-git 11.0.0.r744.ge5ac8c550-1
>     mingw-w64-x86_64-crypto++ 8.9.0-1
>     mingw-w64-x86_64-curl 8.7.1-1
>     mingw-w64-x86_64-dav1d 1.4.1-1
>     mingw-w64-x86_64-djvulibre 3.5.28-3
>     mingw-w64-x86_64-expat 2.6.2-1
>     mingw-w64-x86_64-fftw 3.3.10-5
>     mingw-w64-x86_64-flif 0.4-2
>     mingw-w64-x86_64-fontconfig 2.15.0-2
>     mingw-w64-x86_64-freeglut 3.4.0-2
>     mingw-w64-x86_64-freetype 2.13.2-1
>     mingw-w64-x86_64-fribidi 1.0.13-1
>     mingw-w64-x86_64-gcc 14.1.0-3
>     mingw-w64-x86_64-gcc-libs 14.1.0-3
>     mingw-w64-x86_64-gdb 14.2-1
>     mingw-w64-x86_64-gdb-multiarch 14.2-1
>     mingw-w64-x86_64-gdk-pixbuf2 2.42.10-4
>     mingw-w64-x86_64-gettext-runtime 0.22.5-2
>     mingw-w64-x86_64-giflib 5.2.2-1
>     mingw-w64-x86_64-glib2 2.80.0-1
>     mingw-w64-x86_64-gmp 6.3.0-2
>     mingw-w64-x86_64-gnutls 3.8.5-2
>     mingw-w64-x86_64-graphite2 1.3.14-3
>     mingw-w64-x86_64-gsfonts 20200910-3
>     mingw-w64-x86_64-harfbuzz 8.4.0-1
>     mingw-w64-x86_64-headers-git 11.0.0.r744.ge5ac8c550-1
>     mingw-w64-x86_64-imagemagick 7.1.1.31-1
>     mingw-w64-x86_64-isl 0.26-1
>     mingw-w64-x86_64-jansson 2.14-2
>     mingw-w64-x86_64-jasper 4.2.1-1
>     mingw-w64-x86_64-jbigkit 2.1-5
>     mingw-w64-x86_64-kvazaar 2.3.1-1
>     mingw-w64-x86_64-lcms2 2.16-1
>     mingw-w64-x86_64-lerc 4.0.0-1
>     mingw-w64-x86_64-libdatrie 0.2.13-3
>     mingw-w64-x86_64-libde265 1.0.15-1
>     mingw-w64-x86_64-libdeflate 1.20-1
>     mingw-w64-x86_64-libffi 3.4.6-1
>     mingw-w64-x86_64-libgccjit 14.1.0-3
>     mingw-w64-x86_64-libheif 1.17.6-3
>     mingw-w64-x86_64-libiconv 1.17-4
>     mingw-w64-x86_64-libidn2 2.3.7-2
>     mingw-w64-x86_64-libjpeg-turbo 3.0.2-1
>     mingw-w64-x86_64-liblqr 0.4.2-5
>     mingw-w64-x86_64-libltdl 2.4.7-2
>     mingw-w64-x86_64-libmangle-git 11.0.0.r744.ge5ac8c550-1
>     mingw-w64-x86_64-libpng 1.6.43-1
>     mingw-w64-x86_64-libpsl 0.21.5-2
>     mingw-w64-x86_64-libraqm 0.10.1-1
>     mingw-w64-x86_64-libraw 0.21.2-3
>     mingw-w64-x86_64-librsvg 2.58.0-1
>     mingw-w64-x86_64-libssh2 1.11.0-2
>     mingw-w64-x86_64-libsystre 1.0.1-5
>     mingw-w64-x86_64-libtasn1 4.19.0-1
>     mingw-w64-x86_64-libthai 0.1.29-3
>     mingw-w64-x86_64-libtiff 4.6.0-1
>     mingw-w64-x86_64-libtre-git r177.07e66d0-2
>     mingw-w64-x86_64-libunistring 1.2-1
>     mingw-w64-x86_64-libwebp 1.4.0-1
>     mingw-w64-x86_64-libwinpthread-git 11.0.0.r744.ge5ac8c550-1
>     mingw-w64-x86_64-libwmf 0.2.13-1
>     mingw-w64-x86_64-libxml2 2.12.7-1
>     mingw-w64-x86_64-lzo2 2.10-2
>     mingw-w64-x86_64-make 4.4.1-2
>     mingw-w64-x86_64-mpc 1.3.1-2
>     mingw-w64-x86_64-mpdecimal 4.0.0-1
>     mingw-w64-x86_64-mpfr 4.2.1-2
>     mingw-w64-x86_64-ncurses 6.4.20231217-1
>     mingw-w64-x86_64-nettle 3.9.1-1
>     mingw-w64-x86_64-nghttp2 1.61.0-1
>     mingw-w64-x86_64-nspr 4.35-2
>     mingw-w64-x86_64-nss 3.99-1
>     mingw-w64-x86_64-openjpeg2 2.5.2-1
>     mingw-w64-x86_64-openssl 3.3.0-1
>     mingw-w64-x86_64-p11-kit 0.25.3-2
>     mingw-w64-x86_64-pango 1.52.2-1
>     mingw-w64-x86_64-pcre2 10.43-2
>     mingw-w64-x86_64-pixman 0.43.4-1
>     mingw-w64-x86_64-pkgconf 1~2.2.0-1
>     mingw-w64-x86_64-poppler 24.01.0-2
>     mingw-w64-x86_64-poppler-data 0.4.12-1
>     mingw-w64-x86_64-python 3.11.9-1
>     mingw-w64-x86_64-python-packaging 23.2-1
>     mingw-w64-x86_64-rav1e 0.7.1-2
>     mingw-w64-x86_64-readline 8.2.010-1
>     mingw-w64-x86_64-sqlite3 3.45.2-1
>     mingw-w64-x86_64-svt-av1 2.0.0-1
>     mingw-w64-x86_64-tcl 8.6.13-1
>     mingw-w64-x86_64-termcap 1.3.1-7
>     mingw-w64-x86_64-tk 8.6.13-1
>     mingw-w64-x86_64-tools-git 11.0.0.r744.ge5ac8c550-1
>     mingw-w64-x86_64-tree-sitter 0.22.6-1
>     mingw-w64-x86_64-ttf-dejavu 2.37-4
>     mingw-w64-x86_64-tzdata 2024a-1
>     mingw-w64-x86_64-vulkan-loader 1.3.280.0-1
>     mingw-w64-x86_64-windows-default-manifest 6.4-4
>     mingw-w64-x86_64-wineditline 2.206-1
>     mingw-w64-x86_64-winpthreads-git 11.0.0.r744.ge5ac8c550-1
>     mingw-w64-x86_64-winstorecompat-git 11.0.0.r744.ge5ac8c550-1
>     mingw-w64-x86_64-x265 3.5-3
>     mingw-w64-x86_64-xpm-nox 4.2.0-8
>     mingw-w64-x86_64-xxhash 0.8.2-2
>     mingw-w64-x86_64-xz 5.6.1-2
>     mingw-w64-x86_64-zlib 1.3.1-1
>     mingw-w64-x86_64-zstd 1.5.6-2
> 
>     $ paclist ucrt64
>     mingw-w64-ucrt-x86_64-binutils 2.42-2
>     mingw-w64-ucrt-x86_64-crt-git 11.0.0.r744.ge5ac8c550-1
>     mingw-w64-ucrt-x86_64-gcc 14.1.0-3
>     mingw-w64-ucrt-x86_64-gcc-libs 14.1.0-3
>     mingw-w64-ucrt-x86_64-gettext-runtime 0.22.5-2
>     mingw-w64-ucrt-x86_64-gmp 6.3.0-2
>     mingw-w64-ucrt-x86_64-headers-git 11.0.0.r744.ge5ac8c550-1
>     mingw-w64-ucrt-x86_64-isl 0.26-1
>     mingw-w64-ucrt-x86_64-libiconv 1.17-4
>     mingw-w64-ucrt-x86_64-libwinpthread-git 11.0.0.r744.ge5ac8c550-1
>     mingw-w64-ucrt-x86_64-mpc 1.3.1-2
>     mingw-w64-ucrt-x86_64-mpfr 4.2.1-2
>     mingw-w64-ucrt-x86_64-windows-default-manifest 6.4-4
>     mingw-w64-ucrt-x86_64-winpthreads-git 11.0.0.r744.ge5ac8c550-1
>     mingw-w64-ucrt-x86_64-zlib 1.3.1-1
>     mingw-w64-ucrt-x86_64-zstd 1.5.6-2

I see some libraries are present in both UCRT and MSVCRT builds.  I
wonder if this is related in some way.  Can you tell which files are
installed by, for example, these two packages, which are both GMP
library version 6.3:

   mingw-w64-x86_64-gmp 6.3.0-2
   mingw-w64-ucrt-x86_64-gmp 6.3.0-2

Are the DLLs installed by these packages named differently?  If not,
are they installed into different directories, and if so, are those
directories on Path?

> I removed all ucrt packages (pacman -R)

So now the packages listed by "paclist ucrt" above are no longer
present on your system?

>     $ ldd emacs-extra-checks-no-ucrt/src/emacs.exe

This is a flat list, so it is not very useful.  Can you install the
Dependency Walker (https://www.dependencywalker.com, get the x64
version), and produce a tree-like dependency graph?  That will tell us
whether Emacs itself or one of the DLLs it loads (or both) depend on
UCRT.

> > Let's ask Emacs to help us some more, okay?  Please reconfigure like
> > this:
> >
> >   CFLAGS='-O0 -gdwarf-4 -g3' ./configure --without-native-compilation \
> >     --enable-checking='yes,glyphs' --enable-check-lisp-object-type \
> >     --with-modules --without-dbus --without-compress-install \
> >     --with-sqlite3 --with-tree-sitter
> >
> > then rebuild, and see if the extra checking code catches some problems
> > before they become SIGSEGV due to zero address.
> 
> The above was done using these extra check flags:
> 
>     system-configuration-options is a variable defined in emacs.c.
> 
>     Value
>     "--prefix=/d/tmp/emacs-bug-70914/emacs-extra-checks-no-ucrt/simendsjo-build
> --without-native-compilation --enable-checking=yes,glyphs
> --enable-check-lisp-object-type --with-modules --without-dbus
> --without-compress-install --with-sqlite3 --with-tree-sitter
> 'CFLAGS=-O0 -gdwarf-4 -g3 -Wno-error=implicit-function-declaration'"

And the crashes still look the same with this version, with those zero
addresses?