Skip to content

Switch to reliable non-existent handle for QueryHeap items#4396

Merged
TheMarex merged 1 commit intoProject-OSRM:masterfrom
mloskot:ml/queryheap-none-handle
Aug 30, 2017
Merged

Switch to reliable non-existent handle for QueryHeap items#4396
TheMarex merged 1 commit intoProject-OSRM:masterfrom
mloskot:ml/queryheap-none-handle

Conversation

@mloskot
Copy link
Copy Markdown
Member

@mloskot mloskot commented Aug 10, 2017

Issue

Default-constructed objects of (boost::heap) handle_type are singular, including the wrapped handle_type::iterator.

Apparently, MSVC iterator debug facilities strictly require that one singular instance is compared to another singular instance.

It is not possible to get check-comparabe iterators of non-singular and singular instances as owning container will always mismatch.

Initially investigated at Boost ML (https://lists.boost.org/boost-users/2017/08/87787.php), eventually received confirmation via SO (https://stackoverflow.com/a/45622940/151641)

Tasklist

  • review
  • adjust for comments

@mloskot mloskot mentioned this pull request Aug 10, 2017
7 tasks
Copy link
Copy Markdown
Member

@daniel-j-h daniel-j-h left a comment

Choose a reason for hiding this comment

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

Urgh thanks for chasing this one down.

Could you add your findings, this ticket, and the boost ml / stackoverflow links as comment to the code please.

Copy link
Copy Markdown
Member

@TheMarex TheMarex left a comment

Choose a reason for hiding this comment

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

Urg this is an ugly one. Good catch. 👍 Could you run ./scripts/format.sh? Our formatting check on CI is complaining, otherwise this is good to merge.

BOOST_ASSERT(WasInserted(node));
const Key index = node_index.peek_index(node);
return inserted_nodes[index].handle == HeapHandle{};
auto const end_it = const_cast<HeapContainer&>(heap).end(); // non-const iterator
Copy link
Copy Markdown
Contributor

@oxidase oxidase Aug 11, 2017

Choose a reason for hiding this comment

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

interestingly this method is used only in DecreaseKey in assertion.
I guess it can be removed completely,
and in DecreaseKey added a line
BOOST_ASSERT(reference.handle != HeapContainer::s_handle_from_iterator(heap.end())); // was not removed

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@daniel-j-h & @TheMarex shall I update the PR as you suggest or simply remove the method completely as @oxidase suggests?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@mloskot I would like to keep the interface change out of this PR. :-)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@TheMarex Makes sense.

@mloskot
Copy link
Copy Markdown
Member Author

mloskot commented Aug 12, 2017

I'll be more than happy to improve the PR but after I'm back from short trip in a week or two. No access to any compiler enabled computer ATM.

@mloskot
Copy link
Copy Markdown
Member Author

mloskot commented Aug 28, 2017

while waiting for response to my question in #4396 (comment), I did apply:

  • added relevant comment as per @daniel-j-h request.
  • run ./scripts/format.sh using clang-format 3.8 fixing a few inconsistencies, as per @TheMarex request

PR updated with both changes.

Default-constructed objects of (boost::heap) handle_type are singular,
including the wrapped handle_type::iterator.
Apparently, MSVC iterator debug facilities strictly require that
one singular instance is compared to another singular instance.
It is not possible to get check-comparabe iterators of non-singular
and singular instances as owning container will always mismatch.
@TheMarex
Copy link
Copy Markdown
Member

@mloskot looks good to me, I restarted the travis build. I think the failure was unrelated. 👍

@mloskot
Copy link
Copy Markdown
Member Author

mloskot commented Aug 30, 2017

@TheMarex Thanks

@TheMarex TheMarex merged commit 2385602 into Project-OSRM:master Aug 30, 2017
@mloskot mloskot deleted the ml/queryheap-none-handle branch August 30, 2017 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants