Fix some leaks/use-after-frees

reviewable/pr8842/r2
Craig Tiller 8 years ago
parent ebc77551e9
commit 75731e65a8
  1. 7
      src/core/lib/surface/lame_client.c
  2. 4
      test/core/end2end/fixtures/proxy.c
  3. 1
      test/core/end2end/invalid_call_argument_test.c
  4. 2
      test/core/end2end/tests/max_concurrent_streams.c
  5. 14
      test/core/transport/chttp2/hpack_encoder_test.c

@ -49,6 +49,7 @@
typedef struct {
grpc_linked_mdelem status;
grpc_linked_mdelem details;
gpr_atm filled_metadata;
} call_data;
typedef struct {
@ -59,6 +60,9 @@ typedef struct {
static void fill_metadata(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
grpc_metadata_batch *mdb) {
call_data *calld = elem->call_data;
if (!gpr_atm_no_barrier_cas(&calld->filled_metadata, 0, 1)) {
return;
}
channel_data *chand = elem->channel_data;
char tmp[GPR_LTOA_MIN_BUFSIZE];
gpr_ltoa(chand->error_code, tmp);
@ -72,6 +76,7 @@ static void fill_metadata(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
calld->details.prev = &calld->status;
mdb->list.head = &calld->status;
mdb->list.tail = &calld->details;
mdb->list.count = 2;
mdb->deadline = gpr_inf_future(GPR_CLOCK_REALTIME);
}
@ -118,6 +123,8 @@ static void lame_start_transport_op(grpc_exec_ctx *exec_ctx,
static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
grpc_call_element *elem,
grpc_call_element_args *args) {
call_data *calld = elem->call_data;
gpr_atm_no_barrier_store(&calld->filled_metadata, 0);
return GRPC_ERROR_NONE;
}

@ -111,6 +111,7 @@ grpc_end2end_proxy *grpc_end2end_proxy_create(const grpc_end2end_proxy_def *def,
grpc_server_register_completion_queue(proxy->server, proxy->cq, NULL);
grpc_server_start(proxy->server);
grpc_call_details_init(&proxy->new_call_details);
gpr_thd_options_set_joinable(&opt);
GPR_ASSERT(gpr_thd_new(&proxy->thd, thread_main, proxy, &opt));
@ -398,6 +399,9 @@ static void on_new_call(void *arg, int success) {
request_call(proxy);
grpc_call_details_destroy(&proxy->new_call_details);
grpc_call_details_init(&proxy->new_call_details);
unrefpc(pc, "init");
} else {
GPR_ASSERT(proxy->new_call == NULL);

@ -75,6 +75,7 @@ static void prepare_test(int is_client) {
g_state.deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(2);
g_state.cq = grpc_completion_queue_create(NULL);
g_state.cqv = cq_verifier_create(g_state.cq);
g_state.details = grpc_empty_slice();
memset(g_state.ops, 0, sizeof(g_state.ops));
if (is_client) {

@ -391,6 +391,8 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
CQ_EXPECT_COMPLETION(cqv, tag(live_call + 1), 1);
cq_verify(cqv);
grpc_call_details_destroy(&call_details);
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
f.server, &s2, &call_details,
&request_metadata_recv, f.cq, f.cq, tag(201)));

@ -81,9 +81,9 @@ static void verify(grpc_exec_ctx *exec_ctx, size_t window_available, int eof,
e[i - 1].next = &e[i];
e[i].prev = &e[i - 1];
}
e[i].md =
grpc_mdelem_from_slices(exec_ctx, grpc_slice_from_copied_string(key),
grpc_slice_from_copied_string(value));
e[i].md = grpc_mdelem_from_slices(
exec_ctx, grpc_slice_intern(grpc_slice_from_static_string(key)),
grpc_slice_intern(grpc_slice_from_static_string(value)));
}
e[0].prev = NULL;
e[nheaders - 1].next = NULL;
@ -91,6 +91,7 @@ static void verify(grpc_exec_ctx *exec_ctx, size_t window_available, int eof,
b.list.head = &e[0];
b.list.tail = &e[nheaders - 1];
b.list.count = nheaders;
if (cap_to_delete == num_to_delete) {
cap_to_delete = GPR_MAX(2 * cap_to_delete, 1000);
@ -195,9 +196,9 @@ static void verify_table_size_change_match_elem_size(grpc_exec_ctx *exec_ctx,
const char *key,
const char *value) {
grpc_slice_buffer output;
grpc_mdelem elem =
grpc_mdelem_from_slices(exec_ctx, grpc_slice_from_copied_string(key),
grpc_slice_from_copied_string(value));
grpc_mdelem elem = grpc_mdelem_from_slices(
exec_ctx, grpc_slice_intern(grpc_slice_from_static_string(key)),
grpc_slice_intern(grpc_slice_from_static_string(value)));
size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem);
size_t initial_table_size = g_compressor.table_size;
grpc_linked_mdelem *e = gpr_malloc(sizeof(*e));
@ -208,6 +209,7 @@ static void verify_table_size_change_match_elem_size(grpc_exec_ctx *exec_ctx,
e[0].next = NULL;
b.list.head = &e[0];
b.list.tail = &e[0];
b.list.count = 1;
grpc_slice_buffer_init(&output);
grpc_transport_one_way_stats stats;

Loading…
Cancel
Save