max_tree_depth: lower it for clang builds in general on Windows

In 436a42215e5 (max_tree_depth: lower it for clangarm64 on Windows,
2025-04-23), I provided a work-around for a nasty issue with clangarm
builds, where the stack is exhausted before the maximal tree depth is
reached, and the resulting error cannot easily be handled by Git
(because it would require Windows-specific handling).

Turns out that this is not at all limited to ARM64. In my tests with
CLANG64 in MSYS2 on the GitHub Actions runners, the test t6700.4 failed
in the exact same way. What's worse: The limit needs to be quite a bit
lower for x86_64 than for aarch64. In aforementioned tests, the breaking
point was 1232: With 1231 it still worked as expected, with 1232 it
would fail with the `STATUS_STACK_OVERFLOW` incorrectly mapped to exit
code 127. For comparison, in my tests on GitHub Actions' Windows/ARM64
runners, the breaking point was 1439 instead.

Therefore the condition needs to be adapted once more, to accommodate
(with some safety margin) both aarch64 and x86_64 in clang-based builds
on Windows, to let that test pass.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin 2025-11-21 15:15:42 +01:00
parent 58719bb028
commit 47d7ce745f

View File

@ -588,17 +588,23 @@ static inline bool strip_suffix(const char *str, const char *suffix,
* the stack overflow can occur.
*/
#define DEFAULT_MAX_ALLOWED_TREE_DEPTH 512
#elif defined(GIT_WINDOWS_NATIVE) && defined(__clang__) && defined(__aarch64__)
#elif defined(GIT_WINDOWS_NATIVE) && defined(__clang__)
/*
* Similar to Visual C, it seems that on Windows/ARM64 the clang-based
* builds have a smaller stack space available. When running out of
* that stack space, a `STATUS_STACK_OVERFLOW` is produced. When the
* Similar to Visual C, it seems that clang-based builds on Windows
* have a smaller stack space available. When running out of that
* stack space, a `STATUS_STACK_OVERFLOW` is produced. When the
* Git command was run from an MSYS2 Bash, this unfortunately results
* in an exit code 127. Let's prevent that by lowering the maximal
* tree depth; This value seems to be low enough.
* tree depth; Unfortunately, it seems that the exact limit differs
* for aarch64 vs x86_64, and the difference is too large to simply
* use a single limit.
*/
#if defined(__aarch64__)
#define DEFAULT_MAX_ALLOWED_TREE_DEPTH 1280
#else
#define DEFAULT_MAX_ALLOWED_TREE_DEPTH 1152
#endif
#else
#define DEFAULT_MAX_ALLOWED_TREE_DEPTH 2048
#endif