thiru-mg commented on code in PR #3475:
URL: https://github.com/apache/avro/pull/3475#discussion_r2312743946
##########
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:
I wonder if this could lead to memory leak in case of circular schemas. In
the previous code, if you attempt to make a node that is already present, it
returns a symbolic reference to the old one. If we return the pointer to the
old one, this could lead to cycles of smart pointers which will never get
deleted.
Can we add a test that proves that the above situation doesn't arise? One
way to test is to hold a `weak_ptr` to the returned object and ensure that the
pointer holds nothing after the outermost schema is gone.
An example of circular schema is a binary tree, where each node has two
children which are union of the node's schema and `null`.
--
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]