@@ -301,23 +301,24 @@ def get_slot_iter(self):
301301 self .ma_flags & self .MT_FLAGS_HEIGHT_MASK
302302 ) >> self .MT_FLAGS_HEIGHT_OFFSET
303303 yield from self ._parse_maple_tree_node (
304- self .ma_root ,
305- maple_tree_offset ,
306- expected_maple_tree_depth ,
307- seen = set (),
308- current_depth = 1 ,
304+ self .ma_root , maple_tree_offset , expected_maple_tree_depth
309305 )
310306
311307 def _parse_maple_tree_node (
312308 self ,
313309 maple_tree_entry ,
314310 parent ,
315311 expected_maple_tree_depth ,
316- seen = set () ,
312+ seen = None ,
317313 current_depth = 1 ,
318314 ):
319315 """Recursively parse Maple Tree Nodes and yield all non empty slots"""
320316
317+ # create seen set if it does not exist, e.g. on the first call into
318+ # this recursive function.
319+ if seen == None :
320+ seen = set ()
321+
321322 # protect against unlikely loop
322323 if maple_tree_entry in seen :
323324 vollog .warning (
@@ -326,6 +327,7 @@ def _parse_maple_tree_node(
326327 return
327328 else :
328329 seen .add (maple_tree_entry )
330+
329331 # check if we have exceeded the expected depth of this maple tree.
330332 # e.g. when current_depth is larger than expected_maple_tree_depth there may be an issue.
331333 # it is normal that expected_maple_tree_depth is equal to current_depth.
@@ -334,6 +336,7 @@ def _parse_maple_tree_node(
334336 f"The depth for the maple tree at { hex (self .vol .offset )} is { expected_maple_tree_depth } , however when parsing the nodes "
335337 f"a depth of { current_depth } was reached. This is unexpected and may lead to incorrect results."
336338 )
339+
337340 # parse the mte to extract the pointer value, node type, and leaf status
338341 pointer = maple_tree_entry & ~ (self .MAPLE_NODE_POINTER_MASK )
339342 node_type = (
0 commit comments