On Wed, 25 Jun 2025, Thirumalai Nagalingam wrote:

> -      ldp     x0, x10, [x19, #16]  // x0 = stackaddr, x10 = stackbase \n\
> +      ldp     x10, x0, [x19, #24]  // x0 = stackaddr, x10 = stackbase \n\

I am very confused about this.

The struct layout:
struct pthread_wrapper_arg
{
  LPTHREAD_START_ROUTINE func; // +0
  PVOID arg;                   // +8
  PBYTE stackaddr;             // +16
  PBYTE stackbase;             // +24
  PBYTE stacklimit;            // +32
  ULONG guardsize;             // +40
};

below, you have
           ldp     x19, x0, [x19]       // x19 = func, x0 = arg            \n\
           blr     x19                  // call thread function            \n"

If this works (and it'd be really very obvious if it didn't), ldp loads
64-bits at the address given and puts it in the first register, and loads
64-bits at address+8 and puts it in the second register.  So wouldn't this
really be

+      ldp     x10, x0, [x19, #24]  // x10 = stackbase, x0 = stacklimit \n\

?

so now you're freeing stacklimit instead of stackbase?  I don't think
that's right.

Reply via email to