Bug 10630

Summary: Toaster: protect against circular Layer dependencies
Product: [Build System, Metadata & Runtime] Toaster Reporter: David Reyna <david.reyna>
Component: toasterAssignee: David Reyna <david.reyna>
Status: VERIFIED FIXED QA Contact: David Lopez Barriba <davidx.lopez.barriba>
Severity: normal    
Priority: Medium+ CC: jessica.zhang, stanciux.mihail
Version: 2.3   
Target Milestone: 2.3 M1   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description David Reyna 2016-11-09 07:10:25 UTC
If two layers declare that they are dependent on each other, Toaster will go into an infinite loop trying to resolve the dependencies.

Here is a patch for the Toaster front end. We may need an additional patch for the Toaster backend (bitbake is supposed to already deal with this).

     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==0:
+                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
 
         project = Project.objects.get(pk=project_id)
         result = []
         projectlvers = [player.layercommit for player in project.projectlayer_set.all()]
-        for dep in gen_layerdeps(self, project):
+        # protect against infinite layer dependency loops
+        maxdepth=20
+        for dep in gen_layerdeps(self, project, maxdepth):
             # filter out duplicates and layers already belonging to the project
             if dep not in result + projectlvers:
                 result.append(dep)
Comment 1 David Lopez Barriba 2017-02-09 23:50:27 UTC
Verified in 226a508da955439b881b2f0a544a3aee76e59919
Works OK