From 4a8f336c160e777e6d27adef4c26f38140a0d1eb Mon Sep 17 00:00:00 2001 From: Alexander Polyakov Date: Fri, 13 Feb 2026 19:30:43 +0300 Subject: [PATCH 1/3] check iterators before erase --- runtime-light/stdlib/rpc/rpc-api.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/runtime-light/stdlib/rpc/rpc-api.cpp b/runtime-light/stdlib/rpc/rpc-api.cpp index 2e3720f107..23d2c73458 100644 --- a/runtime-light/stdlib/rpc/rpc-api.cpp +++ b/runtime-light/stdlib/rpc/rpc-api.cpp @@ -183,8 +183,12 @@ kphp::coro::task> rpc_tl_query_result_one_impl(int64_t query_id) no const auto it_response_fetcher{rpc_client_instance_st.response_fetcher_instances.find(query_id)}; const auto it_fork_task{rpc_client_instance_st.response_awaiter_tasks.find(query_id)}; const vk::final_action finalizer{[&rpc_client_instance_st, it_response_fetcher, it_fork_task] noexcept { - rpc_client_instance_st.response_fetcher_instances.erase(it_response_fetcher); - rpc_client_instance_st.response_awaiter_tasks.erase(it_fork_task); + if (it_response_fetcher != rpc_client_instance_st.response_fetcher_instances.end()) [[likely]] { + rpc_client_instance_st.response_fetcher_instances.erase(it_response_fetcher); + } + if (it_fork_task != rpc_client_instance_st.response_awaiter_tasks.end()) [[likely]] { + rpc_client_instance_st.response_awaiter_tasks.erase(it_fork_task); + } }}; if (it_response_fetcher == rpc_client_instance_st.response_fetcher_instances.end() || it_fork_task == rpc_client_instance_st.response_awaiter_tasks.end()) @@ -236,8 +240,12 @@ kphp::coro::task> typed_rpc_tl_query_result_ const auto it_response_fetcher{rpc_client_instance_st.response_fetcher_instances.find(query_id)}; const auto it_fork_task{rpc_client_instance_st.response_awaiter_tasks.find(query_id)}; const vk::final_action finalizer{[&rpc_client_instance_st, it_response_fetcher, it_fork_task] noexcept { - rpc_client_instance_st.response_fetcher_instances.erase(it_response_fetcher); - rpc_client_instance_st.response_awaiter_tasks.erase(it_fork_task); + if (it_response_fetcher != rpc_client_instance_st.response_fetcher_instances.end()) [[likely]] { + rpc_client_instance_st.response_fetcher_instances.erase(it_response_fetcher); + } + if (it_fork_task != rpc_client_instance_st.response_awaiter_tasks.end()) [[likely]] { + rpc_client_instance_st.response_awaiter_tasks.erase(it_fork_task); + } }}; if (it_response_fetcher == rpc_client_instance_st.response_fetcher_instances.end() || it_fork_task == rpc_client_instance_st.response_awaiter_tasks.end()) From a4b68bbfff95f13d3bfb109e3828ac6aaeb88aea Mon Sep 17 00:00:00 2001 From: Alexander Polyakov Date: Sat, 14 Feb 2026 18:22:44 +0300 Subject: [PATCH 2/3] [k2] add missing fetch_float and can_throw to vk_json_encode_safe --- builtin-functions/kphp-light/stdlib/rpc.txt | 3 +++ builtin-functions/kphp-light/stdlib/vkext-functions.txt | 1 + 2 files changed, 4 insertions(+) diff --git a/builtin-functions/kphp-light/stdlib/rpc.txt b/builtin-functions/kphp-light/stdlib/rpc.txt index 6f440baa13..c88b464163 100644 --- a/builtin-functions/kphp-light/stdlib/rpc.txt +++ b/builtin-functions/kphp-light/stdlib/rpc.txt @@ -76,6 +76,9 @@ function fetch_byte () ::: int; /** @kphp-extern-func-info can_throw */ function fetch_long () ::: int; +/** @kphp-extern-func-info can_throw */ +function fetch_float () ::: float; + /** @kphp-extern-func-info can_throw */ function fetch_double () ::: float; diff --git a/builtin-functions/kphp-light/stdlib/vkext-functions.txt b/builtin-functions/kphp-light/stdlib/vkext-functions.txt index 18a68e6f0c..7f963d48c5 100644 --- a/builtin-functions/kphp-light/stdlib/vkext-functions.txt +++ b/builtin-functions/kphp-light/stdlib/vkext-functions.txt @@ -18,6 +18,7 @@ function vk_whitespace_pack ($str ::: string, $html_opt ::: bool = false) ::: st function vk_sp_full_simplify ($str ::: string) ::: string; +/** @kphp-extern-func-info can_throw */ function vk_json_encode_safe ($v ::: mixed) ::: string; function vk_stats_hll_merge($str ::: mixed) ::: string | false; From 94388237020f619eec5bdfbcd84005ca0a3bb311 Mon Sep 17 00:00:00 2001 From: Alexander Polyakov Date: Sun, 15 Feb 2026 01:45:26 +0300 Subject: [PATCH 3/3] wrap wait with TRY_CALL_CORO --- runtime-light/stdlib/fork/fork-functions.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runtime-light/stdlib/fork/fork-functions.h b/runtime-light/stdlib/fork/fork-functions.h index f528e988a6..fdcaf52b65 100644 --- a/runtime-light/stdlib/fork/fork-functions.h +++ b/runtime-light/stdlib/fork/fork-functions.h @@ -18,6 +18,7 @@ #include "runtime-light/coroutine/shared-task.h" #include "runtime-light/coroutine/task.h" #include "runtime-light/coroutine/type-traits.h" +#include "runtime-light/stdlib/diagnostics/exception-functions.h" #include "runtime-light/stdlib/diagnostics/logs.h" #include "runtime-light/stdlib/fork/fork-state.h" #include "runtime-light/stdlib/fork/fork-storage.h" @@ -145,7 +146,7 @@ template kphp::coro::task f$wait_multi(array fork_ids) noexcept { T res{}; for (const auto& it : std::as_const(fork_ids)) { - res.set_value(it.get_key(), co_await f$wait(it.get_value())); + res.set_value(it.get_key(), TRY_CALL_CORO(typename T::value_type, T, co_await f$wait(it.get_value()))); } co_return std::move(res); }