Skip to content

Add padding to globals to maintain ABI compatibility when adding fields in patches - #25356

Closed
iluuu1994 wants to merge 1 commit into
php:PHP-8.6from
iluuu1994:tsrm-compile-time-offsets-padding
Closed

iluuu1994 wants to merge 1 commit into
php:PHP-8.6from
iluuu1994:tsrm-compile-time-offsets-padding

Conversation

@iluuu1994

Copy link
Copy Markdown
Member

@iluuu1994
iluuu1994 force-pushed the tsrm-compile-time-offsets-padding branch from b1e420c to 772e99f Compare November 10, 2026 01:49
@henderkes

henderkes commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Is it just because of the compile-time offset of CG or EG from _tsrm_ls_cache? Otherwise an ABI change could be an issue in NTS too, wouldn't it?

If it is limited to ZTS because of the former, perhaps we could add the padding (or set alignment) on the parent struct?

If it's the latter, this is the right approach.

@iluuu1994

Copy link
Copy Markdown
Member Author

@henderkes

Is it just because of the compile-time offset of CG or EG from _tsrm_ls_cache?

Yes, if the structs grow ZEND_CG_OFFSET/ZEND_EG_OFFSET will be wrong when compiled against older PHP versions. Technically sizeof(global) itself is already an ABI break but one that we can effectively ignore, as globals aren't copied around or initialized by extensions.

If it is limited to ZTS because of the former, perhaps we could add the padding (or set alignment) on the parent struct?

I don't quite understand. You mean omit the offset for NTS? Technically the padding is not needed there, but we can also avoid the other technical ABI break above with this, so it doesn't hurt.

@henderkes

Copy link
Copy Markdown
Contributor

I don't quite understand. You mean omit the offset for NTS.

I meant specifying the padding at the compile time offset define. But as this also fixes the technical ABI break in NTS, yes, this is better.

Let me check something about alignment later on desktop, other than that +1.

@iluuu1994

Copy link
Copy Markdown
Member Author

Adding the padding to the offset number directly also means you'd have to sync the two locations, right? So I think this is more explicit.

Let me check something about alignment later on desktop, other than that +1.

Thanks! This will need to land tomorrow to get included in the last RC. Sorry to rush you. 😅

@henderkes

Copy link
Copy Markdown
Contributor

Home in an hour and a half!

@iluuu1994 iluuu1994 closed this in cd9b9c3 Nov 10, 2026
@iluuu1994

Copy link
Copy Markdown
Member Author

@henderkes Great, thanks for checking

mbeccati pushed a commit to mbeccati/php-src that referenced this pull request Nov 10, 2026
mbeccati pushed a commit to mbeccati/php-src that referenced this pull request Nov 10, 2026
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.

3 participants