Skip to content

Commit 746c710

Browse files
committed
Fix metric offset overflow for large MLD partitions
Each MLD cell has source and destination nodes. MLD is keeping a |source| x |destination| sized table for various metrics (distances, durations, etc) from each source to all destinations in a cell. It stores all of the values for a metric in one large array, with an offset for each cell to find its values. The offset is currently limited to 32 bit values, which overflows on very large graphs (e.g. Planet OSM). We fix this by changing the offsets to be size types.
1 parent 8e100ea commit 746c710

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- FIXED: Fixed Boost link flags in pkg-config file. [#6083](https://github.com/Project-OSRM/osrm-backend/pull/6083)
99
- Routing:
1010
- FIXED: Fix generation of inefficient MLD partitions [#6084](https://github.com/Project-OSRM/osrm-backend/pull/6084)
11+
- FIXED: Fix metric offset overflow for large MLD partitions [#6124](https://github.com/Project-OSRM/osrm-backend/pull/6124)
1112

1213
# 5.25.0
1314
- Changes from 5.24.0

include/partitioner/cell_storage.hpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,13 @@ namespace detail
5252
template <storage::Ownership Ownership> class CellStorageImpl
5353
{
5454
public:
55-
using ValueOffset = std::uint32_t;
56-
using BoundaryOffset = std::uint32_t;
55+
using ValueOffset = std::size_t;
56+
using BoundaryOffset = std::size_t;
5757
using BoundarySize = std::uint32_t;
58-
using SourceIndex = std::uint32_t;
59-
using DestinationIndex = std::uint32_t;
6058

6159
static constexpr auto INVALID_VALUE_OFFSET = std::numeric_limits<ValueOffset>::max();
6260
static constexpr auto INVALID_BOUNDARY_OFFSET = std::numeric_limits<BoundaryOffset>::max();
61+
static constexpr auto MAX_BOUNDARY_SIZE = std::numeric_limits<BoundarySize>::max();
6362

6463
struct CellData
6564
{
@@ -324,7 +323,10 @@ template <storage::Ownership Ownership> class CellStorageImpl
324323
[this, insert_cell_boundary](auto begin, auto end) {
325324
insert_cell_boundary(
326325
source_boundary,
327-
[](auto &cell, auto value) { cell.num_source_nodes = value; },
326+
[](auto &cell, auto value) {
327+
BOOST_ASSERT(value < MAX_BOUNDARY_SIZE);
328+
cell.num_source_nodes = value;
329+
},
328330
[](auto &cell, auto value) { cell.source_boundary_offset = value; },
329331
begin,
330332
end);
@@ -335,7 +337,10 @@ template <storage::Ownership Ownership> class CellStorageImpl
335337
[this, insert_cell_boundary](auto begin, auto end) {
336338
insert_cell_boundary(
337339
destination_boundary,
338-
[](auto &cell, auto value) { cell.num_destination_nodes = value; },
340+
[](auto &cell, auto value) {
341+
BOOST_ASSERT(value < MAX_BOUNDARY_SIZE);
342+
cell.num_destination_nodes = value;
343+
},
339344
[](auto &cell, auto value) { cell.destination_boundary_offset = value; },
340345
begin,
341346
end);

0 commit comments

Comments
 (0)