From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id D29EA1382C5 for ; Mon, 23 Apr 2018 02:41:27 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 137D1E0ACD; Mon, 23 Apr 2018 02:41:27 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id CED3AE0ACD for ; Mon, 23 Apr 2018 02:41:26 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 34D1E335C36 for ; Mon, 23 Apr 2018 02:41:24 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id AC55E27E for ; Mon, 23 Apr 2018 02:41:22 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1524451133.bb2484afc217058267b5ba5d2d792bc1c46203b7.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/_emerge/ X-VCS-Repository: proj/portage X-VCS-Files: pym/_emerge/Scheduler.py pym/_emerge/create_world_atom.py X-VCS-Directories: pym/_emerge/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: bb2484afc217058267b5ba5d2d792bc1c46203b7 X-VCS-Branch: master Date: Mon, 23 Apr 2018 02:41:22 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: d1fb8b9c-8d34-499e-9af8-f747b4d7d3ec X-Archives-Hash: 7d9e6530a78369447ab46533d4f95d8b commit: bb2484afc217058267b5ba5d2d792bc1c46203b7 Author: Zac Medico gentoo org> AuthorDate: Mon Apr 23 02:27:53 2018 +0000 Commit: Zac Medico gentoo org> CommitDate: Mon Apr 23 02:38:53 2018 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=bb2484af Scheduler: fix create_world_atom event loop recursion (bug 653848) Generate world atoms while the event loop is not running, since otherwise portdbapi match calls in the create_world_atom function could trigger event loop recursion. Bug: https://bugs.gentoo.org/653848 pym/_emerge/Scheduler.py | 19 ++++++++++++++----- pym/_emerge/create_world_atom.py | 6 ++++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py index 71fe3e07d..6778708bb 100644 --- a/pym/_emerge/Scheduler.py +++ b/pym/_emerge/Scheduler.py @@ -448,6 +448,7 @@ class Scheduler(PollScheduler): self._pkg_cache = {} self._digraph = None self._mergelist = [] + self._world_atoms = None self._deep_system_deps.clear() return @@ -456,6 +457,18 @@ class Scheduler(PollScheduler): self._digraph = graph_config.graph self._mergelist = graph_config.mergelist + # Generate world atoms while the event loop is not running, + # since otherwise portdbapi match calls in the create_world_atom + # function could trigger event loop recursion. + self._world_atoms = {} + for pkg in self._mergelist: + if getattr(pkg, 'operation', None) != 'merge': + continue + atom = create_world_atom(pkg, self._args_set, + pkg.root_config, before_install=True) + if atom is not None: + self._world_atoms[pkg] = atom + if "--nodeps" in self.myopts or \ (self._max_jobs is not True and self._max_jobs < 2): # save some memory @@ -1939,11 +1952,7 @@ class Scheduler(PollScheduler): atom = None if pkg.operation != "uninstall": - # Do this before acquiring the lock, since it queries the - # portdbapi which can call the global event loop, triggering - # a concurrent call to this method or something else that - # needs an exclusive (non-reentrant) lock on the world file. - atom = create_world_atom(pkg, args_set, root_config) + atom = self._world_atoms.get(pkg) try: diff --git a/pym/_emerge/create_world_atom.py b/pym/_emerge/create_world_atom.py index 74b0fa5d7..947f8088a 100644 --- a/pym/_emerge/create_world_atom.py +++ b/pym/_emerge/create_world_atom.py @@ -11,7 +11,7 @@ if sys.hexversion >= 0x3000000: else: _unicode = unicode -def create_world_atom(pkg, args_set, root_config): +def create_world_atom(pkg, args_set, root_config, before_install=False): """Create a new atom for the world file if one does not exist. If the argument atom is precise enough to identify a specific slot then a slot atom will be returned. Atoms that are in the system set may also be stored @@ -83,11 +83,13 @@ def create_world_atom(pkg, args_set, root_config): # If there is no installed package matching the SLOT atom, # it probably changed SLOT spontaneously due to USE=multislot, # so just record an unslotted atom. - if vardb.match(slot_atom): + if vardb.match(slot_atom) or before_install: # Now verify that the argument is precise # enough to identify a specific slot. matches = mydb.match(arg_atom) matched_slots = set() + if before_install: + matched_slots.add(pkg.slot) if mydb is vardb: for cpv in matches: matched_slots.add(mydb._pkg_str(cpv, None).slot)