You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@kudu.apache.org by "Alexey Serbin (Code Review)" <ge...@cloudera.org> on 2024/10/21 22:09:40 UTC

[kudu-CR](branch-1.17.x) KUDU-3620 fix heap-use-after-free and undefined behavior in OpDriver

Hello Zoltan Martonka, Abhishek Chennaka,

I'd like you to do a code review. Please visit

    http://gerrit.cloudera.org:8080/21960

to review the following change.


Change subject: KUDU-3620 fix heap-use-after-free and undefined behavior in OpDriver
......................................................................

KUDU-3620 fix heap-use-after-free and undefined behavior in OpDriver

This patch fixes a long-standing heap-use-after-free issue in OpDriver.
The problem is addressed by supplying a valid reference to OpDriver
objects for callbacks to make sure objects aren't destroyed while
their methods are being invoked.

The reference-counting wrapper for OpDriver objects changed from
scoped_refptr to std::shared_ptr.  It allows for passing weak pointers
(std::weak_ptr) instead of raw pointers to callbacks where reference
counting cycle was suspected (left the clarification of the latter as
TODOs), so a valid shared pointer can be constructed before invoking any
of the required OpDriver's methods.

I also updated the signature of OpTracker::GetPendingOps() to get rid of
output parameter.

Before this patch, running the following against Kudu bits built in
ASAN configuration would trigger ASAN and UBSAN warnings once in about
150 runs:

  ./ts_recovery-itest \
      --gtest_filter='DifferentFaultPoints/Kudu969Test.Test/*' \
      --gtest_repeat=10000

With this patch, more than 2K iterations of the same succeeded without
producing a single ASAN/UBSAN issue report.

Change-Id: Iadc58f1724bc03373a7e165fd3798b8868dc9d29
Reviewed-on: http://gerrit.cloudera.org:8080/21948
Tested-by: Alexey Serbin <al...@apache.org>
Reviewed-by: Zoltan Martonka <zm...@cloudera.com>
Reviewed-by: Abhishek Chennaka <ac...@cloudera.com>
(cherry picked from commit c51e1354322a4d2cad268de26f254dd52b0c9df1)
  Conflicts:
    src/kudu/tablet/ops/op_driver.cc
    src/kudu/tablet/ops/op_tracker.cc
    src/kudu/tablet/tablet_replica.cc
    src/kudu/tablet/tablet_replica.h
---
M src/kudu/tablet/ops/op_driver.cc
M src/kudu/tablet/ops/op_driver.h
M src/kudu/tablet/ops/op_tracker-test.cc
M src/kudu/tablet/ops/op_tracker.cc
M src/kudu/tablet/ops/op_tracker.h
M src/kudu/tablet/tablet_replica-test.cc
M src/kudu/tablet/tablet_replica.cc
M src/kudu/tablet/tablet_replica.h
M src/kudu/tablet/txn_participant-test.cc
9 files changed, 137 insertions(+), 114 deletions(-)



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

Gerrit-Project: kudu
Gerrit-Branch: branch-1.17.x
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iadc58f1724bc03373a7e165fd3798b8868dc9d29
Gerrit-Change-Number: 21960
Gerrit-PatchSet: 1
Gerrit-Owner: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Abhishek Chennaka <ac...@cloudera.com>
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>

