dircache: increase stack size to avoid stack overflows

rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]> Wed, 22 Apr 2026 20:56:40 -0400
Newsgroups gmane.comp.systems.archos.rockbox.cvs
Message-ID <[email protected]>
commit e661c35b295dcdb9a9d43beab9341e3c043b04b4
Author: Aidan MacDonald <[email protected]>
Date:   Tue Apr 21 22:05:51 2026 +0100

    dircache: increase stack size to avoid stack overflows
    
    On FS#13821, a test build with -fstack-protector-all
    (which adds 4 bytes of stack to each function, roughly)
    overflowed the dircache stack on the Hifiwalker H2.
    In my own testing, the dircache thread hit 94% stack
    use on the Fiio M3K using the same settings.
    
    That seems a bit too close to the limit, especially
    since the dircache uses recursion and might consume
    more stack space for deeply nested directories.
    
    Adding 768 bytes should provide enough of a safety
    margin. This increases the stack size from 1.25k to
    2k on most targets, including all X1000 targets.
    
    Change-Id: I900c19da9fb33f539d02b00830aedeb15c7449e2

diff --git a/firmware/include/dircache.h b/firmware/include/dircache.h
index 2cf838e539..d610c63245 100644
--- a/firmware/include/dircache.h
+++ b/firmware/include/dircache.h
@@ -44,7 +44,7 @@
    the limiting factor is the scanning thread stack size, not the
    implementation -- tune the two together */
 #define DIRCACHE_MAX_DEPTH  15
-#define DIRCACHE_STACK_SIZE (DEFAULT_STACK_SIZE + 0x100)
+#define DIRCACHE_STACK_SIZE (DEFAULT_STACK_SIZE + 0x400)
 
 /* memory buffer constants that control allocation */
 #define DIRCACHE_RESERVE (1024*64)     /* 64 KB - new entry slack */
-- 
rockbox-cvs mailing list
[email protected]
https://lists.haxx.se/mailman/listinfo/rockbox-cvs