Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@arnaud-lb
Copy link
Member

Calling zend_add_system_entropy() after zend_finalize_system_id() has no effect. The function returns FAILURE in that case, but it's not checked in practice, so some zend_add_system_entropy() calls are unknowingly no-ops.

Here I change zend_add_system_entropy() so that calling it too late triggers an assertion failure. I also fix JIT initialization, which called zend_add_system_entropy() too late.

Extensions using zend_get_resource_handle(), zend_get_op_array_extension_handle(), zend_get_internal_function_extension_handle(), or calling zend_add_system_entropy() explicitly, should do so in MINIT() (for PHP modules) or in the startup hook (for Zend extensions).

@TimWolla
Copy link
Member

TimWolla commented Nov 13, 2025

The function returns FAILURE in that case, but it's not checked in practice, so some zend_add_system_entropy() calls are unknowingly no-ops.

Could alternatively (or in addition) add ZEND_ATTRIBUTE_NODISCARD.

@bwoebi
Copy link
Member

bwoebi commented Nov 13, 2025

This will make dl() calls hard-fail, rather than just allocating the handle for later op_arrays.
I don't particularly like this...

@arnaud-lb
Copy link
Member Author

@bwoebi I didn't think about dl(). Is this a real use-case? Do some extensions call zend_add_system_entropy() and support being dl()'ed?

This breaks phpdbg too, so I may abandon this.

@TimWolla as I was seeing it, calling zend_add_system_entropy() too late is a programming error, so an assertion failure would make sense. This may not be the case, so yes I may change to ZEND_ATTRIBUTE_NODISCARD.

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