Skip to content

Commit 84f41eb

Browse files
dschoGit for Windows Build Agent
authored andcommitted
max_tree_depth: lower it for clang builds in general on Windows
In 436a422 (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>
1 parent 1fe9b55 commit 84f41eb

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

git-compat-util.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -597,17 +597,23 @@ static inline bool strip_suffix(const char *str, const char *suffix,
597597
* the stack overflow can occur.
598598
*/
599599
#define DEFAULT_MAX_ALLOWED_TREE_DEPTH 512
600-
#elif defined(GIT_WINDOWS_NATIVE) && defined(__clang__) && defined(__aarch64__)
600+
#elif defined(GIT_WINDOWS_NATIVE) && defined(__clang__)
601601
/*
602-
* Similar to Visual C, it seems that on Windows/ARM64 the clang-based
603-
* builds have a smaller stack space available. When running out of
604-
* that stack space, a `STATUS_STACK_OVERFLOW` is produced. When the
602+
* Similar to Visual C, it seems that clang-based builds on Windows
603+
* have a smaller stack space available. When running out of that
604+
* stack space, a `STATUS_STACK_OVERFLOW` is produced. When the
605605
* Git command was run from an MSYS2 Bash, this unfortunately results
606606
* in an exit code 127. Let's prevent that by lowering the maximal
607-
* tree depth; This value seems to be low enough.
607+
* tree depth; Unfortunately, it seems that the exact limit differs
608+
* for aarch64 vs x86_64, and the difference is too large to simply
609+
* use a single limit.
608610
*/
611+
#if defined(__aarch64__)
609612
#define DEFAULT_MAX_ALLOWED_TREE_DEPTH 1280
610613
#else
614+
#define DEFAULT_MAX_ALLOWED_TREE_DEPTH 1152
615+
#endif
616+
#else
611617
#define DEFAULT_MAX_ALLOWED_TREE_DEPTH 2048
612618
#endif
613619

0 commit comments

Comments
 (0)