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 osrm-contract, tests, on Windows #5882

Merged
merged 1 commit into from
Nov 18, 2020

Conversation

mjjbell
Copy link
Member

@mjjbell mjjbell commented Nov 14, 2020

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 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.

Tasklist

Requirements / Relations

#5872 has related discussion on osrm-contract failing on Windows

return false;

static const constexpr char fmt[sizeof...(Fmt)] = {Fmt...};

if (first + sizeof(fmt) < last && std::equal(fmt, fmt + sizeof(fmt), first + 1u))
Copy link
Member Author

Choose a reason for hiding this comment

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

first + sizeof(fmt) creates iterator beyond end.

@@ -346,7 +346,7 @@ template <typename GroupBlockPolicy, storage::Ownership Ownership> struct Indexe
const GroupBlockPolicy block;
block.ReadRefrencedBlock(blocks[block_idx], internal_idx, first, last);

return adapt(&*first, &*last);
Copy link
Member Author

Choose a reason for hiding this comment

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

For empty container, *first and *last can both be dereferencing the end iterator.

@@ -11,9 +11,11 @@
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) \
Copy link
Member Author

@mjjbell mjjbell Nov 14, 2020

Choose a reason for hiding this comment

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

Failed if lhs or rhs is expression creating a value (e.g. a literal). begin() and end() would reference different containers.

@@ -38,8 +38,8 @@ void test_rw(const Offsets &offsets, const Data &data)

for (std::size_t index = 0; index < offsets.size() - 1; ++index)
{
typename IndexedData::ResultType expected_result(&data[offsets[index]],
&data[offsets[index + 1]]);
Copy link
Member Author

Choose a reason for hiding this comment

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

Potential subscript out of range.

@@ -175,4 +178,56 @@ BOOST_AUTO_TEST_CASE(mlp_sorted)
BOOST_CHECK_EQUAL(mlp.EndChildren(4, 0), 2);
}

BOOST_AUTO_TEST_CASE(large_cell_number)
Copy link
Member Author

@mjjbell mjjbell Nov 15, 2020

Choose a reason for hiding this comment

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

Created this to detect #5878, but it also found an issue with 32 bit builds.

@mjjbell mjjbell force-pushed the mbell/windows_contractor branch from 3aac5b3 to 2fe8334 Compare November 15, 2020 12:46
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.
@mjjbell mjjbell force-pushed the mbell/windows_contractor branch from 2fe8334 to 96acdaf Compare November 15, 2020 14:22
::XCOPY /Y corech\*.* ..\test\data\corech\
::XCOPY /Y mld\*.* ..\test\data\mld\
::unit_tests\%Configuration%\library-tests.exe
ECHO running partitioner-tests.exe ...
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@akashihi akashihi merged commit a3f1c2a into Project-OSRM:master Nov 18, 2020
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