Skip to content

zend call stack, follow-up on 75e9980. #11626

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

devnexen
Copy link
Member

@devnexen devnexen commented Jul 7, 2023

user stack usable implementation for openbsd.

@devnexen devnexen requested a review from iluuu1994 as a code owner July 7, 2023 18:27
@devnexen devnexen requested review from arnaud-lb and removed request for iluuu1994 July 7, 2023 18:29
user stack usable implementation for openbsd.
Copy link
Member

@arnaud-lb arnaud-lb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!


static bool zend_call_stack_get_openbsd(zend_call_stack *stack)
{
if (getthrid() == getpid()) {
Copy link
Member

@arnaud-lb arnaud-lb Jul 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This trick doesn't appear to work on my machine: the IDs are different (I've verified that there is a single thread in the process). I'm not sure how we can determine that we are the main thread. From reading the code, !TIB_GET()->tib_thread || !TIB_GET()->tib_thread->stack would work (tib_thread is null if pthread is not initialized, and tib_thread->stack appears to imply non-main thread), but you may know a better way?

}

// arch dependent top user's stack
stack->base = USRSTACK - rlim.rlim_cur;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On my machine with OpenBSD 7.3 the actual stack base as reported by procmap is randomized, and the value of USRSTACK does not match. Maybe we could use sysctl() like pthread does?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ve looked at first at sysctl and did not find anything relevant (a way may have existed before tough), however there is a hope to achieve it I ll have a better look later today.

@devnexen
Copy link
Member Author

devnexen commented Jul 8, 2023

stack_limit zend tests seem to pass now.

@devnexen devnexen force-pushed the zend_call_stack_nopthread branch from b84497b to a368570 Compare July 8, 2023 09:30
@arnaud-lb
Copy link
Member

Thank you!

@devnexen devnexen closed this in 343b599 Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants