https://bugs.kde.org/show_bug.cgi?id=517304

--- Comment #1 from Paul Floyd <[email protected]> ---
Darwin stack creation. This all happens in macho.c. The macho file format can
specify the stacksize. E.g.,

Load command 12
       cmd LC_MAIN
   cmdsize 24
  entryoff 15584
 stacksize 0

(use otool -l to see it). This command is handled by 'handle_lcmain'. If the
size is 0 (as above) then it gets set by default_stack_size(). 

static vki_size_t default_stack_size(void)
{
   struct vki_rlimit lim;
   int err = VG_(getrlimit)(VKI_RLIMIT_STACK, &lim);
   if (err) return 8*1024*1024; // 8 MB
   else return lim.rlim_cur;
}

That looks wrong in many ways compared to other platforms.
1. They use VG_(client_rlimit_stack).rlim_cur rather than calling
VG_(getrlimit)() (which I assume was used to set the global 
VG_(client_rlimit_stack)). Is  VG_(client_rlimit_stack) not set on Darwin?
2. No minimum of 1Mbyte.
3. Maximum is 8Mbytes rarther than 16Mbytes.
4. Doesn't use VG_(clo_main_stacksize)

I just pushed a fix for the above.

commit 8338e4a11c695b8b24ccb06bae4ed9d611de4d88 (HEAD -> master, origin/master,
origin/HEAD)
Author: Paul Floyd <[email protected]>
Date:   Mon Mar 9 08:05:39 2026 +0100

    Darwin stack size

    Darwin wasn't using --main-stacksize. Instead the stack was being set
    based on rlimit (in my tests I saw that it could also be set from
    macho, but it appears to specify a size of 0, at least on regtest
    files compiled on macOS 12.

    Also unlike other OSes there was no lower/upper limit of 1MB
    and 16MB.

    It looks like all four platforms now have duplicated code for setting
    the main client stack size, so I should probably factor it out into
    something like VG_(get_default_stack_size)().

    With this change I tried to get the lsframe1 and lsframe2 tests to work.
    With some twiddling of the stack and frame size they seem to work.
    One issue is that Darwin has a function that probes below the stack.
    I think that is related to stack growth. We don't implement a grow down
    stack on Darwin.  The whole stack gets mapped in one go. So this probing
    does not serve much purpose under Valgrind but it does generate a lot of
    memcheck noise.

    ~t seems as though the name of this probe function changed with
    macOS 12. Previously it was __chkstk_darwin_probe. With macOS 12
    it is ___chkstk_darwin. So I added a couple of wildcards to the
suppressions
    so that they match both versions.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to