Skip to content

zend_call_stack.c: AIX backend - #22906

Draft
NattyNarwhal wants to merge 2 commits into
php:masterfrom
NattyNarwhal:aix-stack-limit
Draft

zend_call_stack.c: AIX backend#22906
NattyNarwhal wants to merge 2 commits into
php:masterfrom
NattyNarwhal:aix-stack-limit

Conversation

@NattyNarwhal

Copy link
Copy Markdown
Member

Uses pthread_getthrds_np (so requires pthread linked, by default on ZTS, needs to be added for NTS). The stack size part is weird, but works in testing.

An alternative approach is using procfs, but I didn't bother with this due to it not working on PASE (and the pthread approach works for the main thread too).

Uses pthread_getthrds_np (so requires pthread linked, by default on ZTS,
needs to be added for NTS). The stack size part is weird, but works in
testing.

An alternative approach is using procfs, but I didn't bother with this
due to it not working on PASE (and the pthread approach works for the
main thread too).
Comment thread Zend/zend_call_stack.c
* pthread->pt_stk.st_base is __pi_stackaddr,
* below that is the red zone
*/
stack->base = thread_info.__pi_stackend;

@devnexen devnexen Jul 28, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

for me the calculation is right but I wonder why you need a buffer of 256, for example the openjdk only sets to 1.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

WRT registers/size param, I think it may just be unnecessary, the man page on the register size argument:

The pointer to the size of the regbuf buffer. On input, it identifies the maximum size of the buffer in bytes. On output, it identifies the number of bytes of register save data and pass the TLS information. If the thread is not in a system call, there is no register save data returned from the kernel, and regbufsize is 0. If the size of the register save data is larger than the input value of regbufsize, the number of bytes specified by the input value of regbufsize is copied to regbuf, pthread_getthrds_np() returns ERANGE, and the output value of regbufsize specifies the number of bytes required to hold all of the register save data.

Since we call this function only on our own thread, and not on a different one, we never need to save the registers. In a test program, I was able to set the register buffer to NULL and the size buffer to 0 (this can't be a null pointer sadly).

...and pass a NULL register buffer, since this is only used with
suspended threads. something that'll never happen if we invoke it on
ourself. We still need to pass the size though.
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