Fix race conditions and more grpc_inits required. csharp tests will be fixed in a different PR

pull/13058/head
Yash Tibrewal 7 years ago
parent 03412ee9de
commit 26e934245d
  1. 3
      test/core/http/request_fuzzer.cc
  2. 3
      test/core/http/response_fuzzer.cc
  3. 2
      test/core/iomgr/resolve_address_posix_test.cc
  4. 3
      test/core/nanopb/fuzzer_response.cc
  5. 3
      test/core/nanopb/fuzzer_serverlist.cc
  6. 2
      test/core/surface/completion_queue_threading_test.cc

@ -20,6 +20,7 @@
#include <stdint.h>
#include <string.h>
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include "src/core/lib/http/parser.h"
@ -30,6 +31,7 @@ bool leak_check = true;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
grpc_http_parser parser;
grpc_http_request request;
grpc_init();
memset(&request, 0, sizeof(request));
grpc_http_parser_init(&parser, GRPC_HTTP_REQUEST, &request);
grpc_slice slice = grpc_slice_from_copied_buffer((const char*)data, size);
@ -38,5 +40,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
grpc_slice_unref(slice);
grpc_http_parser_destroy(&parser);
grpc_http_request_destroy(&request);
grpc_shutdown();
return 0;
}

@ -19,6 +19,7 @@
#include <stdint.h>
#include <string.h>
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include "src/core/lib/http/parser.h"
@ -29,6 +30,7 @@ bool leak_check = true;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
grpc_http_parser parser;
grpc_http_response response;
grpc_init();
memset(&response, 0, sizeof(response));
grpc_http_parser_init(&parser, GRPC_HTTP_RESPONSE, &response);
grpc_slice slice = grpc_slice_from_copied_buffer((const char*)data, size);
@ -37,5 +39,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
grpc_slice_unref(slice);
grpc_http_parser_destroy(&parser);
grpc_http_response_destroy(&response);
grpc_shutdown();
return 0;
}

@ -79,9 +79,9 @@ static grpc_millis n_sec_deadline(int seconds) {
static void actually_poll(void* argsp) {
args_struct* args = static_cast<args_struct*>(argsp);
grpc_core::ExecCtx _local_exec_ctx;
grpc_millis deadline = n_sec_deadline(10);
while (true) {
grpc_core::ExecCtx _local_exec_ctx;
bool done = gpr_atm_acq_load(&args->done_atm) != 0;
if (done) {
break;

@ -19,6 +19,7 @@
#include <stdint.h>
#include <string.h>
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h"
@ -29,6 +30,7 @@ bool leak_check = true;
static void dont_log(gpr_log_func_args* args) {}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
grpc_init();
if (squelch) gpr_set_log_function(dont_log);
grpc_slice slice = grpc_slice_from_copied_buffer((const char*)data, size);
grpc_grpclb_initial_response* response;
@ -36,5 +38,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
grpc_grpclb_initial_response_destroy(response);
}
grpc_slice_unref(slice);
grpc_shutdown();
return 0;
}

@ -19,6 +19,7 @@
#include <stdint.h>
#include <string.h>
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h"
@ -29,6 +30,7 @@ bool leak_check = true;
static void dont_log(gpr_log_func_args* args) {}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
grpc_init();
if (squelch) gpr_set_log_function(dont_log);
grpc_slice slice = grpc_slice_from_copied_buffer((const char*)data, size);
grpc_grpclb_serverlist* serverlist;
@ -36,5 +38,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
grpc_grpclb_destroy_serverlist(serverlist);
}
grpc_slice_unref(slice);
grpc_shutdown();
return 0;
}

@ -142,7 +142,6 @@ static void free_completion(void* arg, grpc_cq_completion* completion) {
static void producer_thread(void* arg) {
test_thread_options* opt = static_cast<test_thread_options*>(arg);
int i;
grpc_core::ExecCtx _local_exec_ctx;
gpr_log(GPR_INFO, "producer %d started", opt->id);
gpr_event_set(&opt->on_started, (void*)(intptr_t)1);
@ -159,6 +158,7 @@ static void producer_thread(void* arg) {
gpr_log(GPR_INFO, "producer %d phase 2", opt->id);
for (i = 0; i < TEST_THREAD_EVENTS; i++) {
grpc_core::ExecCtx _local_exec_ctx;
grpc_cq_end_op(opt->cc, (void*)(intptr_t)1, GRPC_ERROR_NONE,
free_completion, nullptr,
static_cast<grpc_cq_completion*>(

Loading…
Cancel
Save