From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id 2C14CE00C1A; Tue, 15 Nov 2016 21:55:57 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, * medium trust * [147.11.146.13 listed in list.dnswl.org] Received: from mail1.windriver.com (mail1.windriver.com [147.11.146.13]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id D6FFAE00BF8 for ; Tue, 15 Nov 2016 21:55:52 -0800 (PST) Received: from ALA-HCA.corp.ad.wrs.com (ala-hca.corp.ad.wrs.com [147.11.189.40]) by mail1.windriver.com (8.15.2/8.15.1) with ESMTPS id uAG5tp5O015657 (version=TLSv1 cipher=AES128-SHA bits=128 verify=FAIL) for ; Tue, 15 Nov 2016 21:55:51 -0800 (PST) Received: from ALA-MBA.corp.ad.wrs.com ([169.254.3.156]) by ALA-HCA.corp.ad.wrs.com ([147.11.189.40]) with mapi id 14.03.0294.000; Tue, 15 Nov 2016 21:55:51 -0800 From: "Reyna, David" To: "toaster@yoctoproject.org" Thread-Topic: [Toaster] [PATCH 1/1] toaster: protect against circular Layer dependencies Thread-Index: AdI/zfobxOAtrg8mQ06DsJAo6jRBlg== Date: Wed, 16 Nov 2016 05:55:50 +0000 Message-ID: <5E53D14CE4667A45B9A06760DE5D13D0BF7D733B@ALA-MBA.corp.ad.wrs.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [147.11.116.64] MIME-Version: 1.0 Subject: [PATCH 1/1] toaster: protect against circular Layer dependencies X-BeenThere: toaster@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Web based interface for BitBake List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Nov 2016 05:55:57 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi all, I found this issue while testing some new Wind River layers, where they wer= e required to be included together which meant that they had an intentional= circular dependency. I think that there are no current layers in the OE Layer Index with a circu= lar dependency, nor can we create a custom one since the current Toaster UI= does not allow that. However, these will be coming so I want to preempt th= at problem upstream with this patch. http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/commit/?h=3Ddreyna= %2Fcircular_dependencies_10631 - David=20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >From fdc3e055eb2fcad098711f03d7ca1798f926e5ae Mon Sep 17 00:00:00 2001 From: David Reyna Date: Tue, 15 Nov 2016 21:36:25 -0800 Subject: [PATCH] toaster: protect circular dependencies Limit the recursion (to say 20 levels) when processing layer dependencies so that circular dependecies do not cause infinite decent and an out-of-memory failure. The duplicate found layers are already immediately filtered in the code. [YOCTO #10630] Signed-off-by: David Reyna --- bitbake/lib/toaster/orm/models.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/mo= dels.py index 4f8510c..061d84e 100644 --- a/bitbake/lib/toaster/orm/models.py +++ b/bitbake/lib/toaster/orm/models.py @@ -1478,17 +1478,21 @@ class Layer_Version(models.Model): =20 def get_alldeps(self, project_id): """Get full list of unique layer dependencies.""" - def gen_layerdeps(lver, project): + def gen_layerdeps(lver, project, depth): + if depth=3D=3D0: + return for ldep in lver.dependencies.all(): yield ldep.depends_on # get next level of deps recursively calling gen_layerdeps - for subdep in gen_layerdeps(ldep.depends_on, project): + for subdep in gen_layerdeps(ldep.depends_on, project,depth= -1): yield subdep =20 project =3D Project.objects.get(pk=3Dproject_id) result =3D [] projectlvers =3D [player.layercommit for player in project.project= layer_set.all()] - for dep in gen_layerdeps(self, project): + # protect against infinite layer dependency loops + maxdepth=3D20 + for dep in gen_layerdeps(self, project, maxdepth): # filter out duplicates and layers already belonging to the pr= oject if dep not in result + projectlvers: result.append(dep) --=20 1.9.1