Skip to content

ext/session refactoring: INI settings #9322

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 7 commits into from

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Aug 12, 2022

Came about because of #9304 where the standard API requires zend_strings.

I do really not understand why I was getting some GC refcount issues so it's been a bit bodged together.

Copy link
Member

@TimWolla TimWolla left a comment

Choose a reason for hiding this comment

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

I don't know enough about to engine to help with the TODO points, so here's just some general remarks about the parts that I understand.

return FAILURE;
}
/* Nul bytes are not allowed */
if (ZSTR_LEN(new_value) != strlen(ZSTR_VAL(new_value))) {
Copy link
Member

Choose a reason for hiding this comment

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

This check is highly non-obvious. I was about to suggest changing the second to ZSTR_LEN as well.

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (ZSTR_LEN(new_value) != strlen(ZSTR_VAL(new_value))) {
if (CHECK_NULL_PATH(ZSTR_VAL(new_value), ZSTR_LEN(new_value))) {

Maybe it makes sense to introduce another macro, which expects a zend_string.

@TimWolla
Copy link
Member

The first commit can likely be spun out into a separate PR, because that one is a bugfix based on my understanding, whereas the later commits are rather a feature / refactoring.

@Girgias
Copy link
Member Author

Girgias commented Aug 19, 2022

The first commit can likely be spun out into a separate PR, because that one is a bugfix based on my understanding, whereas the later commits are rather a feature / refactoring.

I'm not sure starting to emit warnings in a patch release is that ideal.
But I think I'm going to cherry pick and commit into master some of the cleanup commits seperately

@Girgias Girgias force-pushed the session-ini-refactoring branch from a5bfad6 to 7ab79e4 Compare August 22, 2022 15:16
@Girgias
Copy link
Member Author

Girgias commented Aug 22, 2022

I might have a possible explanation as to why I'm getting the refcount issues, is that the zend_string* is stored in the INI hashtable, but I don't copy it when storing it in the globals table.
And when the INI setting gets updated its refcount is decreased which also happens when the return value is freed.

@Girgias Girgias force-pushed the session-ini-refactoring branch from 7ab79e4 to c0178cc Compare August 30, 2022 12:27
Girgias and others added 7 commits October 19, 2022 16:40
However, the code is somewhat disgusting as I'm hitting
Zend/zend_types.h:1222: zend_gc_delref: Assertion (zval_gc_flags((p)->u.type_info) & ((1<<7)|(1<<8))) != (1<<7) failed.
Failures that I don't understand.
Also fixed a bug where nul bytes where not properly checked
Co-authored-by: Tim Düsterhus <[email protected]>
@Girgias Girgias force-pushed the session-ini-refactoring branch from c0178cc to f9e3e29 Compare October 19, 2022 15:40
Copy link
Contributor

@jorgsowa jorgsowa left a comment

Choose a reason for hiding this comment

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

I didn't find this PR earlier and I merged already fixes included in here. However, it's pity that it didn't land in 8.4. Would be useful

@Girgias
Copy link
Member Author

Girgias commented Sep 9, 2024

I didn't find this PR earlier and I merged already fixes including in here. However, it's pity that it didn't land in 8.4. Would be useful

If you want, you can rework the PR, as I have no recollection of this any more.

@iluuu1994 iluuu1994 closed this Oct 13, 2024
@Girgias Girgias deleted the session-ini-refactoring branch October 14, 2024 10:51
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.

5 participants