You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@kudu.apache.org by "Todd Lipcon (Code Review)" <ge...@cloudera.org> on 2018/03/22 01:03:29 UTC

[kudu-CR] KUDU-2075. Fix SEGV when using tracing from vanilla threads

Hello Mike Percy,

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

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

to review the following change.


Change subject: KUDU-2075. Fix SEGV when using tracing from vanilla threads
......................................................................

KUDU-2075. Fix SEGV when using tracing from vanilla threads

This fixes a crash when tracing was enabled and a thread happened to
reuse the same pthread_self identifier as a previous deceased
non-kudu::Thread-based thread.

The issue was that non-Kudu-threads were not unregistering themselves
from the TraceLog instance, so when the new thread started and generated
a trace event, it would fail with a CHECK failure like:

F0721 13:14:12.038748  2708 map-util.h:414] Check failed:
InsertIfNotPresent(collection, key, data) duplicate key: 139914842822400

The new test reproduced the issue reliably.

Change-Id: I7457be81c1c2668244907a70d62db7cf91321375
---
M src/kudu/util/debug/trace_event_impl.cc
M src/kudu/util/debug/trace_event_impl.h
M src/kudu/util/kernel_stack_watchdog.cc
M src/kudu/util/threadlocal.cc
M src/kudu/util/threadlocal.h
M src/kudu/util/trace-test.cc
6 files changed, 59 insertions(+), 29 deletions(-)



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

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7457be81c1c2668244907a70d62db7cf91321375
Gerrit-Change-Number: 9750
Gerrit-PatchSet: 1
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Mike Percy <mp...@apache.org>

[kudu-CR] KUDU-2075. Fix SEGV when using tracing from vanilla threads

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

Change subject: KUDU-2075. Fix SEGV when using tracing from vanilla threads
......................................................................


Patch Set 3: Code-Review+2


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

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I7457be81c1c2668244907a70d62db7cf91321375
Gerrit-Change-Number: 9750
Gerrit-PatchSet: 3
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Mike Percy <mp...@apache.org>
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-Comment-Date: Thu, 22 Mar 2018 17:56:52 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-2075. Fix SEGV when using tracing from vanilla threads

Posted by "Todd Lipcon (Code Review)" <ge...@cloudera.org>.
Hello Mike Percy, Kudu Jenkins, Adar Dembo, 

I'd like you to reexamine a change. Please visit

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

to look at the new patch set (#3).

Change subject: KUDU-2075. Fix SEGV when using tracing from vanilla threads
......................................................................

KUDU-2075. Fix SEGV when using tracing from vanilla threads

This fixes a crash when tracing was enabled and a thread happened to
reuse the same pthread_self identifier as a previous deceased
non-kudu::Thread-based thread.

The issue was that non-Kudu-threads were not unregistering themselves
from the TraceLog instance, so when the new thread started and generated
a trace event, it would fail with a CHECK failure like:

F0721 13:14:12.038748  2708 map-util.h:414] Check failed:
InsertIfNotPresent(collection, key, data) duplicate key: 139914842822400

The new test reproduced the issue reliably.

This patch also removes Thread::CallAtExit() which was no longer used
after removing this callsite.

Change-Id: I7457be81c1c2668244907a70d62db7cf91321375
---
M src/kudu/consensus/log.h
M src/kudu/tablet/tablet_metadata.h
M src/kudu/util/debug/trace_event_impl.cc
M src/kudu/util/debug/trace_event_impl.h
M src/kudu/util/kernel_stack_watchdog.cc
M src/kudu/util/thread-test.cc
M src/kudu/util/thread.cc
M src/kudu/util/thread.h
M src/kudu/util/threadlocal.cc
M src/kudu/util/threadlocal.h
M src/kudu/util/trace-test.cc
11 files changed, 61 insertions(+), 82 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/50/9750/3
-- 
To view, visit http://gerrit.cloudera.org:8080/9750
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I7457be81c1c2668244907a70d62db7cf91321375
Gerrit-Change-Number: 9750
Gerrit-PatchSet: 3
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Mike Percy <mp...@apache.org>
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>

