Files
MINGW-packages/mingw-w64-tk
Johannes Schindelin 7669bba63e tk: avoid a segmentation fault
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>
2025-11-07 18:29:03 +01:00
..
2025-11-07 18:29:03 +01:00