rayokota commented on code in PR #3475:
URL: https://github.com/apache/avro/pull/3475#discussion_r2312872503
##########
lang/c++/impl/Compiler.cc:
##########
@@ -94,7 +94,15 @@ static NodePtr makeNode(const string &t, SymbolTable &st,
const string &ns) {
auto it = st.find(n);
if (it != st.end()) {
- return NodePtr(new NodeSymbolic(asSingleAttribute(n), it->second));
Review Comment:
Thanks for reviewing the PR @thiru-mg ! I added the test that you
suggested. Here are some observations:
- Returning the existing node directly in `makeNode` does not create
`shared_ptr` cycles for recursive schemas. During validation, duplicates are
replaced with `NodeSymbolic` via `setLeafToSymbolic`, breaking potential strong
cycles.
- The new test constructs a record `Node` with left/right fields as
`["null","Node"]`, captures a `weak_ptr` to the root, lets `ValidSchema` go out
of scope, and asserts the `weak_ptr` expired. It passes, demonstrating no leak
from cycles.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]