From 95b2ed4fabc9181ddde845ac9684f4054738b76b Mon Sep 17 00:00:00 2001 From: Pablo Hoch Date: Tue, 24 May 2022 13:31:43 +0200 Subject: [PATCH 1/3] loader: handle file access errors on windows --- .pkg | 2 +- .pkg.lock | 4 ++-- base/loader/src/loader.cc | 38 +++++++++++++++++++++++++++++++++++--- 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/.pkg b/.pkg index 75a70f285..8c2ab048d 100644 --- a/.pkg +++ b/.pkg @@ -77,7 +77,7 @@ [utl] url=git@github.com:motis-project/utl.git branch=master - commit=6d7c7fd4e6167a1232bb5f7affcda9003e657ecf + commit=67524961674da10379ad82be71f29a0a003dd209 [guess] url=git@github.com:motis-project/guess.git branch=master diff --git a/.pkg.lock b/.pkg.lock index 1850c076d..fb01574b1 100644 --- a/.pkg.lock +++ b/.pkg.lock @@ -1,4 +1,4 @@ -13018458183320054341 +14261739304580180267 cista 9d5efe87ac5ee8215e26900cdcc5a13ce3381f0b zlib 1e1dfdedddb54a2e2cb8fec3b67f925233c495aa boost c90d53bdcd7ff741a416ae122b33c9c2a96e8be7 @@ -10,7 +10,7 @@ libosmium e35f4f63facbc87a0a5bf388bce19e6c4ed1dca7 protozero 8c9f3fa97c2cfdceef86d0b61818ae98e9328f29 Catch2 e5c9a58d66ff0780e956b5447573af9d6b9b2ca3 fmt c68ab4be8f3cb0e5c6eb181b3f419622e15e02bd -utl 6d7c7fd4e6167a1232bb5f7affcda9003e657ecf +utl 67524961674da10379ad82be71f29a0a003dd209 address-typeahead 9b33a191c05ee3f489492ea9a89253eaa26b91d4 conf 71febe940c0715ea69aa0c9980e08d31c5c946b8 context 797dd16e2b5e959997ddcd5bdeac4f80931169b6 diff --git a/base/loader/src/loader.cc b/base/loader/src/loader.cc index 2109e0495..715667928 100644 --- a/base/loader/src/loader.cc +++ b/base/loader/src/loader.cc @@ -7,6 +7,10 @@ #include #include +#ifdef _WIN32 +#include +#endif + #include "cista/serialization.h" #include "cista/targets/file.h" @@ -46,9 +50,9 @@ std::vector> parsers() { using dataset_mem_t = std::variant>; -schedule_ptr load_schedule(loader_options const& opt, - cista::memory_holder& schedule_buf, - std::string const& data_dir) { +schedule_ptr load_schedule_impl(loader_options const& opt, + cista::memory_holder& schedule_buf, + std::string const& data_dir) { ml::scoped_timer time("loading schedule"); // ensure there is an active progress tracker (e.g. for test cases) @@ -160,6 +164,34 @@ schedule_ptr load_schedule(loader_options const& opt, return sched; } +#ifdef _WIN32 +bool load_schedule_checked(loader_options const& opt, + cista::memory_holder& schedule_buf, + std::string const& data_dir, schedule_ptr& ptr) { + __try { + [&]() { ptr = load_schedule_impl(opt, schedule_buf, data_dir); }(); + return true; + } __except (GetExceptionCode() == EXCEPTION_IN_PAGE_ERROR + ? EXCEPTION_EXECUTE_HANDLER + : EXCEPTION_CONTINUE_SEARCH) { + return false; + } +} +#endif + +schedule_ptr load_schedule(loader_options const& opt, + cista::memory_holder& schedule_buf, + std::string const& data_dir) { +#ifdef _WIN32 + auto ptr = schedule_ptr{}; + utl::verify(load_schedule_checked(opt, schedule_buf, data_dir, ptr), + "load_schedule: file access error: EXCEPTION_IN_PAGE_ERROR"); + return ptr; +#else + return load_schedule_impl(opt, schedule_buf, data_dir); +#endif +} + schedule_ptr load_schedule(loader_options const& opt) { utl::verify(!opt.read_graph_, "load_schedule: read_graph requires buffer"); cista::memory_holder buf{}; From 853b9f8168b760cd7eaef1c4d586c0962a469881 Mon Sep 17 00:00:00 2001 From: Pablo Hoch Date: Tue, 24 May 2022 13:44:44 +0200 Subject: [PATCH 2/3] update cista --- .pkg | 2 +- .pkg.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.pkg b/.pkg index 8c2ab048d..ffa372241 100644 --- a/.pkg +++ b/.pkg @@ -5,7 +5,7 @@ [cista] url=git@github.com:felixguendling/cista.git branch=master - commit=9d5efe87ac5ee8215e26900cdcc5a13ce3381f0b + commit=3e6c6cec9593ae253a258a13c915677c19cab29e [conf] url=git@github.com:motis-project/conf.git branch=master diff --git a/.pkg.lock b/.pkg.lock index fb01574b1..9f9c5c2c3 100644 --- a/.pkg.lock +++ b/.pkg.lock @@ -1,5 +1,5 @@ -14261739304580180267 -cista 9d5efe87ac5ee8215e26900cdcc5a13ce3381f0b +8480001355610021823 +cista 3e6c6cec9593ae253a258a13c915677c19cab29e zlib 1e1dfdedddb54a2e2cb8fec3b67f925233c495aa boost c90d53bdcd7ff741a416ae122b33c9c2a96e8be7 cereal 5afa46f98d1c22627777c3f9d048fffe3f9763dc From e0391003f647504199c7d6191e55c7b1596b29b6 Mon Sep 17 00:00:00 2001 From: Pablo Hoch Date: Tue, 24 May 2022 14:13:17 +0200 Subject: [PATCH 3/3] fix utl::get_or_create errors --- base/loader/src/timezone_util.cc | 6 ++++-- libs/path/src/path_database_query.cc | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/base/loader/src/timezone_util.cc b/base/loader/src/timezone_util.cc index 54ece3495..19692a442 100644 --- a/base/loader/src/timezone_util.cc +++ b/base/loader/src/timezone_util.cc @@ -22,8 +22,10 @@ timezone_name_idx tz_cache::lookup_name(std::string_view timezone_name) { } else { prev_name_ = timezone_name; return prev_name_idx_ = - utl::get_or_create(timezone_name_idx_, timezone_name, - [&]() { return timezone_name_idx_.size(); }); + utl::get_or_create(timezone_name_idx_, timezone_name, [&]() { + return static_cast( + timezone_name_idx_.size()); + }); } } diff --git a/libs/path/src/path_database_query.cc b/libs/path/src/path_database_query.cc index 7ddbfc655..b3adc6f1d 100644 --- a/libs/path/src/path_database_query.cc +++ b/libs/path/src/path_database_query.cc @@ -115,10 +115,12 @@ void path_database_query::resolve_sequences_and_build_subqueries( for (auto j = 0ULL; j < segment->hints_rle()->Get(i + 1); ++j) { auto feature_id = segment->features()->Get(k); + auto const abs_feature_id = + static_cast(std::abs(feature_id)); auto* resolvable = - utl::get_or_create(subquery.map_, std::abs(feature_id), [&] { + utl::get_or_create(subquery.map_, abs_feature_id, [&] { auto r = std::make_unique(); - r->feature_id_ = std::abs(feature_id); + r->feature_id_ = abs_feature_id; return subquery.mem_.emplace_back(std::move(r)).get(); });