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 paring heap UB #1747

Merged
merged 2 commits into from
Feb 10, 2025
Merged

fix paring heap UB #1747

merged 2 commits into from
Feb 10, 2025

Conversation

jere8184
Copy link
Contributor

No description provided.

@jere8184 jere8184 force-pushed the fix_paring_heap_UB branch 3 times, most recently from cbf7ccb to 865289b Compare January 24, 2025 19:36
@heinezen
Copy link
Member

I'm not really in favor of this change as making the iteration over the heap nodes non-const can have severe side effects. e.g. by changing the node values that are used for comparison, which would result in corruption of the entire datastructure.

I thought about this for a while and I think we should use a dedicated erasure method for clear and not use the iter_all method. A simple breadth-first or depth-first search would be enough for this. Then we don't have to worry about invalid pointer accesses too.

@jere8184
Copy link
Contributor Author

e as making the iteration over the heap nodes non-const can have severe side effects. e.g. by changing the node values that are used for

Do you think it might be worth implementing an iterator for the tree?

@heinezen
Copy link
Member

Do you think it might be worth implementing an iterator for the tree?

That would be cool! Currently we can get a problem with the recursion depth if the tree is too large. An iterator should solve that.

@jere8184 jere8184 force-pushed the fix_paring_heap_UB branch 2 times, most recently from 6b485a4 to 2668d9e Compare January 26, 2025 16:40
@jere8184
Copy link
Contributor Author

Do you think it might be worth implementing an iterator for the tree?

That would be cool! Currently we can get a problem with the recursion depth if the tree is too large. An iterator should solve that.

iterator added

@TheJJ TheJJ added kevin-rebuild-pl0x instruct kevin to rebuild this pull request and removed kevin-rebuild-pl0x instruct kevin to rebuild this pull request labels Feb 4, 2025
@SFTbot SFTbot removed the kevin-rebuild-pl0x instruct kevin to rebuild this pull request label Feb 4, 2025
Copy link
Member

@heinezen heinezen left a comment

Choose a reason for hiding this comment

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

Very nice solution!

I changed the test code slightly at the end by changing the C array to a C++ std::array which is a bit more "stable" for test code.

@heinezen heinezen merged commit d7ee6a5 into SFTtech:master Feb 10, 2025
13 checks passed
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.

4 participants