-
Notifications
You must be signed in to change notification settings - Fork 722
[daemon] fix unchecked iterator access in async start mounts #4006
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4006 +/- ##
==========================================
- Coverage 89.26% 89.25% -0.02%
==========================================
Files 260 260
Lines 14693 14696 +3
==========================================
+ Hits 13116 13117 +1
- Misses 1577 1579 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Testing this has proven to be hard since the |
I stumbled upon this one while trying to fix the #4005, specifically by calling the monitor->on_restart() function in the VM constructor. That resulted in a crash since the operative_instances map is actively being populated during the constructor call: multipass/src/daemon/daemon.cpp Lines 1370 to 1371 in 13f8025
|
Signed-off-by: Mustafa Kemal Gilor <mustafa.gilor@canonical.com>
084d1e3
to
e00810d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! There is still the issue of thread safety, but at least it might not break as bad hopefully if we're lucky.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch, it looks good to me.
@@ -3425,8 +3425,15 @@ mp::Daemon::async_wait_for_ssh_and_start_mounts_for(const std::string& name, con | |||
fmt::memory_buffer errors; | |||
try | |||
{ | |||
auto it = operative_instances.find(name); | |||
auto vm = it->second; | |||
const auto& it = operative_instances.find(name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const auto&
and const auto
should not make a difference here since the find
function returns value.
MULTI-1913