There is code in Tk that emulates structured exception handling even
when `gcc` does not support the common `__try { ... } __except`
constructs. This code is written in assembler (so far, only i686 and
x86_64 variants exist, for aarch64 the entire `TkFinalize()` call is
skipped "since we don't have corresponding assembler-code", see
https://github.com/tcltk/tk/blob/core-8-6-17/win/tkWin32Dll.c#L127.
However, it seems that with one of the recent mingw-w64-gcc upgrades in
the MSYS2 project (between Tk v8.6.16 and v8.6.17, `gcc.exe` was updated
nine times, from 14.2.0-3 to 15.2.0-8), _some_ optimization was
introduced that interacts badly with that assember code, and as a
consequence there is a segmentation fault after `TkFinalize()` is called
from `DllMain()` upon `DLL_PROCESS_DETACH`.
This affects Git for Windows because `gitk` and Git GUI are both Tk
programs, and both of them reliably exit with a segmentation fault now.
Let's work around this, for now. It does seem as if the segmentation
fault can be avoided simply by downgrading optimization from `-O2` to
`-O1` when compiling the `tkWin32Dll.c` file specifically.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
15 lines
590 B
Diff
15 lines
590 B
Diff
diff tk8.6.17/win/Makefile.in tk8.6.17-no-segfault/win/Makefile.in
|
|
index 3d89da5..980041b 100644
|
|
--- tk8.6.17/win/Makefile.in
|
|
+++ tk8.6.17-no-segfault/win/Makefile.in
|
|
@@ -723,6 +723,9 @@ tkUnixScale.$(OBJEXT): ${UNIX_DIR}/tkUnixScale.c
|
|
tkWindow.$(OBJEXT): ${GENERIC_DIR}/tkWindow.c configure Makefile tkUuid.h
|
|
$(CC) -c $(CC_SWITCHES) -I. -DBUILD_tk @DEPARG@ $(CC_OBJNAME)
|
|
|
|
+# Prevent a segmentation fault after TkFinalize() was called (twice)
|
|
+tkWin32Dll.$(OBJEXT): CFLAGS += -O1
|
|
+
|
|
# Extra dependency info
|
|
tkConsole.$(OBJEXT): configure Makefile
|
|
tkMain.$(OBJEXT): configure Makefile
|