[kudu-CR] KUDU-2075. Fix SEGV when using tracing from vanilla threads

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

Change subject: KUDU-2075. Fix SEGV when using tracing from vanilla threads
......................................................................


Patch Set 1:

(3 comments)

http://gerrit.cloudera.org:8080/#/c/9750/1/src/kudu/util/debug/trace_event_impl.cc
File src/kudu/util/debug/trace_event_impl.cc:

http://gerrit.cloudera.org:8080/#/c/9750/1/src/kudu/util/debug/trace_event_impl.cc@1726
PS1, Line 1726:   // Don't use Thread::CallAtExit() since that only works in the context of a Kudu
> You could remove CallAtExit() altogether; I think this was the only use of 
Indeed, good catch


http://gerrit.cloudera.org:8080/#/c/9750/1/src/kudu/util/threadlocal.cc
File src/kudu/util/threadlocal.cc:

http://gerrit.cloudera.org:8080/#/c/9750/1/src/kudu/util/threadlocal.cc@75
PS1, Line 75:   auto* p = new PerThreadDestructorList();
> Nit: if you want to be pedantic, you could store this in a unique_ptr and t
Done


http://gerrit.cloudera.org:8080/#/c/9750/1/src/kudu/util/trace-test.cc
File src/kudu/util/trace-test.cc:

http://gerrit.cloudera.org:8080/#/c/9750/1/src/kudu/util/trace-test.cc@883
PS1, Line 883:         });
> Nit: should be aligned with the 't' in 'threads' , no?
My editor auto-indents it here, and seems like we're pretty inconsistent. If this were a control block (if/else/while/etc) then I'd 100% agree, but you can also argue that this is a continuation of an argument, like:

  foo(something + somethingelse +
    some_line_with_questionable_indentation);



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

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I7457be81c1c2668244907a70d62db7cf91321375
Gerrit-Change-Number: 9750
Gerrit-PatchSet: 1
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Mike Percy <mp...@apache.org>
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-Comment-Date: Thu, 22 Mar 2018 16:53:24 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-2075. Fix SEGV when using tracing from vanilla threads

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

Change subject: KUDU-2075. Fix SEGV when using tracing from vanilla threads
......................................................................


Patch Set 2: Code-Review+2


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

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I7457be81c1c2668244907a70d62db7cf91321375
Gerrit-Change-Number: 9750
Gerrit-PatchSet: 2
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Mike Percy <mp...@apache.org>
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-Comment-Date: Thu, 22 Mar 2018 17:23:52 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-2075. Fix SEGV when using tracing from vanilla threads

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

Change subject: KUDU-2075. Fix SEGV when using tracing from vanilla threads
......................................................................

KUDU-2075. Fix SEGV when using tracing from vanilla threads

This fixes a crash when tracing was enabled and a thread happened to
reuse the same pthread_self identifier as a previous deceased
non-kudu::Thread-based thread.

The issue was that non-Kudu-threads were not unregistering themselves
from the TraceLog instance, so when the new thread started and generated
a trace event, it would fail with a CHECK failure like:

F0721 13:14:12.038748  2708 map-util.h:414] Check failed:
InsertIfNotPresent(collection, key, data) duplicate key: 139914842822400

The new test reproduced the issue reliably.

This patch also removes Thread::CallAtExit() which was no longer used
after removing this callsite.

Change-Id: I7457be81c1c2668244907a70d62db7cf91321375
Reviewed-on: http://gerrit.cloudera.org:8080/9750
Reviewed-by: Adar Dembo <ad...@cloudera.com>
Tested-by: Kudu Jenkins
---
M src/kudu/consensus/log.h
M src/kudu/tablet/tablet_metadata.h
M src/kudu/util/debug/trace_event_impl.cc
M src/kudu/util/debug/trace_event_impl.h
M src/kudu/util/kernel_stack_watchdog.cc
M src/kudu/util/thread-test.cc
M src/kudu/util/thread.cc
M src/kudu/util/thread.h
M src/kudu/util/threadlocal.cc
M src/kudu/util/threadlocal.h
M src/kudu/util/trace-test.cc
11 files changed, 61 insertions(+), 82 deletions(-)

