Alexey Serbin has uploaded this change for review. ( 
http://gerrit.cloudera.org:8080/18510


Change subject: [client] prohibit copying/assigning of ResourceMetrics
......................................................................

[client] prohibit copying/assigning of ResourceMetrics

Since ResourceMetrics contains a raw pointer, it makes it dangerous
since its auto-generated copy constructor and assignment operator
are not private.  Somebody could write something like

  {
    KuduScanner scanner();
    {
      ResouceMetrics m = session->GetResourceMetrics();
      ...
    }
    // Continue scanning activity with the 'scanner'.
    ...
  }

  or

  {
    KuduSession session(...);
    {
      ResouceMetrics m = session->GetWriteOpMetrics();
      ...
    }
    // Continue writing activity with the 'session'.
    ...
  }

and hit a silent memory corruption issue since that's the use-after-free
condition for the KuduScanner and KuduSession instances when the data
behind the raw pointer in ResourceMetrics::data_ is accessed later on.

This patch breaks the ABI compatibility for the kudu_client C++ library,
but this would surface only if there is a dangerous code like above
in the Kudu application linked with the library.  It's much worse having
such a hidden memory corruption issue in an application than hitting
a build breakage due to a linkage error which is quite simple to fix.

This is a follow-up to ece7b5653998db318e4baa5d57f27ba3a836731d.

Change-Id: I602cc4e194a975752687d13d525e44043955a5cf
---
M src/kudu/client/resource_metrics.h
1 file changed, 6 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/10/18510/1
--
To view, visit http://gerrit.cloudera.org:8080/18510
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I602cc4e194a975752687d13d525e44043955a5cf
Gerrit-Change-Number: 18510
Gerrit-PatchSet: 1
Gerrit-Owner: Alexey Serbin <[email protected]>

Reply via email to