Sailesh Mukil created KUDU-1700:

             Summary: Debug build will not fail gracefully on Messenger::Init() 
                 Key: KUDU-1700
             Project: Kudu
          Issue Type: Bug
          Components: rpc
    Affects Versions: 0.10.0
            Reporter: Sailesh Mukil
            Priority: Minor

Status MessengerBuilder::Build(Messenger **msgr) {
  RETURN_NOT_OK(SaslInit(kSaslAppName)); // Initialize SASL library before we 
start making requests
  gscoped_ptr<Messenger> new_msgr(new Messenger(*this));
  *msgr = new_msgr.release();
  return Status::OK();

If Messenger::Init() fails, _msgr_ will not get assigned. Therefore, the 
calling function will also not have the argument _msgr_ assigned:
Status MessengerBuilder::Build(shared_ptr<Messenger> *msgr) {
  Messenger *ptr;

  // See docs on Messenger::retain_self_ for info about this odd hack.
  *msgr = shared_ptr<Messenger>(
    ptr, std::mem_fun(&Messenger::AllExternalReferencesDropped));
  return Status::OK();

This will cause the deleter to not get assigned as well, which means 
Messenger::Shutdown() doesn't get called, which will ultimately result in a 
CHECK() here, as _closing\_ _ will not be set:
Messenger::~Messenger() {
  std::lock_guard<percpu_rwlock> guard(lock_);
  CHECK(closing_) << "Should have already shut down";

Reordering the code in both the functions slightly will ensure that this does 
not happen.

This message was sent by Atlassian JIRA

Reply via email to