Approvals:
  Adar Dembo: Looks good to me, approved
  Kudu Jenkins: Verified

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

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I7457be81c1c2668244907a70d62db7cf91321375
Gerrit-Change-Number: 9750
Gerrit-PatchSet: 4
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Mike Percy <mp...@apache.org>
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>

[kudu-CR] KUDU-2075. Fix SEGV when using tracing from vanilla threads

Posted by "Todd Lipcon (Code Review)" <ge...@cloudera.org>.
Hello Mike Percy, Kudu Jenkins, Adar Dembo, 

I'd like you to reexamine a change. Please visit

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

to look at the new patch set (#2).

Change subject: KUDU-2075. Fix SEGV when using tracing from vanilla threads
......................................................................

KUDU-2075. Fix SEGV when using tracing from vanilla threads

This fixes a crash when tracing was enabled and a thread happened to
reuse the same pthread_self identifier as a previous deceased
non-kudu::Thread-based thread.

The issue was that non-Kudu-threads were not unregistering themselves
from the TraceLog instance, so when the new thread started and generated
a trace event, it would fail with a CHECK failure like:

F0721 13:14:12.038748  2708 map-util.h:414] Check failed:
InsertIfNotPresent(collection, key, data) duplicate key: 139914842822400

The new test reproduced the issue reliably.

This patch also removes Thread::CallAtExit() which was no longer used
after removing this callsite.

Change-Id: I7457be81c1c2668244907a70d62db7cf91321375
---
M src/kudu/util/debug/trace_event_impl.cc
M src/kudu/util/debug/trace_event_impl.h
M src/kudu/util/kernel_stack_watchdog.cc
M src/kudu/util/thread-test.cc
M src/kudu/util/thread.cc
M src/kudu/util/thread.h
M src/kudu/util/threadlocal.cc
M src/kudu/util/threadlocal.h
M src/kudu/util/trace-test.cc
9 files changed, 59 insertions(+), 82 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/50/9750/2
-- 
To view, visit http://gerrit.cloudera.org:8080/9750
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I7457be81c1c2668244907a70d62db7cf91321375
Gerrit-Change-Number: 9750
Gerrit-PatchSet: 2
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Mike Percy <mp...@apache.org>
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>

[kudu-CR] KUDU-2075. Fix SEGV when using tracing from vanilla threads

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

Change subject: KUDU-2075. Fix SEGV when using tracing from vanilla threads
......................................................................


Patch Set 1:

(3 comments)

http://gerrit.cloudera.org:8080/#/c/9750/1/src/kudu/util/debug/trace_event_impl.cc
File src/kudu/util/debug/trace_event_impl.cc:

http://gerrit.cloudera.org:8080/#/c/9750/1/src/kudu/util/debug/trace_event_impl.cc@1726
PS1, Line 1726:   // Don't use Thread::CallAtExit() since that only works in the context of a Kudu
You could remove CallAtExit() altogether; I think this was the only use of it.


http://gerrit.cloudera.org:8080/#/c/9750/1/src/kudu/util/threadlocal.cc
File src/kudu/util/threadlocal.cc:

http://gerrit.cloudera.org:8080/#/c/9750/1/src/kudu/util/threadlocal.cc@75
PS1, Line 75:   auto* p = new PerThreadDestructorList();
Nit: if you want to be pedantic, you could store this in a unique_ptr and then p.release() it on L79.


http://gerrit.cloudera.org:8080/#/c/9750/1/src/kudu/util/trace-test.cc
File src/kudu/util/trace-test.cc:

http://gerrit.cloudera.org:8080/#/c/9750/1/src/kudu/util/trace-test.cc@883
PS1, Line 883:         });
Nit: should be aligned with the 't' in 'threads' , no?



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

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I7457be81c1c2668244907a70d62db7cf91321375
Gerrit-Change-Number: 9750
Gerrit-PatchSet: 1
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Mike Percy <mp...@apache.org>
Gerrit-Comment-Date: Thu, 22 Mar 2018 16:14:55 +0000
Gerrit-HasComments: Yes