Skip to content
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

Make sure that capabilities for ngx_array are valid when the array is expanded. #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

qwattash
Copy link

In case ngx_array are expanded and there is space for a new item in the existing pool, the array capability is not updated and will have the wrong length.

@brooksdavis
Copy link
Member

There are more issues here. At a minimum, we need to check that elts is sufficiently aligned to permit the extension (possibly adding more than one element to allow it if the result won't be exactly representable), but if alignment is in play, there's a good chance that nalloc was set incorrectly in ngx_array_init since it should be rounded up as required.

@qwattash
Copy link
Author

Good point, I'll have a stab at fixing those as well. I'm also not sure what is happening to the old elts pointer, which appears to never be free'd?

@brooksdavis
Copy link
Member

Good point, I'll have a stab at fixing those as well. I'm also not sure what is happening to the old elts pointer, which appears to never be free'd?

Everything allocated by the pool is freed when the pool is freed (e.g. at the end of a transaction.) It's a bit odd that they don't call ngx_pfree, but maybe there are/were issues with stale references or maybe arrays are rarely big enough (since ngx_pfree only frees "large" objects and does so somewhat expensively.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants