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

fix(proxy): sticky sessions null dereference #673

Merged
merged 1 commit into from
Aug 28, 2023

Conversation

olevski
Copy link
Member

@olevski olevski commented Aug 27, 2023

This is just a draft, not ready for review yet.

/deploy #persist

@olevski olevski requested a review from a team as a code owner August 27, 2023 20:37
@olevski olevski marked this pull request as draft August 27, 2023 20:37
@olevski olevski temporarily deployed to renku-ci-gw-673 August 27, 2023 20:37 — with GitHub Actions Inactive
@RenkuBot
Copy link
Contributor

You can access the deployment of this PR at https://renku-ci-gw-673.dev.renku.ch

@olevski olevski force-pushed the 672-fix-sticky-sessions-null-deref branch from 62bbb4a to 3e133a0 Compare August 28, 2023 08:53
@olevski olevski temporarily deployed to renku-ci-gw-673 August 28, 2023 08:53 — with GitHub Actions Inactive
@olevski
Copy link
Member Author

olevski commented Aug 28, 2023

The main reason for this bug is that I pre-allocate and pre-populate the array that will hold the endpoint slices. This "pre-populate" step is done by golang automatically with the "null" version of every value. And the null version of a pointer is a null pointer. Since the array contains endpoint slice pointers, when the core version is not ready and the reverse proxy is starting up, then it will keep 1 or 2 null pointers in the array because it will not replace the elements with the real endpoint slice if the endpoint slice is not pointing to a fully running core service.

Then further in the code it goes to sort the array of endpoint slices pointers and for this it needs to dereference the pointers because it uses a property of the endpoint slice as the sorting criteria. This is where things crash and burn.

The fix was as simple as replacing make([]*EndpointStoreItem, len(input)) with make([]*EndpointStoreItem, 0, len(input)). The first statement allocates and populates, the second only allocates but does not populate.

The other changes here are only cosmetic.

@olevski olevski marked this pull request as ready for review August 28, 2023 09:22
@olevski olevski linked an issue Aug 28, 2023 that may be closed by this pull request
@olevski olevski temporarily deployed to renku-ci-gw-673 August 28, 2023 09:31 — with GitHub Actions Inactive
Copy link
Contributor

@aledegano aledegano left a comment

Choose a reason for hiding this comment

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

Ah, yes our dear old Null Point Dereference :D
Thanks for the fix!

@olevski olevski deployed to renku-ci-gw-673 August 28, 2023 11:04 — with GitHub Actions Active
@olevski olevski merged commit ebd6624 into master Aug 28, 2023
@olevski olevski deleted the 672-fix-sticky-sessions-null-deref branch August 28, 2023 11:49
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.

Reverse proxy sticky sessions crashing on nil pointer dereference
3 participants