Vincent Bernat
2018-Apr-04 18:38 UTC
Re: [libvirt-users] error : virHashForEach:597 : Hash operation not allowed during iteration
❦ 4 avril 2018 17:00 +0200, Vincent Bernat <bernat@luffy.cx> :>>> You can do that locally, but as a patch it's very unlikely to be >>> accepted upstream because we've introduced RW locks to be able to access >>> domain list from multiple threads. >> >> Looking a bit more, the whole "iterating" bit is currently >> unsafe. First, it is racy since it's "check then take". Two threads may >> check the value is false and start iterating both. Moreover, at some >> places, it is not set, for example in virHashAddOrUpdateEntry(). So, it >> would be possible to call this function and during the update to iterate >> over the hash. This seems to be prevented only by callers using RW >> lock. So, it seems we can just remove this "iterating" bool and just >> check all users of these functions are using the appropriate lock. > > My bad, I didn't see the use of table->current...It seems it can also go away if caller correctly use a RW lock. I am currently testing the attached patch on a few servers (patch for master, but applied on our 3.6 version). After checking many locations, I came to conclusion that locks are used correctly. -- Use library functions. - The Elements of Programming Style (Kernighan & Plauger)
Michal Privoznik
2018-Apr-05 15:00 UTC
Re: [libvirt-users] error : virHashForEach:597 : Hash operation not allowed during iteration
On 04/04/2018 08:38 PM, Vincent Bernat wrote:> 0001-util-don-t-check-for-parallel-iteration-in-hash-rela.patch > > > From 7bf32825325b124edce58687a8cd2ceff13328b9 Mon Sep 17 00:00:00 2001 > From: Vincent Bernat <vincent@bernat.im> > Date: Wed, 4 Apr 2018 16:25:37 +0200 > Subject: [PATCH] util: don't check for parallel iteration in hash-related > functionsCan you send this as a regular patch? I'd like to review it. Michal
Vincent Bernat
2018-Apr-05 15:55 UTC
Re: [libvirt-users] error : virHashForEach:597 : Hash operation not allowed during iteration
❦ 5 avril 2018 17:00 +0200, Michal Privoznik <mprivozn@redhat.com> :>> 0001-util-don-t-check-for-parallel-iteration-in-hash-rela.patch >> >> >> From 7bf32825325b124edce58687a8cd2ceff13328b9 Mon Sep 17 00:00:00 2001 >> From: Vincent Bernat <vincent@bernat.im> >> Date: Wed, 4 Apr 2018 16:25:37 +0200 >> Subject: [PATCH] util: don't check for parallel iteration in hash-related >> functions > > Can you send this as a regular patch? I'd like to review it.What do you mean by regular? Not an attachment? Through git send-email? FI, I am now running this patch on 22 hosts without any detected issues. -- Let the machine do the dirty work. - The Elements of Programming Style (Kernighan & Plauger)
Seemingly Similar Threads
- Re: error : virHashForEach:597 : Hash operation not allowed during iteration
- Re: error : virHashForEach:597 : Hash operation not allowed during iteration
- Re: error : virHashForEach:597 : Hash operation not allowed during iteration
- Re: error : virHashForEach:597 : Hash operation not allowed during iteration
- Re: error : virHashForEach:597 : Hash operation not allowed during iteration