Skip to content

Fix iterator comparison bug in expr_iterator #1610

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 1 commit into from

Conversation

reuk
Copy link
Contributor

@reuk reuk commented Nov 22, 2017

After calling mutate() on an expr_iterator, a new state struct is created, containing iterators over the operands of a new expr created by copy-on-write behaviour. When this struct is compared for equality with the current struct at the back of the stack, iterators from two different collections are compared, which is undefined behaviour.

This patch changes the equality comparison to check the size of the iterator range in each state struct, rather than comparing iterators directly. This way, there's no danger of comparing iterators from different collections.

This bug was found by enabling -D_GLIBCXX_DEBUG. I suggest that this debug mode is added to Travis.

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