Fix crash when purge deleting while starting #3679
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
resolves #3279
There are several sources of crashes when running
delete -p
andstart
at the same time.One source stems from a race condition in the daemon involving multiple reads and writes to
operative_instances
concurrently. The crash source is from a callback created inon_restart
which can unsafely write intooperative_instances
if the instance has been deleted. A workaround is to ensure this is always a read operation and catching the resulting error, but this still causes UB and puts the thread in a corrupt state. Preventing the callback or having safe access into theoperative_instances
map would be better.Another is from callbacks in the
QemuVirtualMachine
which are called during or after the destruction of the VM instance. This is addressed by disconnecting the callbacks so they are not called when they shouldn't be and reconnecting them when appropriate.