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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

jere8184
Copy link
Contributor

No description provided.

@jere8184 jere8184 force-pushed the fix_paring_heap_UB branch 2 times, most recently from 73ae0c8 to cbf7ccb Compare January 24, 2025 18:18
@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
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

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