overlay: fix child_nodes deserialization in multi-pass lopper invocations#761
overlay: fix child_nodes deserialization in multi-pass lopper invocations#761arthokal wants to merge 1 commit into
Conversation
|
@onkarharsh, please review. |
|
Looks good to me |
|
I need a bit more information. While the commit looks ok, the commit message doesn't carry enough information. What attribute error ? I assume something is accessing .child, or similar, but that needs to be in the commit message. What are the lopper command lines used to reproduce the issue, as well as the inputs. Both of those are required, since the overlay selftest are currently passing, and I need to check against those as well as to consider alternate implementations (we may not need the serialization anymore) |
…ions _deserialize_overlay_node() calls append() on node.child_nodes, which is an OrderedDict, causing: AttributeError: 'collections.OrderedDict' object has no attribute 'append' The issue is observed in a two-pass flow where pass 1 runs xlnx_overlay_pl_dt with an overlay file containing child nodes (e.g., updated_zocl.dtsi with zyxclmm_drm under &amba_pl). Pass 1 embeds the overlay data into the output DTS via _serialize_overlay_subtrees. Pass 2 (gen_domain_dts) crashes at startup when _deserialize_overlay_subtrees tries to reconstruct the embedded child nodes. Fix by using dict-style insertion keyed by abs_path and set child.parent explicitly, consistent with how child_nodes is managed in tree.py. Signed-off-by: Aravind Thokala <aravind.thokala@amd.com>
5d1be2d to
7a55feb
Compare
|
Hi @zeddii, Thank you for reviewing. Commit message and PR description were updated. Please review. |
|
Thanks @arthokal — fix is correct. I made one small adjustment before merging: rather than setting `child.parent = node` after the recursive call (where the `parent` parameter was passed in but never used inside the function body), I moved it to `node.parent = parent` at the top of `_deserialize_overlay_node`. This establishes the parent backref before any property or child processing, which is more defensive against any code that walks `.parent` during construction. You're still listed as author. Also added a second commit with self-tests covering the crash path and the invariants the fix depends on: |
|
The reason this slipped through existing tests: all our overlay test fixtures use flat overlay nodes (e.g. `/axi/timer@f1e90000` with only properties, no child nodes), so the `for child_data in data.get("children", [])` loop in `_deserialize_overlay_node` was never entered and the `append()` call was never reached. The new regression tests use a nested node (`zyxclmm_drm` under `amba_pl`) to exercise that path directly. |
Issue:
When an overlay file with child nodes (e.g., updated_zocl.dtsi containing zyxclmm_drm under &amba_pl) is passed via -i in pass 1, Lopper embeds the overlay data into the output DTS for preservation across passes. In pass 2 (e.g., gen_domain_dts), Lopper crashes at startup while reconstructing the embedded overlay data:
AttributeError: 'collections.OrderedDict' object has no attribute 'append'
Root Cause:
_deserialize_overlay_node() used node.child_nodes.append(child), but child_nodes is an OrderedDict, not a list.
Fix:
Changed to node.child_nodes[child.abs_path] = child with explicit parent assignment, consistent with how child_nodes is managed in tree.py.
Example Lopper command invocations: