Set stackaddr if mmap is called in pthread_create (#606)

This commit is contained in:
Gautham 2022-09-08 23:07:53 -05:00 committed by GitHub
parent 5140897c27
commit c32e2d4486
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -196,6 +196,15 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
// we only need to save this to support pthread_getattr_np() // we only need to save this to support pthread_getattr_np()
pt->attr = *attr; pt->attr = *attr;
// if attr->stackaddr == 0,
// the stack is managed by cosmo,
// pt->spawn.stk is from a successful mmap,
// and so pt->attr.stackaddr = pt->spawn.stk
pt->attr.stackaddr = pt->spawn.stk;
// if attr->stackaddr != 0,
// then stack is not managed by cosmo
// pt->attr.stackaddr = pt->spawn.stk = attr->stackaddr
// so the above line is a no-op.
// set initial status // set initial status
switch (attr->detachstate) { switch (attr->detachstate) {