diff options
authorSam Thursfield <>2016-02-18 14:42:42 (GMT)
committerBaserock Gerrit <>2016-02-24 17:10:17 (GMT)
commit7e15ed7080c45f5283938e86af33fe4794b91b43 (patch)
parentbda9fe51c8e22d4c8c5ad8325094abd6ed25706d (diff)
Avoid stack overflow in cachekeycomputer
I managed to trigger a stack overflow in Morph, by having two chunks with the same name and same build instructions in different strata (by mistake, obviously). The error before was this: .... File "/src/morph/morphlib/", line 77, in get_cache_id cacheid = self._calculate(source) File "/src/morph/morphlib/", line 86, in _calculate for a in source.dependencies], File "/src/morph/morphlib/", line 38, in compute_key ret = self._hash_id(self.get_cache_id(source)) File "/src/morph/morphlib/", line 77, in get_cache_id cacheid = self._calculate(source) File "/src/morph/morphlib/", line 83, in _calculate 'env': self._filterenv(self._build_env.env), File "/src/morph/morphlib/", line 32, in _filterenv return dict([(k, env[k]) for k in keys]) RuntimeError: maximum recursion depth exceeded while calling a Python object The error afterwards is this: 2016-02-18 13:53:14 Deciding on task order ERROR: There are multiple versions of component 'cython' Change-Id: I96a41cabe4d9aa81bddc5186c5248a636a0843c2
1 files changed, 12 insertions, 0 deletions
diff --git a/morphlib/ b/morphlib/
index ce39564..d7c9707 100644
--- a/morphlib/
+++ b/morphlib/
@@ -491,6 +491,18 @@ def create_source_pool(lrc, rrc, repo, ref, filenames, cachedir,
def add_to_pool(reponame, ref, filename, absref, tree, morphology,
+ # If there are duplicate chunks which have the same 'name' and the
+ # same build instructions, we might cause a stack overflow in
+ # when trying to hash the build graph. The
+ # _find_duplicate_chunks() function doesn't handle this case, it
+ # is checking for duplicates with the same name but different build
+ # instructions.
+ if morphology['kind'] != 'stratum':
+ if pool.lookup(reponame, ref, filename):
+ raise morphlib.Error(
+ "There are multiple versions of component '%s'" %
+ morphology['name'])
sources = morphlib.source.make_sources(
reponame, ref, filename, absref, tree, morphology,