Skip to content

Commit 17e1503

Browse files
danpatPatrick Niklaus
authored andcommitted
Log helpful error message if mmap fails.
1 parent 875f482 commit 17e1503

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
- fixed a bug that could result in inconsistent behaviour when collapsing instructions
2929
- fixed a bug that could result in crashes when leaving a ferry directly onto a motorway ramp
3030
- fixed a bug in the tile plugin that resulted in discovering invalid edges for connections
31+
- improved error messages when missing files during traffic updates (#3114)
3132
- Debug Tiles
3233
- Added support for turn penalties
3334
- Internals

features/options/contract/invalid.feature

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,26 @@ Feature: osrm-contract command line options: invalid options
33

44
Background:
55
Given the profile "testbot"
6+
And the node map
7+
"""
8+
a b
9+
"""
10+
And the ways
11+
| nodes |
12+
| ab |
13+
And the data has been extracted
614

715
Scenario: osrm-contract - Non-existing option
816
When I try to run "osrm-contract --fly-me-to-the-moon"
917
Then stdout should be empty
1018
And stderr should contain "option"
1119
And stderr should contain "fly-me-to-the-moon"
1220
And it should exit with an error
21+
22+
# This tests the error messages when you try to use --segment-speed-file,
23+
# but osrm-extract has not been run with --generate-edge-lookup
24+
Scenario: osrm-contract - Someone forgot --generate-edge-lookup on osrm-extract
25+
When I try to run "osrm-contract --segment-speed-file /dev/null {processed_file}"
26+
Then stderr should contain "Error while trying to mmap"
27+
Then stderr should contain ".osrm.edge_penalties"
28+
And it should exit with an error

src/contractor/contractor.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -521,10 +521,18 @@ EdgeID Contractor::LoadEdgeExpandedGraph(
521521
using boost::interprocess::mapped_region;
522522
using boost::interprocess::read_only;
523523

524-
const file_mapping mapping{filename.c_str(), read_only};
525-
mapped_region region{mapping, read_only};
526-
region.advise(mapped_region::advice_sequential);
527-
return region;
524+
try
525+
{
526+
const file_mapping mapping{filename.c_str(), read_only};
527+
mapped_region region{mapping, read_only};
528+
region.advise(mapped_region::advice_sequential);
529+
return region;
530+
}
531+
catch (const std::exception &e)
532+
{
533+
util::Log(logERROR) << "Error while trying to mmap " + filename + ": " + e.what();
534+
throw;
535+
}
528536
};
529537

530538
const auto edge_based_graph_region = mmap_file(edge_based_graph_filename);

0 commit comments

Comments
 (0)