Skip to content

Fix osrm-contract, tests, on Windows#5882

Merged
akashihi merged 1 commit intoProject-OSRM:masterfrom
mjjbell:mbell/windows_contractor
Nov 18, 2020
Merged

Fix osrm-contract, tests, on Windows#5882
akashihi merged 1 commit intoProject-OSRM:masterfrom
mjjbell:mbell/windows_contractor

Conversation

@mjjbell
Copy link
Copy Markdown
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


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

if (first + sizeof(fmt) < last && std::equal(fmt, fmt + sizeof(fmt), first + 1u))
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.

first + sizeof(fmt) creates iterator beyond end.

const GroupBlockPolicy block;
block.ReadRefrencedBlock(blocks[block_idx], internal_idx, first, last);

return adapt(&*first, &*last);
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.

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

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

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

BOOST_CHECK_EQUAL(mlp.EndChildren(4, 0), 2);
}

BOOST_AUTO_TEST_CASE(large_cell_number)
Copy link
Copy Markdown
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
Copy Markdown
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