Fix osrm-contract, tests, on Windows#5882
Merged
akashihi merged 1 commit intoProject-OSRM:masterfrom Nov 18, 2020
Merged
Conversation
mjjbell
commented
Nov 14, 2020
|
|
||
| static const constexpr char fmt[sizeof...(Fmt)] = {Fmt...}; | ||
|
|
||
| if (first + sizeof(fmt) < last && std::equal(fmt, fmt + sizeof(fmt), first + 1u)) |
Member
Author
There was a problem hiding this comment.
first + sizeof(fmt) creates iterator beyond end.
mjjbell
commented
Nov 14, 2020
| const GroupBlockPolicy block; | ||
| block.ReadRefrencedBlock(blocks[block_idx], internal_idx, first, last); | ||
|
|
||
| return adapt(&*first, &*last); |
Member
Author
There was a problem hiding this comment.
For empty container, *first and *last can both be dereferencing the end iterator.
mjjbell
commented
Nov 14, 2020
| const auto &rhs = {__VA_ARGS__}; \ | ||
| BOOST_CHECK_EQUAL_COLLECTIONS(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); \ | ||
| } while (0) | ||
| #define CHECK_EQUAL_COLLECTIONS(lhs, rhs) \ |
Member
Author
There was a problem hiding this comment.
Failed if lhs or rhs is expression creating a value (e.g. a literal). begin() and end() would reference different containers.
mjjbell
commented
Nov 14, 2020
| for (std::size_t index = 0; index < offsets.size() - 1; ++index) | ||
| { | ||
| typename IndexedData::ResultType expected_result(&data[offsets[index]], | ||
| &data[offsets[index + 1]]); |
Member
Author
There was a problem hiding this comment.
Potential subscript out of range.
mjjbell
commented
Nov 15, 2020
| BOOST_CHECK_EQUAL(mlp.EndChildren(4, 0), 2); | ||
| } | ||
|
|
||
| BOOST_AUTO_TEST_CASE(large_cell_number) |
Member
Author
There was a problem hiding this comment.
Created this to detect #5878, but it also found an issue with 32 bit builds.
3aac5b3 to
2fe8334
Compare
As part of graph contraction, node renumbering leads to in-place permuting of graph state, including boolean vector elements. std::vector<bool> returns proxy objects when referencing individual bits. To correctly swap bool elements using MSVC, we need to explicitly apply std::vector<bool>::swap. Making this change fixes osrm-contract on Windows. We also correct failing tests and other undefined behaviours (mainly iterator access outside boundaries) highlighted by MSVC.
2fe8334 to
96acdaf
Compare
akashihi
reviewed
Nov 16, 2020
| ::XCOPY /Y corech\*.* ..\test\data\corech\ | ||
| ::XCOPY /Y mld\*.* ..\test\data\mld\ | ||
| ::unit_tests\%Configuration%\library-tests.exe | ||
| ECHO running partitioner-tests.exe ... |
akashihi
approved these changes
Nov 16, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
As part of graph contraction, node renumbering leads to in-place permuting of graph state, including boolean vector elements.
std::vector<bool>returns proxy objects when referencing individual bits. To correctly swap boolean elements using MSVC, we need to explicitly applystd::vector<bool>::swap.Making this change fixes
osrm-contracton Windows.We also correct failing tests and other undefined behaviours (mainly iterator access outside boundaries) highlighted by MSVC.
Tasklist
Requirements / Relations
#5872 has related discussion on
osrm-contractfailing on Windows