﻿id	summary	reporter	owner	description	type	status	component	version	resolution	keywords	cc	guest	host
13801	Save settings deadlock	a.urakov		"There is possible deadlock on medium access when different machines save their settings. Deadlock occurs when these machines are commiting medias and saving modified registries at the same time.

In our case there are two machines (''1'' and ''2'') cloned with link option from ''common'' machine. We take snapshots of machines at the same time. So machine ''1'' saves modified registries (''VirtualBox::saveModifiedRegistries()'') for machine ''common'' (because information about ''1'' medias is saved in common settings due to linked cloning). Eventually it calls ''VirtualBox::saveMediaRegistry()'' which holds read lock on ''common'' medium and calls ''Medium::saveSettings()'' for every children. This recurses through all children mediums of ''common'' and holds read locks on all current recursion branch. So it tries to get read lock on ''2'' medium.

At the same time machine ''2'' commits media (''Machine::commitMedia()''). When it converts implicit attachment to normal it holds write lock on parent medium (the same medium thread ''1'' waits for) and tries to unlock all locked by session mediums (here I mean ''IMedium'' API-level locking, not object locking). Unlock procedure ''MediumLockList::Unlock()'' eventually calls ''Medium::unlockRead()'' for each medium in locked list (and ''common'' medium too). ''Medium::unlockRead()'' tries to get common medium write lock so threads are deadlocked.

Thank you in advance!
"	defect	closed	other	VirtualBox 4.3.20	fixed	save, settings, deadlock, media		all	Linux
