From 62ec0b10d4f07083e32fc34539da4b8c1ddff31d Mon Sep 17 00:00:00 2001 From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> Date: Thu, 26 Oct 2023 12:27:19 -0400 Subject: [PATCH] don't run compile task callback when socket being dtored --- .../webassembly/runtimes/eos-vm-oc/compile_monitor.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libraries/chain/webassembly/runtimes/eos-vm-oc/compile_monitor.cpp b/libraries/chain/webassembly/runtimes/eos-vm-oc/compile_monitor.cpp index d74fe26574..01ae7ecaba 100644 --- a/libraries/chain/webassembly/runtimes/eos-vm-oc/compile_monitor.cpp +++ b/libraries/chain/webassembly/runtimes/eos-vm-oc/compile_monitor.cpp @@ -114,7 +114,13 @@ struct compile_monitor_session { void read_message_from_compile_task(std::list>::iterator current_compile_it) { auto& [code, socket] = *current_compile_it; socket.async_wait(local::datagram_protocol::socket::wait_read, [this, current_compile_it](auto ec) { - //at this point we only expect 1 of 2 things to happen: we either get a reply (success), or we get no reply (failure) + //at this point we generally expect 1 of 2 things to happen: we either get a reply (success), or we get an error reading from the + // socket (failure). But there is also a third possibility that this compile_monitor_session is being destroyed and thus the + // socket is being destroyed by way of current_compiles being destroyed. Since this is an async_wait() and not an async_read(), + // for now just consider any error as being due to cancellation at dtor time and completely bail out (there aren't many other + // potential errors for an asnyc_wait) + if(ec) + return; auto& [code, socket] = *current_compile_it; auto [success, message, fds] = read_message_with_fds(socket);