Skip to content

Commit 798d18e

Browse files
authored
Merge pull request grpc#24592 from markdroth/deadline_filter_fix
Fix msan bug in deadline filter.
2 parents dcfb6a9 + d55591f commit 798d18e

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/core/ext/filters/deadline/deadline_filter.cc

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,6 @@ class TimerState {
4949
void Cancel() { grpc_timer_cancel(&timer_); }
5050

5151
private:
52-
~TimerState() {
53-
grpc_deadline_state* deadline_state =
54-
static_cast<grpc_deadline_state*>(elem_->call_data);
55-
GRPC_CALL_STACK_UNREF(deadline_state->call_stack, "DeadlineTimerState");
56-
}
57-
5852
// The on_complete callback used when sending a cancel_error batch down the
5953
// filter stack. Yields the call combiner when the batch returns.
6054
static void YieldCallCombiner(void* arg, grpc_error* /*ignored*/) {
@@ -63,8 +57,7 @@ class TimerState {
6357
static_cast<grpc_deadline_state*>(self->elem_->call_data);
6458
GRPC_CALL_COMBINER_STOP(deadline_state->call_combiner,
6559
"got on_complete from cancel_stream batch");
66-
// Allocated on call arena, so not deleting, but do want to call the dtor.
67-
self->~TimerState();
60+
GRPC_CALL_STACK_UNREF(deadline_state->call_stack, "DeadlineTimerState");
6861
}
6962

7063
// This is called via the call combiner, so access to deadline_state is
@@ -94,11 +87,17 @@ class TimerState {
9487
error,
9588
"deadline exceeded -- sending cancel_stream op");
9689
} else {
97-
// Allocated on call arena, so not deleting, but do want to call the dtor.
98-
self->~TimerState();
90+
GRPC_CALL_STACK_UNREF(deadline_state->call_stack, "DeadlineTimerState");
9991
}
10092
}
10193

94+
// NOTE: This object's dtor is never called, so do not add any data
95+
// members that require destruction!
96+
// TODO(roth): We should ideally call this object's dtor somewhere,
97+
// but that would require adding more synchronization, because we'd
98+
// need to call the dtor only after both (a) the timer callback
99+
// finishes and (b) the filter sees the call completion and attempts
100+
// to cancel the timer.
102101
grpc_call_element* elem_;
103102
grpc_timer timer_;
104103
grpc_closure closure_;

0 commit comments

Comments
 (0)