Merge github.com:grpc/grpc into call_arena

pull/10135/head
Craig Tiller 8 years ago
commit 6f8ddd6183
  1. 2
      Makefile
  2. 6
      build.yaml
  3. 3
      src/core/lib/support/arena.c
  4. 109
      src/core/lib/surface/call.c
  5. 3
      src/core/lib/transport/transport.c
  6. 3
      src/python/grpcio_health_checking/grpc_health/v1/health.py
  7. 5
      src/python/grpcio_tests/tests/health_check/_health_servicer_test.py
  8. 2
      test/core/security/BUILD
  9. 14
      test/core/security/ssl_server_fuzzer.c
  10. 2
      test/cpp/interop/http2_client.cc
  11. 2
      test/cpp/interop/http2_client.h
  12. 4
      test/cpp/interop/interop_client.cc
  13. 2
      test/cpp/interop/interop_client.h
  14. 4
      test/cpp/interop/interop_server.cc
  15. 4
      test/cpp/interop/reconnect_interop_client.cc
  16. 4
      test/cpp/interop/reconnect_interop_server.cc
  17. 7
      test/cpp/microbenchmarks/bm_arena.cc
  18. 2
      test/cpp/qps/client.h
  19. 2
      test/cpp/qps/driver.h
  20. 2
      test/cpp/qps/histogram.h
  21. 4
      test/cpp/qps/server.h
  22. 3
      tools/fuzzer/options/api_fuzzer.options
  23. 3
      tools/fuzzer/options/client_fuzzer.options
  24. 2
      tools/fuzzer/options/fuzzer.options
  25. 2
      tools/fuzzer/options/fuzzer_response.options
  26. 2
      tools/fuzzer/options/fuzzer_serverlist.options
  27. 3
      tools/fuzzer/options/hpack_parser_fuzzer_test.options
  28. 2
      tools/fuzzer/options/percent_decode_fuzzer.options
  29. 2
      tools/fuzzer/options/percent_encode_fuzzer.options
  30. 3
      tools/fuzzer/options/request_fuzzer.options
  31. 3
      tools/fuzzer/options/response_fuzzer.options
  32. 3
      tools/fuzzer/options/server_fuzzer.options
  33. 2
      tools/fuzzer/options/ssl_server_fuzzer.options
  34. 2
      tools/fuzzer/options/uri_fuzzer_test.options
  35. 119
      tools/gcp/utils/gcr_upload.py
  36. 2
      tools/run_tests/generated/configs.json
  37. 7
      tools/ubsan_suppressions.txt

@ -189,7 +189,7 @@ CC_ubsan = clang
CXX_ubsan = clang++ CXX_ubsan = clang++
LD_ubsan = clang LD_ubsan = clang
LDXX_ubsan = clang++ LDXX_ubsan = clang++
CPPFLAGS_ubsan = -O0 -fsanitize-coverage=edge -fsanitize=undefined,unsigned-integer-overflow -fno-omit-frame-pointer -Wno-unused-command-line-argument -Wvarargs CPPFLAGS_ubsan = -O0 -fsanitize-coverage=edge -fsanitize=undefined -fno-omit-frame-pointer -Wno-unused-command-line-argument -Wvarargs
LDFLAGS_ubsan = -fsanitize=undefined,unsigned-integer-overflow LDFLAGS_ubsan = -fsanitize=undefined,unsigned-integer-overflow
DEFINES_ubsan = NDEBUG DEFINES_ubsan = NDEBUG

@ -4285,8 +4285,8 @@ configs:
TSAN_OPTIONS: suppressions=tools/tsan_suppressions.txt:halt_on_error=1:second_deadlock_stack=1 TSAN_OPTIONS: suppressions=tools/tsan_suppressions.txt:halt_on_error=1:second_deadlock_stack=1
ubsan: ubsan:
CC: clang CC: clang
CPPFLAGS: -O0 -fsanitize-coverage=edge -fsanitize=undefined,unsigned-integer-overflow CPPFLAGS: -O0 -fsanitize-coverage=edge -fsanitize=undefined -fno-omit-frame-pointer
-fno-omit-frame-pointer -Wno-unused-command-line-argument -Wvarargs -Wno-unused-command-line-argument -Wvarargs
CXX: clang++ CXX: clang++
DEFINES: NDEBUG DEFINES: NDEBUG
LD: clang LD: clang
@ -4294,7 +4294,7 @@ configs:
LDXX: clang++ LDXX: clang++
compile_the_world: true compile_the_world: true
test_environ: test_environ:
UBSAN_OPTIONS: halt_on_error=1:print_stacktrace=1 UBSAN_OPTIONS: halt_on_error=1:print_stacktrace=1:suppressions=tools/ubsan_suppressions.txt
defaults: defaults:
benchmark: benchmark:
CPPFLAGS: -Ithird_party/benchmark/include -DHAVE_POSIX_REGEX CPPFLAGS: -Ithird_party/benchmark/include -DHAVE_POSIX_REGEX