[kudu-CR](branch-1.17.x) KUDU-3620 fix heap-use-after-free and undefined behavior in OpDriver

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Alexey Serbin has submitted this change and it was merged. ( http://gerrit.cloudera.org:8080/21960 )

Change subject: KUDU-3620 fix heap-use-after-free and undefined behavior in OpDriver
......................................................................

KUDU-3620 fix heap-use-after-free and undefined behavior in OpDriver

This patch fixes a long-standing heap-use-after-free issue in OpDriver.
The problem is addressed by supplying a valid reference to OpDriver
objects for callbacks to make sure objects aren't destroyed while
their methods are being invoked.

The reference-counting wrapper for OpDriver objects changed from
scoped_refptr to std::shared_ptr.  It allows for passing weak pointers
(std::weak_ptr) instead of raw pointers to callbacks where reference
counting cycle was suspected (left the clarification of the latter as
TODOs), so a valid shared pointer can be constructed before invoking any
of the required OpDriver's methods.

I also updated the signature of OpTracker::GetPendingOps() to get rid of
output parameter.

Before this patch, running the following against Kudu bits built in
ASAN configuration would trigger ASAN and UBSAN warnings once in about
150 runs:

  ./ts_recovery-itest \
      --gtest_filter='DifferentFaultPoints/Kudu969Test.Test/*' \
      --gtest_repeat=10000

With this patch, more than 2K iterations of the same succeeded without
producing a single ASAN/UBSAN issue report.

Change-Id: Iadc58f1724bc03373a7e165fd3798b8868dc9d29
Reviewed-on: http://gerrit.cloudera.org:8080/21948
Tested-by: Alexey Serbin <al...@apache.org>
Reviewed-by: Zoltan Martonka <zm...@cloudera.com>
Reviewed-by: Abhishek Chennaka <ac...@cloudera.com>
(cherry picked from commit c51e1354322a4d2cad268de26f254dd52b0c9df1)
  Conflicts:
    src/kudu/tablet/ops/op_driver.cc
    src/kudu/tablet/ops/op_tracker.cc
    src/kudu/tablet/tablet_replica.cc
    src/kudu/tablet/tablet_replica.h
Reviewed-on: http://gerrit.cloudera.org:8080/21960
Tested-by: Kudu Jenkins
---
M src/kudu/tablet/ops/op_driver.cc
M src/kudu/tablet/ops/op_driver.h
M src/kudu/tablet/ops/op_tracker-test.cc
M src/kudu/tablet/ops/op_tracker.cc
M src/kudu/tablet/ops/op_tracker.h
M src/kudu/tablet/tablet_replica-test.cc
M src/kudu/tablet/tablet_replica.cc
M src/kudu/tablet/tablet_replica.h
M src/kudu/tablet/txn_participant-test.cc
9 files changed, 137 insertions(+), 114 deletions(-)

Approvals:
  Abhishek Chennaka: Looks good to me, approved
  Kudu Jenkins: Verified

-- 
To view, visit http://gerrit.cloudera.org:8080/21960
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: branch-1.17.x
Gerrit-MessageType: merged
Gerrit-Change-Id: Iadc58f1724bc03373a7e165fd3798b8868dc9d29
Gerrit-Change-Number: 21960
Gerrit-PatchSet: 2
Gerrit-Owner: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Abhishek Chennaka <ac...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>

[kudu-CR](branch-1.17.x) KUDU-3620 fix heap-use-after-free and undefined behavior in OpDriver

Posted by "Abhishek Chennaka (Code Review)" <ge...@cloudera.org>.
Abhishek Chennaka has posted comments on this change. ( http://gerrit.cloudera.org:8080/21960 )

Change subject: KUDU-3620 fix heap-use-after-free and undefined behavior in OpDriver
......................................................................


Patch Set 1: Code-Review+2


-- 
To view, visit http://gerrit.cloudera.org:8080/21960
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: branch-1.17.x
Gerrit-MessageType: comment
Gerrit-Change-Id: Iadc58f1724bc03373a7e165fd3798b8868dc9d29
Gerrit-Change-Number: 21960
Gerrit-PatchSet: 1
Gerrit-Owner: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Abhishek Chennaka <ac...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Mon, 21 Oct 2024 22:11:32 +0000
Gerrit-HasComments: No

[kudu-CR](branch-1.17.x) KUDU-3620 fix heap-use-after-free and undefined behavior in OpDriver

Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/21960 )

Change subject: KUDU-3620 fix heap-use-after-free and undefined behavior in OpDriver
......................................................................


Patch Set 1: Verified+1

Build Successful 

http://jenkins.kudu.apache.org/job/pre_commit/609/ : SUCCESS


-- 
To view, visit http://gerrit.cloudera.org:8080/21960
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: branch-1.17.x
Gerrit-MessageType: comment
Gerrit-Change-Id: Iadc58f1724bc03373a7e165fd3798b8868dc9d29
Gerrit-Change-Number: 21960
Gerrit-PatchSet: 1
Gerrit-Owner: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Abhishek Chennaka <ac...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Tue, 22 Oct 2024 00:05:49 +0000
Gerrit-HasComments: No

[kudu-CR](branch-1.17.x) KUDU-3620 fix heap-use-after-free and undefined behavior in OpDriver

Posted by "Kudu Jenkins (Code Review)" <ge...@cloudera.org>.
Kudu Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/21960 )

Change subject: KUDU-3620 fix heap-use-after-free and undefined behavior in OpDriver
......................................................................


Patch Set 1:

Build Started http://jenkins.kudu.apache.org/job/pre_commit/609/


-- 
To view, visit http://gerrit.cloudera.org:8080/21960
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: branch-1.17.x
Gerrit-MessageType: comment
Gerrit-Change-Id: Iadc58f1724bc03373a7e165fd3798b8868dc9d29
Gerrit-Change-Number: 21960
Gerrit-PatchSet: 1
Gerrit-Owner: Alexey Serbin <al...@apache.org>
Gerrit-Reviewer: Abhishek Chennaka <ac...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Zoltan Martonka <zm...@cloudera.com>
Gerrit-Comment-Date: Mon, 21 Oct 2024 22:09:46 +0000
Gerrit-HasComments: No