empiredan commented on code in PR #2302:
URL: 
https://github.com/apache/incubator-pegasus/pull/2302#discussion_r2464313374


##########
src/zookeeper/zookeeper_session.cpp:
##########
@@ -398,58 +399,64 @@ void zookeeper_session::visit(zoo_opcontext *ctx)
         _watchers.back().watcher_callback = 
std::move(ctx->_input._watcher_callback);
     };
 
-    // TODO: the read ops from zookeeper might get the staled data, need to fix
+    // TODO(clang-tidy): the read ops from zookeeper might get the staled 
data, need to fix
     int ec = ZOK;
     zoo_input &input = ctx->_input;
-    const char *path = input._path.c_str();
+
+    // A local variable is needed here to hold a reference to `_path` to 
prevent it from
+    // being freed in the thread executing the completion callback, which 
could otherwise
+    // lead to a dangling pointer issue.
+    const std::shared_ptr<std::string> path(input._path);

Review Comment:
   Yes !



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to