@ -78,8 +78,7 @@ void *gpr_arena_alloc(gpr_arena *arena, size_t size) {
while (start > z->size_end) { while (start > z->size_end) {
zone *next_z = (zone *)gpr_atm_acq_load(&z->next_atm); zone *next_z = (zone *)gpr_atm_acq_load(&z->next_atm);
if (next_z == NULL) { if (next_z == NULL) {
size_t next_z_size = size_t next_z_size = (size_t)gpr_atm_no_barrier_load(&arena->size_so_far);
GPR_MAX((size_t)gpr_atm_no_barrier_load(&arena->size_so_far), size);
next_z = gpr_zalloc(sizeof(zone) + next_z_size); next_z = gpr_zalloc(sizeof(zone) + next_z_size);
next_z->size_begin = z->size_end; next_z->size_begin = z->size_end;
next_z->size_end = z->size_end + next_z_size; next_z->size_end = z->size_end + next_z_size;

@ -146,8 +146,8 @@ struct grpc_call {
grpc_call *parent; grpc_call *parent;
grpc_call *first_child; grpc_call *first_child;
gpr_timespec start_time; gpr_timespec start_time;
/* TODO(ctiller): share with cq if possible? */ /* protects first_child, and child next/prev links */
gpr_mu mu; gpr_mu child_list_mu;
/* client or server call */ /* client or server call */
bool is_client; bool is_client;
@ -162,8 +162,8 @@ struct grpc_call {
bool received_initial_metadata; bool received_initial_metadata;
bool receiving_message; bool receiving_message;
bool requested_final_op; bool requested_final_op;
bool received_final_op; gpr_atm any_ops_sent_atm;
bool sent_any_op; gpr_atm received_final_op_atm;
/* have we received initial metadata */ /* have we received initial metadata */
bool has_initial_md_been_received; bool has_initial_md_been_received;
@ -283,7 +283,7 @@ grpc_error *grpc_call_create(grpc_exec_ctx *exec_ctx,
sizeof(grpc_call) + channel_stack->call_stack_size); sizeof(grpc_call) + channel_stack->call_stack_size);
call->arena = arena; call->arena = arena;
*out_call = call; *out_call = call;
gpr_mu_init(&call->mu); gpr_mu_init(&call->child_list_mu);
call->channel = args->channel; call->channel = args->channel;
call->cq = args->cq; call->cq = args->cq;
call->parent = args->parent_call; call->parent = args->parent_call;
@ -321,7 +321,7 @@ grpc_error *grpc_call_create(grpc_exec_ctx *exec_ctx,
GPR_ASSERT(call->is_client); GPR_ASSERT(call->is_client);
GPR_ASSERT(!args->parent_call->is_client); GPR_ASSERT(!args->parent_call->is_client);
gpr_mu_lock(&args->parent_call->mu); gpr_mu_lock(&args->parent_call->child_list_mu);
if (args->propagation_mask & GRPC_PROPAGATE_DEADLINE) { if (args->propagation_mask & GRPC_PROPAGATE_DEADLINE) {
send_deadline = gpr_time_min( send_deadline = gpr_time_min(
@ -349,6 +349,10 @@ grpc_error *grpc_call_create(grpc_exec_ctx *exec_ctx,
} }
if (args->propagation_mask & GRPC_PROPAGATE_CANCELLATION) { if (args->propagation_mask & GRPC_PROPAGATE_CANCELLATION) {
call->cancellation_is_inherited = 1; call->cancellation_is_inherited = 1;
if (gpr_atm_acq_load(&args->parent_call->received_final_op_atm)) {
cancel_with_error(exec_ctx, call, STATUS_FROM_API_OVERRIDE,
GRPC_ERROR_CANCELLED);
}
} }
if (args->parent_call->first_child == NULL) { if (args->parent_call->first_child == NULL) {
@ -361,7 +365,7 @@ grpc_error *grpc_call_create(grpc_exec_ctx *exec_ctx,
call; call;
} }
gpr_mu_unlock(&args->parent_call->mu); gpr_mu_unlock(&args->parent_call->child_list_mu);
} }
call->send_deadline = send_deadline; call->send_deadline = send_deadline;
@ -456,7 +460,7 @@ static void destroy_call(grpc_exec_ctx *exec_ctx, void *call,
if (c->receiving_stream != NULL) { if (c->receiving_stream != NULL) {
grpc_byte_stream_destroy(exec_ctx, c->receiving_stream); grpc_byte_stream_destroy(exec_ctx, c->receiving_stream);
} }
gpr_mu_destroy(&c->mu); gpr_mu_destroy(&c->child_list_mu);
for (ii = 0; ii < c->send_extra_metadata_count; ii++) { for (ii = 0; ii < c->send_extra_metadata_count; ii++) {
GRPC_MDELEM_UNREF(exec_ctx, c->send_extra_metadata[ii].md); GRPC_MDELEM_UNREF(exec_ctx, c->send_extra_metadata[ii].md);
} }
@ -476,7 +480,7 @@ static void destroy_call(grpc_exec_ctx *exec_ctx, void *call,
for (i = 0; i < STATUS_SOURCE_COUNT; i++) { for (i = 0; i < STATUS_SOURCE_COUNT; i++) {
GRPC_ERROR_UNREF( GRPC_ERROR_UNREF(
unpack_received_status(gpr_atm_no_barrier_load(&c->status[i])).error); unpack_received_status(gpr_atm_acq_load(&c->status[i])).error);
} }
grpc_call_stack_destroy(exec_ctx, CALL_STACK_FROM_CALL(c), &c->final_info, grpc_call_stack_destroy(exec_ctx, CALL_STACK_FROM_CALL(c), &c->final_info,
@ -494,7 +498,7 @@ void grpc_call_destroy(grpc_call *c) {
GRPC_API_TRACE("grpc_call_destroy(c=%p)", 1, (c)); GRPC_API_TRACE("grpc_call_destroy(c=%p)", 1, (c));
if (parent) { if (parent) {
gpr_mu_lock(&parent->mu); gpr_mu_lock(&parent->child_list_mu);
if (c == parent->first_child) { if (c == parent->first_child) {
parent->first_child = c->sibling_next; parent->first_child = c->sibling_next;
if (c == parent->first_child) { if (c == parent->first_child) {
@ -503,15 +507,14 @@ void grpc_call_destroy(grpc_call *c) {
c->sibling_prev->sibling_next = c->sibling_next; c->sibling_prev->sibling_next = c->sibling_next;
c->sibling_next->sibling_prev = c->sibling_prev; c->sibling_next->sibling_prev = c->sibling_prev;
} }
gpr_mu_unlock(&parent->mu); gpr_mu_unlock(&parent->child_list_mu);
GRPC_CALL_INTERNAL_UNREF(&exec_ctx, parent, "child"); GRPC_CALL_INTERNAL_UNREF(&exec_ctx, parent, "child");
} }
gpr_mu_lock(&c->mu);
GPR_ASSERT(!c->destroy_called); GPR_ASSERT(!c->destroy_called);
c->destroy_called = 1; c->destroy_called = 1;
cancel = c->sent_any_op && !c->received_final_op; cancel = gpr_atm_acq_load(&c->any_ops_sent_atm) &&
gpr_mu_unlock(&c->mu); !gpr_atm_acq_load(&c->received_final_op_atm);
if (cancel) { if (cancel) {
cancel_with_error(&exec_ctx, c, STATUS_FROM_API_OVERRIDE, cancel_with_error(&exec_ctx, c, STATUS_FROM_API_OVERRIDE,
GRPC_ERROR_CANCELLED); GRPC_ERROR_CANCELLED);
@ -576,53 +579,25 @@ grpc_call_error grpc_call_cancel_with_status(grpc_call *c,
"c=%p, status=%d, description=%s, reserved=%p)", "c=%p, status=%d, description=%s, reserved=%p)",
4, (c, (int)status, description, reserved)); 4, (c, (int)status, description, reserved));
GPR_ASSERT(reserved == NULL); GPR_ASSERT(reserved == NULL);
gpr_mu_lock(&c->mu);
cancel_with_status(&exec_ctx, c, STATUS_FROM_API_OVERRIDE, status, cancel_with_status(&exec_ctx, c, STATUS_FROM_API_OVERRIDE, status,
description); description);
gpr_mu_unlock(&c->mu);
grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx);
return GRPC_CALL_OK; return GRPC_CALL_OK;
} }
typedef struct termination_closure { static void done_termination(grpc_exec_ctx *exec_ctx, void *call,
grpc_closure closure;
grpc_call *call;
grpc_transport_stream_op op;
} termination_closure;
static void done_termination(grpc_exec_ctx *exec_ctx, void *tcp,
grpc_error *error) {
termination_closure *tc = tcp;
GRPC_CALL_INTERNAL_UNREF(exec_ctx, tc->call, "termination");
gpr_free(tc);
}
static void send_termination(grpc_exec_ctx *exec_ctx, void *tcp,
grpc_error *error) { grpc_error *error) {
termination_closure *tc = tcp; GRPC_CALL_INTERNAL_UNREF(exec_ctx, call, "termination");
memset(&tc->op, 0, sizeof(tc->op));
tc->op.cancel_error = GRPC_ERROR_REF(error);
/* reuse closure to catch completion */
tc->op.on_complete = grpc_closure_init(&tc->closure, done_termination, tc,
grpc_schedule_on_exec_ctx);
execute_op(exec_ctx, tc->call, &tc->op);
}
static void terminate_with_error(grpc_exec_ctx *exec_ctx, grpc_call *c,
grpc_error *error) {
termination_closure *tc = gpr_malloc(sizeof(*tc));
memset(tc, 0, sizeof(*tc));
tc->call = c;
GRPC_CALL_INTERNAL_REF(tc->call, "termination");
grpc_closure_sched(exec_ctx, grpc_closure_init(&tc->closure, send_termination,
tc, grpc_schedule_on_exec_ctx),
error);
} }
static void cancel_with_error(grpc_exec_ctx *exec_ctx, grpc_call *c, static void cancel_with_error(grpc_exec_ctx *exec_ctx, grpc_call *c,
status_source source, grpc_error *error) { status_source source, grpc_error *error) {
GRPC_CALL_INTERNAL_REF(c, "termination");
set_status_from_error(exec_ctx, c, source, GRPC_ERROR_REF(error)); set_status_from_error(exec_ctx, c, source, GRPC_ERROR_REF(error));
terminate_with_error(exec_ctx, c, error); grpc_transport_stream_op *op = grpc_make_transport_stream_op(
grpc_closure_create(done_termination, c, grpc_schedule_on_exec_ctx));
op->cancel_error = error;
execute_op(exec_ctx, c, op);
} }
static grpc_error *error_from_status(grpc_status_code status, static grpc_error *error_from_status(grpc_status_code status,
@ -736,9 +711,7 @@ static void set_incoming_compression_algorithm(
grpc_compression_algorithm grpc_call_test_only_get_compression_algorithm( grpc_compression_algorithm grpc_call_test_only_get_compression_algorithm(
grpc_call *call) { grpc_call *call) {
grpc_compression_algorithm algorithm; grpc_compression_algorithm algorithm;
gpr_mu_lock(&call->mu);
algorithm = call->incoming_compression_algorithm; algorithm = call->incoming_compression_algorithm;
gpr_mu_unlock(&call->mu);
return algorithm; return algorithm;
} }
@ -750,9 +723,7 @@ static grpc_compression_algorithm compression_algorithm_for_level_locked(
uint32_t grpc_call_test_only_get_message_flags(grpc_call *call) { uint32_t grpc_call_test_only_get_message_flags(grpc_call *call) {
uint32_t flags; uint32_t flags;
gpr_mu_lock(&call->mu);
flags = call->test_only_last_message_flags; flags = call->test_only_last_message_flags;
gpr_mu_unlock(&call->mu);
return flags; return flags;
} }
@ -806,9 +777,7 @@ static void set_encodings_accepted_by_peer(grpc_exec_ctx *exec_ctx,
uint32_t grpc_call_test_only_get_encodings_accepted_by_peer(grpc_call *call) { uint32_t grpc_call_test_only_get_encodings_accepted_by_peer(grpc_call *call) {
uint32_t encodings_accepted_by_peer; uint32_t encodings_accepted_by_peer;
gpr_mu_lock(&call->mu);
encodings_accepted_by_peer = call->encodings_accepted_by_peer; encodings_accepted_by_peer = call->encodings_accepted_by_peer;
gpr_mu_unlock(&call->mu);
return encodings_accepted_by_peer; return encodings_accepted_by_peer;
} }
@ -1077,7 +1046,7 @@ static void finish_batch_completion(grpc_exec_ctx *exec_ctx, void *user_data,
} }
static grpc_error *consolidate_batch_errors(batch_control *bctl) { static grpc_error *consolidate_batch_errors(batch_control *bctl) {
size_t n = (size_t)gpr_atm_no_barrier_load(&bctl->num_errors); size_t n = (size_t)gpr_atm_acq_load(&bctl->num_errors);
if (n == 0) { if (n == 0) {
return GRPC_ERROR_NONE; return GRPC_ERROR_NONE;
} else if (n == 1) { } else if (n == 1) {
@ -1104,8 +1073,6 @@ static void post_batch_completion(grpc_exec_ctx *exec_ctx,
grpc_call *call = bctl->call; grpc_call *call = bctl->call;
grpc_error *error = consolidate_batch_errors(bctl); grpc_error *error = consolidate_batch_errors(bctl);
gpr_mu_lock(&call->mu);
if (bctl->send_initial_metadata) { if (bctl->send_initial_metadata) {
grpc_metadata_batch_destroy( grpc_metadata_batch_destroy(
exec_ctx, exec_ctx,
@ -1124,20 +1091,23 @@ static void post_batch_completion(grpc_exec_ctx *exec_ctx,
&call->metadata_batch[1 /* is_receiving */][1 /* is_trailing */]; &call->metadata_batch[1 /* is_receiving */][1 /* is_trailing */];
recv_trailing_filter(exec_ctx, call, md); recv_trailing_filter(exec_ctx, call, md);
call->received_final_op = true;
/* propagate cancellation to any interested children */ /* propagate cancellation to any interested children */
gpr_atm_rel_store(&call->received_final_op_atm, 1);
gpr_mu_lock(&call->child_list_mu);
child_call = call->first_child; child_call = call->first_child;
if (child_call != NULL) { if (child_call != NULL) {
do { do {
next_child_call = child_call->sibling_next; next_child_call = child_call->sibling_next;
if (child_call->cancellation_is_inherited) { if (child_call->cancellation_is_inherited) {
GRPC_CALL_INTERNAL_REF(child_call, "propagate_cancel"); GRPC_CALL_INTERNAL_REF(child_call, "propagate_cancel");
grpc_call_cancel(child_call, NULL); cancel_with_error(exec_ctx, child_call, STATUS_FROM_API_OVERRIDE,
GRPC_ERROR_CANCELLED);
GRPC_CALL_INTERNAL_UNREF(exec_ctx, child_call, "propagate_cancel"); GRPC_CALL_INTERNAL_UNREF(exec_ctx, child_call, "propagate_cancel");
} }
child_call = next_child_call; child_call = next_child_call;
} while (child_call != call->first_child); } while (child_call != call->first_child);
} }
gpr_mu_unlock(&call->child_list_mu);
if (call->is_client) { if (call->is_client) {
get_final_status(call, set_status_value_directly, get_final_status(call, set_status_value_directly,
@ -1151,7 +1121,6 @@ static void post_batch_completion(grpc_exec_ctx *exec_ctx,
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);
error = GRPC_ERROR_NONE; error = GRPC_ERROR_NONE;
} }
gpr_mu_unlock(&call->mu);
if (bctl->is_notify_tag_closure) { if (bctl->is_notify_tag_closure) {
/* unrefs bctl->error */ /* unrefs bctl->error */
@ -1242,7 +1211,6 @@ static void receiving_stream_ready(grpc_exec_ctx *exec_ctx, void *bctlp,
grpc_error *error) { grpc_error *error) {
batch_control *bctl = bctlp; batch_control *bctl = bctlp;
grpc_call *call = bctl->call; grpc_call *call = bctl->call;
gpr_mu_lock(&bctl->call->mu);
if (error != GRPC_ERROR_NONE) { if (error != GRPC_ERROR_NONE) {
if (call->receiving_stream != NULL) { if (call->receiving_stream != NULL) {
grpc_byte_stream_destroy(exec_ctx, call->receiving_stream); grpc_byte_stream_destroy(exec_ctx, call->receiving_stream);
@ -1254,11 +1222,9 @@ static void receiving_stream_ready(grpc_exec_ctx *exec_ctx, void *bctlp,
} }
if (call->has_initial_md_been_received || error != GRPC_ERROR_NONE || if (call->has_initial_md_been_received || error != GRPC_ERROR_NONE ||
call->receiving_stream == NULL) { call->receiving_stream == NULL) {
gpr_mu_unlock(&bctl->call->mu);
process_data_after_md(exec_ctx, bctlp); process_data_after_md(exec_ctx, bctlp);
} else { } else {
call->saved_receiving_stream_ready_bctlp = bctlp; call->saved_receiving_stream_ready_bctlp = bctlp;
gpr_mu_unlock(&bctl->call->mu);
} }
} }
@ -1317,7 +1283,7 @@ static void validate_filtered_metadata(grpc_exec_ctx *exec_ctx,
static void add_batch_error(grpc_exec_ctx *exec_ctx, batch_control *bctl, static void add_batch_error(grpc_exec_ctx *exec_ctx, batch_control *bctl,
grpc_error *error, bool has_cancelled) { grpc_error *error, bool has_cancelled) {
if (error == GRPC_ERROR_NONE) return; if (error == GRPC_ERROR_NONE) return;
int idx = (int)gpr_atm_no_barrier_fetch_add(&bctl->num_errors, 1); int idx = (int)gpr_atm_full_fetch_add(&bctl->num_errors, 1);
if (idx == 0 && !has_cancelled) { if (idx == 0 && !has_cancelled) {
cancel_with_error(exec_ctx, bctl->call, STATUS_FROM_CORE, cancel_with_error(exec_ctx, bctl->call, STATUS_FROM_CORE,
GRPC_ERROR_REF(error)); GRPC_ERROR_REF(error));
@ -1330,8 +1296,6 @@ static void receiving_initial_metadata_ready(grpc_exec_ctx *exec_ctx,
batch_control *bctl = bctlp; batch_control *bctl = bctlp;
grpc_call *call = bctl->call; grpc_call *call = bctl->call;
gpr_mu_lock(&call->mu);
add_batch_error(exec_ctx, bctl, GRPC_ERROR_REF(error), false); add_batch_error(exec_ctx, bctl, GRPC_ERROR_REF(error), false);
if (error == GRPC_ERROR_NONE) { if (error == GRPC_ERROR_NONE) {
grpc_metadata_batch *md = grpc_metadata_batch *md =
@ -1357,11 +1321,9 @@ static void receiving_initial_metadata_ready(grpc_exec_ctx *exec_ctx,
receiving_stream_ready, call->saved_receiving_stream_ready_bctlp, receiving_stream_ready, call->saved_receiving_stream_ready_bctlp,
grpc_schedule_on_exec_ctx); grpc_schedule_on_exec_ctx);
call->saved_receiving_stream_ready_bctlp = NULL; call->saved_receiving_stream_ready_bctlp = NULL;
grpc_closure_sched(exec_ctx, saved_rsr_closure, GRPC_ERROR_REF(error)); grpc_closure_run(exec_ctx, saved_rsr_closure, GRPC_ERROR_REF(error));
} }
gpr_mu_unlock(&call->mu);
finish_batch_step(exec_ctx, bctl); finish_batch_step(exec_ctx, bctl);
} }
@ -1414,7 +1376,6 @@ static grpc_call_error call_start_batch(grpc_exec_ctx *exec_ctx,
bctl->notify_tag = notify_tag; bctl->notify_tag = notify_tag;
bctl->is_notify_tag_closure = (uint8_t)(is_notify_tag_closure != 0); bctl->is_notify_tag_closure = (uint8_t)(is_notify_tag_closure != 0);
gpr_mu_lock(&call->mu);
grpc_transport_stream_op *stream_op = &bctl->op; grpc_transport_stream_op *stream_op = &bctl->op;
memset(stream_op, 0, sizeof(*stream_op)); memset(stream_op, 0, sizeof(*stream_op));
stream_op->covered_by_poller = true; stream_op->covered_by_poller = true;
@ -1700,8 +1661,7 @@ static grpc_call_error call_start_batch(grpc_exec_ctx *exec_ctx,
grpc_closure_init(&bctl->finish_batch, finish_batch, bctl, grpc_closure_init(&bctl->finish_batch, finish_batch, bctl,
grpc_schedule_on_exec_ctx); grpc_schedule_on_exec_ctx);
stream_op->on_complete = &bctl->finish_batch; stream_op->on_complete = &bctl->finish_batch;
call->sent_any_op = true; gpr_atm_rel_store(&call->any_ops_sent_atm, 1);
gpr_mu_unlock(&call->mu);
execute_op(exec_ctx, call, stream_op); execute_op(exec_ctx, call, stream_op);
@ -1732,7 +1692,6 @@ done_with_error:
if (bctl->recv_final_op) { if (bctl->recv_final_op) {
call->requested_final_op = 0; call->requested_final_op = 0;
} }
gpr_mu_unlock(&call->mu);
goto done; goto done;
} }
@ -1781,10 +1740,8 @@ uint8_t grpc_call_is_client(grpc_call *call) { return call->is_client; }
grpc_compression_algorithm grpc_call_compression_for_level( grpc_compression_algorithm grpc_call_compression_for_level(
grpc_call *call, grpc_compression_level level) { grpc_call *call, grpc_compression_level level) {
gpr_mu_lock(&call->mu);
grpc_compression_algorithm algo = grpc_compression_algorithm algo =
compression_algorithm_for_level_locked(call, level); compression_algorithm_for_level_locked(call, level);
gpr_mu_unlock(&call->mu);
return algo; return algo;
} }

@ -255,8 +255,9 @@ typedef struct {
static void destroy_made_transport_stream_op(grpc_exec_ctx *exec_ctx, void *arg, static void destroy_made_transport_stream_op(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error) { grpc_error *error) {
made_transport_stream_op *op = arg; made_transport_stream_op *op = arg;
grpc_closure_sched(exec_ctx, op->inner_on_complete, GRPC_ERROR_REF(error)); grpc_closure *c = op->inner_on_complete;
gpr_free(op); gpr_free(op);
grpc_closure_run(exec_ctx, c, GRPC_ERROR_REF(error));
} }
grpc_transport_stream_op *grpc_make_transport_stream_op( grpc_transport_stream_op *grpc_make_transport_stream_op(

@ -33,9 +33,10 @@ import threading
import grpc import grpc
from grpc_health.v1 import health_pb2 from grpc_health.v1 import health_pb2
from grpc_health.v1 import health_pb2_grpc
class HealthServicer(health_pb2.HealthServicer): class HealthServicer(health_pb2_grpc.HealthServicer):
"""Servicer handling RPCs for service statuses.""" """Servicer handling RPCs for service statuses."""
def __init__(self): def __init__(self):

@ -34,6 +34,7 @@ import grpc
from grpc.framework.foundation import logging_pool from grpc.framework.foundation import logging_pool
from grpc_health.v1 import health from grpc_health.v1 import health
from grpc_health.v1 import health_pb2 from grpc_health.v1 import health_pb2
from grpc_health.v1 import health_pb2_grpc
from tests.unit.framework.common import test_constants from tests.unit.framework.common import test_constants
@ -52,11 +53,11 @@ class HealthServicerTest(unittest.TestCase):
server_pool = logging_pool.pool(test_constants.THREAD_CONCURRENCY) server_pool = logging_pool.pool(test_constants.THREAD_CONCURRENCY)
self._server = grpc.server(server_pool) self._server = grpc.server(server_pool)
port = self._server.add_insecure_port('[::]:0') port = self._server.add_insecure_port('[::]:0')
health_pb2.add_HealthServicer_to_server(servicer, self._server) health_pb2_grpc.add_HealthServicer_to_server(servicer, self._server)
self._server.start() self._server.start()
channel = grpc.insecure_channel('localhost:%d' % port) channel = grpc.insecure_channel('localhost:%d' % port)
self._stub = health_pb2.HealthStub(channel) self._stub = health_pb2_grpc.HealthStub(channel)
def test_empty_service(self): def test_empty_service(self):
request = health_pb2.HealthCheckRequest() request = health_pb2.HealthCheckRequest()

@ -34,7 +34,7 @@ load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer")
grpc_fuzzer( grpc_fuzzer(
name = "ssl_server_fuzzer", name = "ssl_server_fuzzer",
srcs = ["ssl_server_fuzzer.c"], srcs = ["ssl_server_fuzzer.c"],
deps = ["//:gpr", "//:grpc", "//test/core/util:grpc_test_util"], deps = ["//:gpr", "//:grpc", "//test/core/util:grpc_test_util", "//test/core/end2end:ssl_test_data"],
corpus = "corpus", corpus = "corpus",
copts = ["-std=c99"], copts = ["-std=c99"],
) )

@ -38,6 +38,7 @@
#include "src/core/lib/iomgr/load_file.h" #include "src/core/lib/iomgr/load_file.h"
#include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/credentials/credentials.h"
#include "src/core/lib/security/transport/security_connector.h" #include "src/core/lib/security/transport/security_connector.h"
#include "test/core/end2end/data/ssl_test_data.h"
#include "test/core/util/memory_counters.h" #include "test/core/util/memory_counters.h"
#include "test/core/util/mock_endpoint.h" #include "test/core/util/mock_endpoint.h"
@ -46,10 +47,6 @@ bool squelch = true;
// Turning this on will fail the leak check. // Turning this on will fail the leak check.
bool leak_check = false; bool leak_check = false;
#define SSL_CERT_PATH "src/core/lib/tsi/test_creds/server1.pem"
#define SSL_KEY_PATH "src/core/lib/tsi/test_creds/server1.key"
#define SSL_CA_PATH "src/core/lib/tsi/test_creds/ca.pem"
static void discard_write(grpc_slice slice) {} static void discard_write(grpc_slice slice) {}
static void dont_log(gpr_log_func_args *args) {} static void dont_log(gpr_log_func_args *args) {}
@ -88,12 +85,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
// Load key pair and establish server SSL credentials. // Load key pair and establish server SSL credentials.
grpc_ssl_pem_key_cert_pair pem_key_cert_pair; grpc_ssl_pem_key_cert_pair pem_key_cert_pair;
grpc_slice ca_slice, cert_slice, key_slice; grpc_slice ca_slice, cert_slice, key_slice;
GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file", ca_slice = grpc_slice_from_static_string(test_root_cert);
grpc_load_file(SSL_CA_PATH, 1, &ca_slice))); cert_slice = grpc_slice_from_static_string(test_server1_cert);
GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file", key_slice = grpc_slice_from_static_string(test_server1_key);
grpc_load_file(SSL_CERT_PATH, 1, &cert_slice)));
GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file",
grpc_load_file(SSL_KEY_PATH, 1, &key_slice)));
const char *ca_cert = (const char *)GRPC_SLICE_START_PTR(ca_slice); const char *ca_cert = (const char *)GRPC_SLICE_START_PTR(ca_slice);
pem_key_cert_pair.private_key = (const char *)GRPC_SLICE_START_PTR(key_slice); pem_key_cert_pair.private_key = (const char *)GRPC_SLICE_START_PTR(key_slice);
pem_key_cert_pair.cert_chain = (const char *)GRPC_SLICE_START_PTR(cert_slice); pem_key_cert_pair.cert_chain = (const char *)GRPC_SLICE_START_PTR(cert_slice);

@ -41,7 +41,7 @@
#include <grpc/support/useful.h> #include <grpc/support/useful.h>
#include "src/core/lib/transport/byte_stream.h" #include "src/core/lib/transport/byte_stream.h"
#include "src/proto/grpc/testing/messages.grpc.pb.h" #include "src/proto/grpc/testing/messages.pb.h"
#include "src/proto/grpc/testing/test.grpc.pb.h" #include "src/proto/grpc/testing/test.grpc.pb.h"
#include "test/cpp/interop/http2_client.h" #include "test/cpp/interop/http2_client.h"

@ -38,7 +38,7 @@
#include <grpc++/channel.h> #include <grpc++/channel.h>
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include "src/proto/grpc/testing/messages.grpc.pb.h" #include "src/proto/grpc/testing/messages.pb.h"
#include "src/proto/grpc/testing/test.grpc.pb.h" #include "src/proto/grpc/testing/test.grpc.pb.h"
namespace grpc { namespace grpc {

@ -46,8 +46,8 @@
#include <grpc/support/useful.h> #include <grpc/support/useful.h>
#include "src/core/lib/transport/byte_stream.h" #include "src/core/lib/transport/byte_stream.h"
#include "src/proto/grpc/testing/empty.grpc.pb.h" #include "src/proto/grpc/testing/empty.pb.h"
#include "src/proto/grpc/testing/messages.grpc.pb.h" #include "src/proto/grpc/testing/messages.pb.h"
#include "src/proto/grpc/testing/test.grpc.pb.h" #include "src/proto/grpc/testing/test.grpc.pb.h"
#include "test/cpp/interop/client_helper.h" #include "test/cpp/interop/client_helper.h"
#include "test/cpp/interop/interop_client.h" #include "test/cpp/interop/interop_client.h"

@ -38,7 +38,7 @@
#include <grpc++/channel.h> #include <grpc++/channel.h>
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include "src/proto/grpc/testing/messages.grpc.pb.h" #include "src/proto/grpc/testing/messages.pb.h"
#include "src/proto/grpc/testing/test.grpc.pb.h" #include "src/proto/grpc/testing/test.grpc.pb.h"
namespace grpc { namespace grpc {

@ -48,8 +48,8 @@
#include "src/core/lib/support/string.h" #include "src/core/lib/support/string.h"
#include "src/core/lib/transport/byte_stream.h" #include "src/core/lib/transport/byte_stream.h"
#include "src/proto/grpc/testing/empty.grpc.pb.h" #include "src/proto/grpc/testing/empty.pb.h"
#include "src/proto/grpc/testing/messages.grpc.pb.h" #include "src/proto/grpc/testing/messages.pb.h"
#include "src/proto/grpc/testing/test.grpc.pb.h" #include "src/proto/grpc/testing/test.grpc.pb.h"
#include "test/cpp/interop/server_helper.h" #include "test/cpp/interop/server_helper.h"
#include "test/cpp/util/test_config.h" #include "test/cpp/util/test_config.h"

@ -40,8 +40,8 @@
#include <grpc++/support/channel_arguments.h> #include <grpc++/support/channel_arguments.h>
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include "src/proto/grpc/testing/empty.grpc.pb.h" #include "src/proto/grpc/testing/empty.pb.h"
#include "src/proto/grpc/testing/messages.grpc.pb.h" #include "src/proto/grpc/testing/messages.pb.h"
#include "src/proto/grpc/testing/test.grpc.pb.h" #include "src/proto/grpc/testing/test.grpc.pb.h"
#include "test/cpp/util/create_test_channel.h" #include "test/cpp/util/create_test_channel.h"
#include "test/cpp/util/test_config.h" #include "test/cpp/util/test_config.h"

@ -47,8 +47,8 @@
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include "src/proto/grpc/testing/empty.grpc.pb.h" #include "src/proto/grpc/testing/empty.pb.h"
#include "src/proto/grpc/testing/messages.grpc.pb.h" #include "src/proto/grpc/testing/messages.pb.h"
#include "src/proto/grpc/testing/test.grpc.pb.h" #include "src/proto/grpc/testing/test.grpc.pb.h"
#include "test/core/util/reconnect_server.h" #include "test/core/util/reconnect_server.h"
#include "test/cpp/util/test_config.h" #include "test/cpp/util/test_config.h"

@ -48,8 +48,15 @@ BENCHMARK(BM_Arena_NoOp)->Range(1, 1024 * 1024);
static void BM_Arena_ManyAlloc(benchmark::State& state) { static void BM_Arena_ManyAlloc(benchmark::State& state) {
gpr_arena* a = gpr_arena_create(state.range(0)); gpr_arena* a = gpr_arena_create(state.range(0));
const size_t realloc_after =
1024 * 1024 * 1024 / ((state.range(1) + 15) & 0xffffff0u);
while (state.KeepRunning()) { while (state.KeepRunning()) {
gpr_arena_alloc(a, state.range(1)); gpr_arena_alloc(a, state.range(1));
// periodically recreate arena to avoid OOM
if (state.iterations() % realloc_after == 0) {
gpr_arena_destroy(a);
a = gpr_arena_create(state.range(0));
}
} }
gpr_arena_destroy(a); gpr_arena_destroy(a);
} }

@ -46,7 +46,7 @@
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/time.h> #include <grpc/support/time.h>
#include "src/proto/grpc/testing/payloads.grpc.pb.h" #include "src/proto/grpc/testing/payloads.pb.h"
#include "src/proto/grpc/testing/services.grpc.pb.h" #include "src/proto/grpc/testing/services.grpc.pb.h"
#include "test/cpp/qps/histogram.h" #include "test/cpp/qps/histogram.h"

@ -36,7 +36,7 @@
#include <memory> #include <memory>
#include "src/proto/grpc/testing/control.grpc.pb.h" #include "src/proto/grpc/testing/control.pb.h"
#include "test/cpp/qps/histogram.h" #include "test/cpp/qps/histogram.h"
namespace grpc { namespace grpc {

@ -35,7 +35,7 @@
#define TEST_QPS_HISTOGRAM_H #define TEST_QPS_HISTOGRAM_H
#include <grpc/support/histogram.h> #include <grpc/support/histogram.h>
#include "src/proto/grpc/testing/stats.grpc.pb.h" #include "src/proto/grpc/testing/stats.pb.h"
namespace grpc { namespace grpc {
namespace testing { namespace testing {

@ -38,8 +38,8 @@
#include <grpc/support/cpu.h> #include <grpc/support/cpu.h>
#include <vector> #include <vector>
#include "src/proto/grpc/testing/control.grpc.pb.h" #include "src/proto/grpc/testing/control.pb.h"
#include "src/proto/grpc/testing/messages.grpc.pb.h" #include "src/proto/grpc/testing/messages.pb.h"
#include "test/core/end2end/data/ssl_test_data.h" #include "test/core/end2end/data/ssl_test_data.h"
#include "test/core/util/port.h" #include "test/core/util/port.h"
#include "test/cpp/qps/usage_timer.h" #include "test/cpp/qps/usage_timer.h"

@ -0,0 +1,3 @@
[libfuzzer]
max_len = 2048
dict = api_fuzzer.dictionary

@ -0,0 +1,3 @@
[libfuzzer]
max_len = 2048
dict = hpack.dictionary

@ -0,0 +1,2 @@
[libfuzzer]
max_len = 512

@ -0,0 +1,2 @@
[libfuzzer]
max_len = 128

@ -0,0 +1,2 @@
[libfuzzer]
max_len = 128

@ -0,0 +1,3 @@
[libfuzzer]
max_len = 512
dict = hpack.dictionary

@ -0,0 +1,3 @@
[libfuzzer]
max_len = 2048

@ -0,0 +1,3 @@
[libfuzzer]
max_len = 2048

@ -0,0 +1,3 @@
[libfuzzer]
max_len = 2048
dict = hpack.dictionary

@ -0,0 +1,2 @@
[libfuzzer]
max_len = 2048

@ -0,0 +1,2 @@
[libfuzzer]
max_len = 128

@ -0,0 +1,119 @@
#!/usr/bin/env python2.7
# Copyright 2017, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""Upload docker images to Google Container Registry."""
from __future__ import print_function
import argparse
import atexit
import os
import shutil
import subprocess
import tempfile
argp = argparse.ArgumentParser(description='Run interop tests.')
argp.add_argument('--gcr_path',
default='gcr.io/grpc-testing',
help='Path of docker images in Google Container Registry')
argp.add_argument('--gcr_tag',
default='latest',
help='the tag string for the images to upload')
argp.add_argument('--with_files',
default=[],
nargs='+',
help='additional files to include in the docker image')
argp.add_argument('--with_file_dest',
default='/var/local/image_info',
help='Destination directory for with_files inside docker image')
argp.add_argument('--images',
default=[],
nargs='+',
help='local docker images in the form of repo:tag ' +
'(i.e. grpc_interop_java:26328ad8) to upload')
argp.add_argument('--keep',
action='store_true',
help='keep the created local images after uploading to GCR')
args = argp.parse_args()
def upload_to_gcr(image):
"""Tags and Pushes a docker image in Google Containger Registry.
image: docker image name, i.e. grpc_interop_java:26328ad8
A docker image image_foo:tag_old will be uploaded as
<gcr_path>/image_foo:<gcr_tag>
after inserting extra with_files under with_file_dest in the image. The
original image name will be stored as label original_name:"image_foo:tag_old".
"""
tag_idx = image.find(':')
if tag_idx == -1:
print('Failed to parse docker image name %s' % image)
return False
new_tag = '%s/%s:%s' % (args.gcr_path, image[:tag_idx], args.gcr_tag)
lines = ['FROM ' + image]
lines.append('LABEL original_name="%s"' % image)
temp_dir = tempfile.mkdtemp()
atexit.register(lambda: subprocess.call(['rm', '-rf', temp_dir]))
# Copy with_files inside the tmp directory, which will be the docker build
# context.
for f in args.with_files:
shutil.copy(f, temp_dir)
lines.append('COPY %s %s/' % (os.path.basename(f), args.with_file_dest))
# Create a Dockerfile.
with open(os.path.join(temp_dir, 'Dockerfile'), 'w') as f:
f.write('\n'.join(lines))
build_cmd = ['docker', 'build', '--rm', '--tag', new_tag, temp_dir]
subprocess.check_output(build_cmd)
if not args.keep:
atexit.register(lambda: subprocess.call(['docker', 'rmi', new_tag]))
# Upload to GCR.
if args.gcr_path:
subprocess.call(['gcloud', 'docker', '--', 'push', new_tag])
return True
for image in args.images:
upload_to_gcr(image)

@ -58,7 +58,7 @@
{ {
"config": "ubsan", "config": "ubsan",
"environ": { "environ": {
"UBSAN_OPTIONS": "halt_on_error=1:print_stacktrace=1" "UBSAN_OPTIONS": "halt_on_error=1:print_stacktrace=1:suppressions=tools/ubsan_suppressions.txt"
} }
}, },
{ {

@ -0,0 +1,7 @@
# boringssl stuff
nonnull-attribute:bn_wexpand
nonnull-attribute:CBB_add_bytes
nonnull-attribute:rsa_blinding_get
nonnull-attribute:ssl_copy_key_material
alignment:CRYPTO_cbc128_encrypt
Loading…
Cancel
Save