[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_ASSERT (#36471)

[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_ASSERT
Replacing GPR_ASSERT with absl CHECK.
These changes have been made using string replacement and regex.
Will not be replacing all instances of CHECK with CHECK_EQ , CHECK_NE etc because there are too many callsites. Only ones which are doable using very simple regex with least chance of failure will be replaced.
Given that we have 5000+ instances of GPR_ASSERT to edit, Doing it manually is too much work for both the author and reviewer.

<!--

If you know who should review your pull request, please assign it to that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the appropriate
lang label.

-->

Closes #36471

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36471 from tanvi-jagtap:tjagtap_src_core_lib_misc 420b5458bd
PiperOrigin-RevId: 629629223
pull/36492/head
Tanvi Jagtap 9 months ago committed by Copybara-Service
parent e614dafd89
commit 760f2ae46d
  1. 11
      BUILD
  2. 19
      CMakeLists.txt
  3. 17
      build_autogenerated.yaml
  4. 34
      src/core/BUILD
  5. 4
      src/core/lib/address_utils/parse_address.cc
  6. 20
      src/core/lib/address_utils/sockaddr_utils.cc
  7. 11
      src/core/lib/channel/call_tracer.cc
  8. 5
      src/core/lib/channel/channel_args.cc
  9. 12
      src/core/lib/channel/channel_stack.cc
  10. 3
      src/core/lib/channel/connected_channel.cc
  11. 14
      src/core/lib/channel/metrics.cc
  12. 132
      src/core/lib/channel/promise_based_filter.cc
  13. 92
      src/core/lib/channel/promise_based_filter.h
  14. 3
      src/core/lib/compression/compression_internal.cc
  15. 14
      src/core/lib/compression/message_compress.cc
  16. 14
      src/core/lib/config/core_configuration.cc
  17. 9
      src/core/lib/config/core_configuration.h
  18. 3
      src/core/lib/config/load_config.cc
  19. 3
      src/core/lib/debug/event_log.cc
  20. 7
      src/core/lib/experiments/config.cc
  21. 5
      src/core/lib/http/httpcli.cc
  22. 7
      src/core/lib/http/parser.cc
  23. 5
      src/core/lib/json/json_reader.cc
  24. 14
      src/core/lib/resource_quota/connection_quota.cc
  25. 19
      src/core/lib/resource_quota/memory_quota.cc
  26. 5
      src/core/lib/resource_quota/memory_quota.h
  27. 4
      src/core/lib/resource_quota/thread_quota.cc
  28. 1
      src/python/grpcio_observability/observability_lib_deps.py

11
BUILD

@ -1712,6 +1712,7 @@ grpc_cc_library(
"//src/core:lib/channel/call_tracer.h",
],
external_deps = [
"absl/log:check",
"absl/status",
"absl/strings",
"absl/types:optional",
@ -1989,6 +1990,7 @@ grpc_cc_library(
"absl/container:inlined_vector",
"absl/functional:any_invocable",
"absl/functional:function_ref",
"absl/log:check",
"absl/meta:type_traits",
"absl/status",
"absl/status:statusor",
@ -2973,6 +2975,7 @@ grpc_cc_library(
external_deps = [
"absl/flags:flag",
"absl/flags:marshalling",
"absl/log:check",
"absl/strings",
"absl/types:optional",
],
@ -3008,7 +3011,10 @@ grpc_cc_library(
srcs = [
"//src/core:lib/config/core_configuration.cc",
],
external_deps = ["absl/functional:any_invocable"],
external_deps = [
"absl/functional:any_invocable",
"absl/log:check",
],
language = "c++",
public_hdrs = [
"//src/core:lib/config/core_configuration.h",
@ -3205,6 +3211,7 @@ grpc_cc_library(
"//src/core:lib/address_utils/sockaddr_utils.h",
],
external_deps = [
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -3330,6 +3337,7 @@ grpc_cc_library(
"//src/core:lib/iomgr/grpc_if_nametoindex.h",
],
external_deps = [
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -3819,6 +3827,7 @@ grpc_cc_library(
external_deps = [
"absl/base:core_headers",
"absl/functional:bind_front",
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings",

19
CMakeLists.txt generated

@ -1748,6 +1748,7 @@ target_link_libraries(gpr
absl::flags
absl::flags_marshalling
absl::any_invocable
absl::check
absl::log
absl::memory
absl::random_random
@ -2676,7 +2677,6 @@ target_link_libraries(grpc
absl::bind_front
absl::function_ref
absl::hash
absl::check
absl::type_traits
absl::random_bit_gen_ref
absl::random_distributions
@ -3378,7 +3378,6 @@ target_link_libraries(grpc_unsecure
absl::bind_front
absl::function_ref
absl::hash
absl::check
absl::type_traits
absl::random_bit_gen_ref
absl::random_distributions
@ -5443,7 +5442,6 @@ target_link_libraries(grpc_authorization_provider
absl::inlined_vector
absl::function_ref
absl::hash
absl::check
absl::type_traits
absl::statusor
absl::span
@ -5930,7 +5928,6 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_POSIX)
target_link_libraries(static_stride_scheduler_benchmark
${_gRPC_ALLTARGETS_LIBRARIES}
absl::algorithm_container
absl::check
absl::span
${_gRPC_BENCHMARK_LIBRARIES}
gpr
@ -8580,7 +8577,6 @@ target_link_libraries(call_filters_test
absl::inlined_vector
absl::function_ref
absl::hash
absl::check
absl::type_traits
absl::statusor
absl::utility
@ -10241,7 +10237,6 @@ target_link_libraries(chunked_vector_test
absl::config
absl::function_ref
absl::hash
absl::check
absl::type_traits
absl::statusor
gpr
@ -13385,7 +13380,6 @@ target_link_libraries(exec_ctx_wakeup_scheduler_test
upb_message_lib
absl::config
absl::hash
absl::check
absl::type_traits
absl::statusor
gpr
@ -14255,7 +14249,6 @@ target_link_libraries(flow_control_test
absl::config
absl::function_ref
absl::hash
absl::check
absl::type_traits
absl::statusor
absl::span
@ -14341,7 +14334,6 @@ target_link_libraries(for_each_test
absl::config
absl::function_ref
absl::hash
absl::check
absl::type_traits
absl::statusor
gpr
@ -14431,7 +14423,6 @@ target_include_directories(forkable_test
target_link_libraries(forkable_test
${_gRPC_ALLTARGETS_LIBRARIES}
gtest
absl::check
absl::statusor
gpr
)
@ -18006,7 +17997,6 @@ target_link_libraries(interception_chain_test
absl::inlined_vector
absl::function_ref
absl::hash
absl::check
absl::type_traits
absl::statusor
absl::span
@ -18095,7 +18085,6 @@ target_link_libraries(interceptor_list_test
absl::config
absl::function_ref
absl::hash
absl::check
absl::type_traits
absl::statusor
gpr
@ -19289,7 +19278,6 @@ target_link_libraries(map_pipe_test
absl::config
absl::function_ref
absl::hash
absl::check
absl::type_traits
absl::statusor
gpr
@ -21553,7 +21541,6 @@ target_link_libraries(periodic_update_test
upb_message_lib
absl::function_ref
absl::hash
absl::check
absl::statusor
gpr
)
@ -29860,7 +29847,6 @@ target_include_directories(test_core_event_engine_posix_timer_heap_test
target_link_libraries(test_core_event_engine_posix_timer_heap_test
${_gRPC_ALLTARGETS_LIBRARIES}
gtest
absl::check
absl::statusor
gpr
)
@ -29959,7 +29945,6 @@ target_link_libraries(test_core_event_engine_slice_buffer_test
${_gRPC_ALLTARGETS_LIBRARIES}
gtest
absl::hash
absl::check
absl::statusor
absl::utility
gpr
@ -36934,7 +36919,7 @@ generate_pkgconfig(
"gpr"
"gRPC platform support library"
"${gRPC_CORE_VERSION}"
"absl_any_invocable absl_base absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_log absl_log_severity absl_memory absl_optional absl_random_random absl_status absl_str_format absl_strings absl_synchronization absl_time absl_variant"
"absl_any_invocable absl_base absl_check absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_log absl_log_severity absl_memory absl_optional absl_random_random absl_status absl_str_format absl_strings absl_synchronization absl_time absl_variant"
""
"-lgpr"
""

@ -130,6 +130,7 @@ libs:
- absl/flags:flag
- absl/flags:marshalling
- absl/functional:any_invocable
- absl/log:check
- absl/log:log
- absl/memory:memory
- absl/random:random
@ -2055,7 +2056,6 @@ libs:
- absl/functional:bind_front
- absl/functional:function_ref
- absl/hash:hash
- absl/log:check
- absl/meta:type_traits
- absl/random:bit_gen_ref
- absl/random:distributions
@ -3114,7 +3114,6 @@ libs:
- absl/functional:bind_front
- absl/functional:function_ref
- absl/hash:hash
- absl/log:check
- absl/meta:type_traits
- absl/random:bit_gen_ref
- absl/random:distributions
@ -5028,7 +5027,6 @@ libs:
- absl/container:inlined_vector
- absl/functional:function_ref
- absl/hash:hash
- absl/log:check
- absl/meta:type_traits
- absl/status:statusor
- absl/types:span
@ -5172,7 +5170,6 @@ targets:
- test/core/load_balancing/static_stride_scheduler_benchmark.cc
deps:
- absl/algorithm:container
- absl/log:check
- absl/types:span
- benchmark
- gpr
@ -6520,7 +6517,6 @@ targets:
- absl/container:inlined_vector
- absl/functional:function_ref
- absl/hash:hash
- absl/log:check
- absl/meta:type_traits
- absl/status:statusor
- absl/utility:utility
@ -7775,7 +7771,6 @@ targets:
- absl/base:config
- absl/functional:function_ref
- absl/hash:hash
- absl/log:check
- absl/meta:type_traits
- absl/status:statusor
- gpr
@ -9257,7 +9252,6 @@ targets:
- upb_message_lib
- absl/base:config
- absl/hash:hash
- absl/log:check
- absl/meta:type_traits
- absl/status:statusor
- gpr
@ -9900,7 +9894,6 @@ targets:
- absl/base:config
- absl/functional:function_ref
- absl/hash:hash
- absl/log:check
- absl/meta:type_traits
- absl/status:statusor
- absl/types:span
@ -10036,7 +10029,6 @@ targets:
- absl/base:config
- absl/functional:function_ref
- absl/hash:hash
- absl/log:check
- absl/meta:type_traits
- absl/status:statusor
- gpr
@ -10069,7 +10061,6 @@ targets:
- test/core/event_engine/forkable_test.cc
deps:
- gtest
- absl/log:check
- absl/status:statusor
- gpr
- name: format_request_test
@ -12160,7 +12151,6 @@ targets:
- absl/container:inlined_vector
- absl/functional:function_ref
- absl/hash:hash
- absl/log:check
- absl/meta:type_traits
- absl/status:statusor
- absl/types:span
@ -12291,7 +12281,6 @@ targets:
- absl/base:config
- absl/functional:function_ref
- absl/hash:hash
- absl/log:check
- absl/meta:type_traits
- absl/status:statusor
- gpr
@ -12975,7 +12964,6 @@ targets:
- absl/base:config
- absl/functional:function_ref
- absl/hash:hash
- absl/log:check
- absl/meta:type_traits
- absl/status:statusor
- gpr
@ -14176,7 +14164,6 @@ targets:
- upb_message_lib
- absl/functional:function_ref
- absl/hash:hash
- absl/log:check
- absl/status:statusor
- gpr
uses_polling: false
@ -19335,7 +19322,6 @@ targets:
- test/core/event_engine/posix/timer_heap_test.cc
deps:
- gtest
- absl/log:check
- absl/status:statusor
- gpr
uses_polling: false
@ -19389,7 +19375,6 @@ targets:
deps:
- gtest
- absl/hash:hash
- absl/log:check
- absl/status:statusor
- absl/utility:utility
- gpr

@ -196,6 +196,7 @@ grpc_cc_library(
),
external_deps = [
"absl/functional:any_invocable",
"absl/log:check",
"absl/strings",
],
language = "c++",
@ -1154,6 +1155,9 @@ grpc_cc_library(
grpc_cc_library(
name = "ref_counted",
external_deps = [
"absl/log:check",
],
language = "c++",
public_hdrs = ["lib/gprpp/ref_counted.h"],
deps = [
@ -1167,6 +1171,9 @@ grpc_cc_library(
grpc_cc_library(
name = "dual_ref_counted",
external_deps = [
"absl/log:check",
],
language = "c++",
public_hdrs = ["lib/gprpp/dual_ref_counted.h"],
deps = [
@ -1359,6 +1366,7 @@ grpc_cc_library(
external_deps = [
"absl/base:core_headers",
"absl/container:flat_hash_set",
"absl/log:check",
"absl/status",
"absl/strings",
"absl/types:optional",
@ -1429,7 +1437,10 @@ grpc_cc_library(
hdrs = [
"lib/resource_quota/thread_quota.h",
],
external_deps = ["absl/base:core_headers"],
external_deps = [
"absl/base:core_headers",
"absl/log:check",
],
deps = [
"ref_counted",
"//:gpr",
@ -1445,7 +1456,10 @@ grpc_cc_library(
hdrs = [
"lib/resource_quota/connection_quota.h",
],
external_deps = ["absl/base:core_headers"],
external_deps = [
"absl/base:core_headers",
"absl/log:check",
],
deps = [
"memory_quota",
"ref_counted",
@ -2930,6 +2944,7 @@ grpc_cc_library(
],
external_deps = [
"absl/base:core_headers",
"absl/log:check",
"absl/strings",
"absl/types:span",
],
@ -3050,7 +3065,10 @@ grpc_cc_library(
"service_config/service_config.h",
"service_config/service_config_call_data.h",
],
external_deps = ["absl/strings"],
external_deps = [
"absl/log:check",
"absl/strings",
],
language = "c++",
deps = [
"arena",
@ -3102,6 +3120,7 @@ grpc_cc_library(
"lib/channel/channel_args.h",
],
external_deps = [
"absl/log:check",
"absl/meta:type_traits",
"absl/strings",
"absl/strings:str_format",
@ -4371,6 +4390,7 @@ grpc_cc_library(
],
external_deps = [
"absl/base:core_headers",
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -4482,6 +4502,7 @@ grpc_cc_library(
],
external_deps = [
"absl/base:core_headers",
"absl/log:check",
"absl/meta:type_traits",
"absl/random",
"absl/status",
@ -5602,7 +5623,10 @@ grpc_cc_library(
grpc_cc_library(
name = "down_cast",
hdrs = ["lib/gprpp/down_cast.h"],
external_deps = ["absl/base:config"],
external_deps = [
"absl/base:config",
"absl/log:check",
],
deps = ["//:gpr"],
)
@ -7453,6 +7477,7 @@ grpc_cc_library(
],
external_deps = [
"absl/container:inlined_vector",
"absl/log:check",
"absl/strings",
"absl/strings:str_format",
"absl/types:optional",
@ -7614,6 +7639,7 @@ grpc_cc_library(
"absl/container:flat_hash_map",
"absl/functional:any_invocable",
"absl/functional:function_ref",
"absl/log:check",
"absl/strings",
"absl/types:span",
],

@ -18,6 +18,8 @@
#include "src/core/lib/address_utils/parse_address.h"
#include "absl/log/check.h"
#include <grpc/support/port_platform.h>
#include "src/core/lib/iomgr/port.h" // IWYU pragma: keep
@ -284,7 +286,7 @@ bool grpc_parse_ipv6_hostport(absl::string_view hostport,
char* host_end =
static_cast<char*>(gpr_memrchr(host.c_str(), '%', host.size()));
if (host_end != nullptr) {
GPR_ASSERT(host_end >= host.c_str());
CHECK(host_end >= host.c_str());
char host_without_scope[GRPC_INET6_ADDRSTRLEN + 1];
size_t host_without_scope_len =
static_cast<size_t>(host_end - host.c_str());

@ -21,6 +21,8 @@
#include <errno.h>
#include <inttypes.h>
#include "absl/log/check.h"
#include <grpc/support/port_platform.h>
#ifdef GRPC_HAVE_VSOCK
#include <linux/vm_sockets.h>
@ -110,7 +112,7 @@ static const uint8_t kV4MappedPrefix[] = {0, 0, 0, 0, 0, 0,
int grpc_sockaddr_is_v4mapped(const grpc_resolved_address* resolved_addr,
grpc_resolved_address* resolved_addr4_out) {
GPR_ASSERT(resolved_addr != resolved_addr4_out);
CHECK(resolved_addr != resolved_addr4_out);
const grpc_sockaddr* addr =
reinterpret_cast<const grpc_sockaddr*>(resolved_addr->addr);
grpc_sockaddr_in* addr4_out =
@ -140,7 +142,7 @@ int grpc_sockaddr_is_v4mapped(const grpc_resolved_address* resolved_addr,
int grpc_sockaddr_to_v4mapped(const grpc_resolved_address* resolved_addr,
grpc_resolved_address* resolved_addr6_out) {
GPR_ASSERT(resolved_addr != resolved_addr6_out);
CHECK(resolved_addr != resolved_addr6_out);
const grpc_sockaddr* addr =
reinterpret_cast<const grpc_sockaddr*>(resolved_addr->addr);
grpc_sockaddr_in6* addr6_out =
@ -203,7 +205,8 @@ void grpc_sockaddr_make_wildcard4(int port,
grpc_resolved_address* resolved_wild_out) {
grpc_sockaddr_in* wild_out =
reinterpret_cast<grpc_sockaddr_in*>(resolved_wild_out->addr);
GPR_ASSERT(port >= 0 && port < 65536);
CHECK(port >= 0);
CHECK(port < 65536);
memset(resolved_wild_out, 0, sizeof(*resolved_wild_out));
wild_out->sin_family = GRPC_AF_INET;
wild_out->sin_port = grpc_htons(static_cast<uint16_t>(port));
@ -214,7 +217,8 @@ void grpc_sockaddr_make_wildcard6(int port,
grpc_resolved_address* resolved_wild_out) {
grpc_sockaddr_in6* wild_out =
reinterpret_cast<grpc_sockaddr_in6*>(resolved_wild_out->addr);
GPR_ASSERT(port >= 0 && port < 65536);
CHECK(port >= 0);
CHECK(port < 65536);
memset(resolved_wild_out, 0, sizeof(*resolved_wild_out));
wild_out->sin6_family = GRPC_AF_INET6;
wild_out->sin6_port = grpc_htons(static_cast<uint16_t>(port));
@ -378,12 +382,14 @@ int grpc_sockaddr_set_port(grpc_resolved_address* resolved_addr, int port) {
grpc_sockaddr* addr = reinterpret_cast<grpc_sockaddr*>(resolved_addr->addr);
switch (addr->sa_family) {
case GRPC_AF_INET:
GPR_ASSERT(port >= 0 && port < 65536);
CHECK(port >= 0);
CHECK(port < 65536);
(reinterpret_cast<grpc_sockaddr_in*>(addr))->sin_port =
grpc_htons(static_cast<uint16_t>(port));
return 1;
case GRPC_AF_INET6:
GPR_ASSERT(port >= 0 && port < 65536);
CHECK(port >= 0);
CHECK(port < 65536);
(reinterpret_cast<grpc_sockaddr_in6*>(addr))->sin6_port =
grpc_htons(static_cast<uint16_t>(port));
return 1;
@ -437,7 +443,7 @@ void grpc_sockaddr_mask_bits(grpc_resolved_address* address,
// We cannot use s6_addr32 since it is not defined on all platforms that we
// need it on.
uint32_t address_parts[4];
GPR_ASSERT(sizeof(addr6->sin6_addr) == sizeof(address_parts));
CHECK(sizeof(addr6->sin6_addr) == sizeof(address_parts));
memcpy(address_parts, &addr6->sin6_addr, sizeof(grpc_in6_addr));
if (mask_bits <= 32) {
uint32_t mask_ip_addr = (~(uint32_t{0})) << (32 - mask_bits);

@ -22,6 +22,8 @@
#include <utility>
#include <vector>
#include "absl/log/check.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
@ -76,7 +78,7 @@ class DelegatingClientCallTracer : public ClientCallTracer {
explicit DelegatingClientCallAttemptTracer(
std::vector<CallAttemptTracer*> tracers)
: tracers_(std::move(tracers)) {
GPR_DEBUG_ASSERT(!tracers_.empty());
DCHECK(!tracers_.empty());
}
~DelegatingClientCallAttemptTracer() override {}
void RecordSendInitialMetadata(
@ -176,7 +178,7 @@ class DelegatingClientCallTracer : public ClientCallTracer {
attempt_tracers.reserve(tracers_.size());
for (auto* tracer : tracers_) {
auto* attempt_tracer = tracer->StartNewAttempt(is_transparent_retry);
GPR_DEBUG_ASSERT(attempt_tracer != nullptr);
DCHECK_NE(attempt_tracer, nullptr);
attempt_tracers.push_back(attempt_tracer);
}
return GetContext<Arena>()->ManagedNew<DelegatingClientCallAttemptTracer>(
@ -328,9 +330,8 @@ void AddClientCallTracerToContext(grpc_call_context_element* call_context,
void AddServerCallTracerToContext(grpc_call_context_element* call_context,
ServerCallTracer* tracer) {
GPR_DEBUG_ASSERT(
call_context[GRPC_CONTEXT_CALL_TRACER].value ==
call_context[GRPC_CONTEXT_CALL_TRACER_ANNOTATION_INTERFACE].value);
DCHECK(call_context[GRPC_CONTEXT_CALL_TRACER].value ==
call_context[GRPC_CONTEXT_CALL_TRACER_ANNOTATION_INTERFACE].value);
if (call_context[GRPC_CONTEXT_CALL_TRACER_ANNOTATION_INTERFACE].value ==
nullptr) {
// This is the first call tracer. Set it directly.

@ -28,6 +28,7 @@
#include <string>
#include <vector>
#include "absl/log/check.h"
#include "absl/strings/match.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
@ -427,7 +428,7 @@ grpc_channel_args* grpc_channel_args_copy_and_add_and_remove(
for (size_t i = 0; i < num_to_add; ++i) {
dst->args[dst_idx++] = copy_arg(&to_add[i]);
}
GPR_ASSERT(dst_idx == dst->num_args);
CHECK(dst_idx == dst->num_args);
return dst;
}
@ -699,7 +700,7 @@ grpc_channel_args_client_channel_creation_mutator g_mutator = nullptr;
void grpc_channel_args_set_client_channel_creation_mutator(
grpc_channel_args_client_channel_creation_mutator cb) {
GPR_DEBUG_ASSERT(g_mutator == nullptr);
DCHECK_EQ(g_mutator, nullptr);
g_mutator = cb;
}
grpc_channel_args_client_channel_creation_mutator

@ -23,6 +23,8 @@
#include <memory>
#include <utility>
#include "absl/log/check.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
@ -67,8 +69,8 @@ size_t grpc_channel_stack_size(const grpc_channel_filter** filters,
sizeof(grpc_channel_element));
size_t i;
GPR_ASSERT((GPR_MAX_ALIGNMENT & (GPR_MAX_ALIGNMENT - 1)) == 0 &&
"GPR_MAX_ALIGNMENT must be a power of two");
CHECK((GPR_MAX_ALIGNMENT & (GPR_MAX_ALIGNMENT - 1)) == 0)
<< "GPR_MAX_ALIGNMENT must be a power of two";
// add the size for each filter
for (i = 0; i < filter_count; i++) {
@ -167,9 +169,9 @@ grpc_error_handle grpc_channel_stack_init(
call_size += GPR_ROUND_UP_TO_ALIGNMENT_SIZE(filters[i]->sizeof_call_data);
}
GPR_ASSERT(user_data > (char*)stack);
GPR_ASSERT((uintptr_t)(user_data - (char*)stack) ==
grpc_channel_stack_size(filters, filter_count));
CHECK(user_data > (char*)stack);
CHECK((uintptr_t)(user_data - (char*)stack) ==
grpc_channel_stack_size(filters, filter_count));
stack->call_stack_size = call_size;
return first_error;

@ -26,6 +26,7 @@
#include <type_traits>
#include <utility>
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/types/optional.h"
@ -224,7 +225,7 @@ static void connected_channel_destroy_call_elem(
static grpc_error_handle connected_channel_init_channel_elem(
grpc_channel_element* elem, grpc_channel_element_args* args) {
channel_data* cd = static_cast<channel_data*>(elem->channel_data);
GPR_ASSERT(args->is_last);
CHECK(args->is_last);
cd->transport = args->channel_args.GetObject<grpc_core::Transport>();
return absl::OkStatus();
}

@ -16,6 +16,8 @@
#include <memory>
#include "absl/log/check.h"
#include <grpc/support/port_platform.h>
#include "src/core/lib/gprpp/crash.h"
@ -46,7 +48,7 @@ GlobalInstrumentsRegistry::RegisterUInt64Counter(
}
}
uint32_t index = instruments.size();
GPR_ASSERT(index < std::numeric_limits<uint32_t>::max());
CHECK_LT(index, std::numeric_limits<uint32_t>::max());
GlobalInstrumentDescriptor descriptor;
descriptor.value_type = ValueType::kUInt64;
descriptor.instrument_type = InstrumentType::kCounter;
@ -78,7 +80,7 @@ GlobalInstrumentsRegistry::RegisterDoubleCounter(
}
}
uint32_t index = instruments.size();
GPR_ASSERT(index < std::numeric_limits<uint32_t>::max());
CHECK_LT(index, std::numeric_limits<uint32_t>::max());
GlobalInstrumentDescriptor descriptor;
descriptor.value_type = ValueType::kDouble;
descriptor.instrument_type = InstrumentType::kCounter;
@ -110,7 +112,7 @@ GlobalInstrumentsRegistry::RegisterUInt64Histogram(
}
}
uint32_t index = instruments.size();
GPR_ASSERT(index < std::numeric_limits<uint32_t>::max());
CHECK_LT(index, std::numeric_limits<uint32_t>::max());
GlobalInstrumentDescriptor descriptor;
descriptor.value_type = ValueType::kUInt64;
descriptor.instrument_type = InstrumentType::kHistogram;
@ -142,7 +144,7 @@ GlobalInstrumentsRegistry::RegisterDoubleHistogram(
}
}
uint32_t index = instruments.size();
GPR_ASSERT(index < std::numeric_limits<uint32_t>::max());
CHECK_LT(index, std::numeric_limits<uint32_t>::max());
GlobalInstrumentDescriptor descriptor;
descriptor.value_type = ValueType::kDouble;
descriptor.instrument_type = InstrumentType::kHistogram;
@ -174,7 +176,7 @@ GlobalInstrumentsRegistry::RegisterCallbackInt64Gauge(
}
}
uint32_t index = instruments.size();
GPR_ASSERT(index < std::numeric_limits<uint32_t>::max());
CHECK_LT(index, std::numeric_limits<uint32_t>::max());
GlobalInstrumentDescriptor descriptor;
descriptor.value_type = ValueType::kInt64;
descriptor.instrument_type = InstrumentType::kCallbackGauge;
@ -206,7 +208,7 @@ GlobalInstrumentsRegistry::RegisterCallbackDoubleGauge(
}
}
uint32_t index = instruments.size();
GPR_ASSERT(index < std::numeric_limits<uint32_t>::max());
CHECK_LT(index, std::numeric_limits<uint32_t>::max());
GlobalInstrumentDescriptor descriptor;
descriptor.value_type = ValueType::kDouble;
descriptor.instrument_type = InstrumentType::kCallbackGauge;

@ -22,6 +22,7 @@
#include "absl/base/attributes.h"
#include "absl/functional/function_ref.h"
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
@ -180,7 +181,7 @@ BaseCallData::CapturedBatch::~CapturedBatch() {
uintptr_t& refcnt = *RefCountField(batch_);
if (refcnt == 0) return; // refcnt==0 ==> cancelled
--refcnt;
GPR_ASSERT(refcnt != 0);
CHECK_NE(refcnt, 0u);
}
BaseCallData::CapturedBatch::CapturedBatch(const CapturedBatch& rhs)
@ -211,7 +212,7 @@ BaseCallData::CapturedBatch& BaseCallData::CapturedBatch::operator=(
void BaseCallData::CapturedBatch::ResumeWith(Flusher* releaser) {
auto* batch = std::exchange(batch_, nullptr);
GPR_ASSERT(batch != nullptr);
CHECK_NE(batch, nullptr);
uintptr_t& refcnt = *RefCountField(batch);
if (refcnt == 0) {
// refcnt==0 ==> cancelled
@ -228,7 +229,7 @@ void BaseCallData::CapturedBatch::ResumeWith(Flusher* releaser) {
void BaseCallData::CapturedBatch::CompleteWith(Flusher* releaser) {
auto* batch = std::exchange(batch_, nullptr);
GPR_ASSERT(batch != nullptr);
CHECK_NE(batch, nullptr);
uintptr_t& refcnt = *RefCountField(batch);
if (refcnt == 0) return; // refcnt==0 ==> cancelled
if (--refcnt == 0) {
@ -239,7 +240,7 @@ void BaseCallData::CapturedBatch::CompleteWith(Flusher* releaser) {
void BaseCallData::CapturedBatch::CancelWith(grpc_error_handle error,
Flusher* releaser) {
auto* batch = std::exchange(batch_, nullptr);
GPR_ASSERT(batch != nullptr);
CHECK_NE(batch, nullptr);
uintptr_t& refcnt = *RefCountField(batch);
if (refcnt == 0) {
// refcnt==0 ==> cancelled
@ -369,7 +370,7 @@ void BaseCallData::SendMessage::GotPipe(T* pipe_end) {
gpr_log(GPR_INFO, "%s SendMessage.GotPipe st=%s", base_->LogTag().c_str(),
StateString(state_));
}
GPR_ASSERT(pipe_end != nullptr);
CHECK_NE(pipe_end, nullptr);
switch (state_) {
case State::kInitial:
state_ = State::kIdle;
@ -518,7 +519,7 @@ void BaseCallData::SendMessage::WakeInsideCombiner(Flusher* flusher,
}
ABSL_FALLTHROUGH_INTENDED;
case State::kPushedToPipe: {
GPR_ASSERT(push_.has_value());
CHECK(push_.has_value());
auto r_push = (*push_)();
if (auto* p = r_push.value_if_ready()) {
if (grpc_trace_channel.enabled()) {
@ -527,12 +528,12 @@ void BaseCallData::SendMessage::WakeInsideCombiner(Flusher* flusher,
base_->LogTag().c_str(), *p ? "true" : "false");
}
// We haven't pulled through yet, so this certainly shouldn't succeed.
GPR_ASSERT(!*p);
CHECK(!*p);
state_ = State::kCancelled;
batch_.CancelWith(absl::CancelledError(), flusher);
break;
}
GPR_ASSERT(next_.has_value());
CHECK(next_.has_value());
auto r_next = (*next_)();
if (auto* p = r_next.value_if_ready()) {
if (grpc_trace_channel.enabled()) {
@ -851,12 +852,12 @@ void BaseCallData::ReceiveMessage::WakeInsideCombiner(Flusher* flusher,
completed_status_, "recv_message");
break;
}
GPR_ASSERT(state_ == State::kPushedToPipe ||
state_ == State::kCompletedWhilePushedToPipe);
CHECK(state_ == State::kPushedToPipe ||
state_ == State::kCompletedWhilePushedToPipe);
ABSL_FALLTHROUGH_INTENDED;
case State::kCompletedWhilePushedToPipe:
case State::kPushedToPipe: {
GPR_ASSERT(push_.has_value());
CHECK(push_.has_value());
auto r_push = (*push_)();
if (auto* p = r_push.value_if_ready()) {
if (grpc_trace_channel.enabled()) {
@ -865,11 +866,11 @@ void BaseCallData::ReceiveMessage::WakeInsideCombiner(Flusher* flusher,
base_->LogTag().c_str(), *p ? "true" : "false");
}
// We haven't pulled through yet, so this certainly shouldn't succeed.
GPR_ASSERT(!*p);
CHECK(!*p);
state_ = State::kCancelled;
break;
}
GPR_ASSERT(next_.has_value());
CHECK(next_.has_value());
auto r_next = (*next_)();
if (auto* p = r_next.value_if_ready()) {
next_.reset();
@ -907,7 +908,7 @@ void BaseCallData::ReceiveMessage::WakeInsideCombiner(Flusher* flusher,
ABSL_FALLTHROUGH_INTENDED;
case State::kCompletedWhilePulledFromPipe:
case State::kPulledFromPipe: {
GPR_ASSERT(push_.has_value());
CHECK(push_.has_value());
if ((*push_)().ready()) {
if (grpc_trace_channel.enabled()) {
gpr_log(GPR_INFO,
@ -1013,7 +1014,7 @@ class ClientCallData::PollContext {
public:
explicit PollContext(ClientCallData* self, Flusher* flusher)
: self_(self), flusher_(flusher) {
GPR_ASSERT(self_->poll_ctx_ == nullptr);
CHECK_EQ(self_->poll_ctx_, nullptr);
self_->poll_ctx_ = this;
scoped_activity_.Init(self_);
@ -1024,12 +1025,12 @@ class ClientCallData::PollContext {
PollContext& operator=(const PollContext&) = delete;
void Run() {
GPR_DEBUG_ASSERT(HasContext<Arena>());
DCHECK(HasContext<Arena>());
if (grpc_trace_channel.enabled()) {
gpr_log(GPR_INFO, "%s ClientCallData.PollContext.Run %s",
self_->LogTag().c_str(), self_->DebugString().c_str());
}
GPR_ASSERT(have_scoped_activity_);
CHECK(have_scoped_activity_);
repoll_ = false;
if (self_->send_message() != nullptr) {
self_->send_message()->WakeInsideCombiner(flusher_, true);
@ -1064,10 +1065,8 @@ class ClientCallData::PollContext {
case RecvInitialMetadata::kCompleteAndGotPipe:
self_->recv_initial_metadata_->state =
RecvInitialMetadata::kCompleteAndPushedToPipe;
GPR_ASSERT(
!self_->recv_initial_metadata_->metadata_push_.has_value());
GPR_ASSERT(
!self_->recv_initial_metadata_->metadata_next_.has_value());
CHECK(!self_->recv_initial_metadata_->metadata_push_.has_value());
CHECK(!self_->recv_initial_metadata_->metadata_next_.has_value());
self_->recv_initial_metadata_->metadata_push_.emplace(
self_->recv_initial_metadata_->server_initial_metadata_publisher
->Push(ServerMetadataHandle(
@ -1078,7 +1077,7 @@ class ClientCallData::PollContext {
self_->server_initial_metadata_pipe()->receiver.Next());
ABSL_FALLTHROUGH_INTENDED;
case RecvInitialMetadata::kCompleteAndPushedToPipe: {
GPR_ASSERT(self_->recv_initial_metadata_->metadata_next_.has_value());
CHECK(self_->recv_initial_metadata_->metadata_next_.has_value());
Poll<NextResult<ServerMetadataHandle>> p =
(*self_->recv_initial_metadata_->metadata_next_)();
if (NextResult<ServerMetadataHandle>* nr = p.value_if_ready()) {
@ -1172,7 +1171,7 @@ class ClientCallData::PollContext {
}
} else {
self_->cancelled_error_ = StatusFromMetadata(*md);
GPR_ASSERT(!self_->cancelled_error_.ok());
CHECK(!self_->cancelled_error_.ok());
if (self_->recv_initial_metadata_ != nullptr) {
switch (self_->recv_initial_metadata_->state) {
case RecvInitialMetadata::kInitial:
@ -1210,7 +1209,7 @@ class ClientCallData::PollContext {
self_->send_initial_metadata_batch_.CancelWith(
self_->cancelled_error_, flusher_);
} else {
GPR_ASSERT(
CHECK(
self_->recv_trailing_state_ == RecvTrailingState::kInitial ||
self_->recv_trailing_state_ == RecvTrailingState::kForwarded);
self_->call_combiner()->Cancel(self_->cancelled_error_);
@ -1314,7 +1313,7 @@ ClientCallData::ClientCallData(grpc_call_element* elem,
ClientCallData::~ClientCallData() {
ScopedActivity scoped_activity(this);
GPR_ASSERT(poll_ctx_ == nullptr);
CHECK_EQ(poll_ctx_, nullptr);
if (recv_initial_metadata_ != nullptr) {
recv_initial_metadata_->~RecvInitialMetadata();
}
@ -1328,7 +1327,7 @@ std::string ClientCallData::DebugTag() const {
// Activity implementation.
void ClientCallData::ForceImmediateRepoll(WakeupMask) {
GPR_ASSERT(poll_ctx_ != nullptr);
CHECK_NE(poll_ctx_, nullptr);
poll_ctx_->Repoll();
}
@ -1399,10 +1398,9 @@ void ClientCallData::StartBatch(grpc_transport_stream_op_batch* b) {
// If this is a cancel stream, cancel anything we have pending and propagate
// the cancellation.
if (batch->cancel_stream) {
GPR_ASSERT(!batch->send_initial_metadata &&
!batch->send_trailing_metadata && !batch->send_message &&
!batch->recv_initial_metadata && !batch->recv_message &&
!batch->recv_trailing_metadata);
CHECK(!batch->send_initial_metadata && !batch->send_trailing_metadata &&
!batch->send_message && !batch->recv_initial_metadata &&
!batch->recv_message && !batch->recv_trailing_metadata);
PollContext poll_ctx(this, &flusher);
Cancel(batch->payload->cancel_stream.cancel_error, &flusher);
poll_ctx.Run();
@ -1473,12 +1471,12 @@ void ClientCallData::StartBatch(grpc_transport_stream_op_batch* b) {
batch.CancelWith(cancelled_error_, &flusher);
} else {
// Otherwise, we should not have seen a send_initial_metadata op yet.
GPR_ASSERT(send_initial_state_ == SendInitialState::kInitial);
CHECK(send_initial_state_ == SendInitialState::kInitial);
// Mark ourselves as queued.
send_initial_state_ = SendInitialState::kQueued;
if (batch->recv_trailing_metadata) {
// If there's a recv_trailing_metadata op, we queue that too.
GPR_ASSERT(recv_trailing_state_ == RecvTrailingState::kInitial);
CHECK(recv_trailing_state_ == RecvTrailingState::kInitial);
recv_trailing_state_ = RecvTrailingState::kQueued;
}
// This is the queuing!
@ -1493,7 +1491,7 @@ void ClientCallData::StartBatch(grpc_transport_stream_op_batch* b) {
if (recv_trailing_state_ == RecvTrailingState::kCancelled) {
batch.CancelWith(cancelled_error_, &flusher);
} else {
GPR_ASSERT(recv_trailing_state_ == RecvTrailingState::kInitial);
CHECK(recv_trailing_state_ == RecvTrailingState::kInitial);
recv_trailing_state_ = RecvTrailingState::kForwarded;
HookRecvTrailingMetadata(batch);
}
@ -1571,7 +1569,7 @@ void ClientCallData::Cancel(grpc_error_handle error, Flusher* flusher) {
// Begin running the promise - which will ultimately take some initial
// metadata and return some trailing metadata.
void ClientCallData::StartPromise(Flusher* flusher) {
GPR_ASSERT(send_initial_state_ == SendInitialState::kQueued);
CHECK(send_initial_state_ == SendInitialState::kQueued);
ChannelFilter* filter = promise_filter_detail::ChannelFilterFromElem(elem());
// Construct the promise.
@ -1684,8 +1682,8 @@ ArenaPromise<ServerMetadataHandle> ClientCallData::MakeNextPromise(
gpr_log(GPR_INFO, "%s ClientCallData.MakeNextPromise %s", LogTag().c_str(),
DebugString().c_str());
}
GPR_ASSERT(poll_ctx_ != nullptr);
GPR_ASSERT(send_initial_state_ == SendInitialState::kQueued);
CHECK_NE(poll_ctx_, nullptr);
CHECK(send_initial_state_ == SendInitialState::kQueued);
send_initial_metadata_batch_->payload->send_initial_metadata
.send_initial_metadata = call_args.client_initial_metadata.get();
if (recv_initial_metadata_ != nullptr) {
@ -1693,7 +1691,7 @@ ArenaPromise<ServerMetadataHandle> ClientCallData::MakeNextPromise(
// It might be the one we passed in - in which case we know this filter
// only wants to examine the metadata, or it might be a new instance, in
// which case we know the filter wants to mutate.
GPR_ASSERT(call_args.server_initial_metadata != nullptr);
CHECK_NE(call_args.server_initial_metadata, nullptr);
recv_initial_metadata_->server_initial_metadata_publisher =
call_args.server_initial_metadata;
switch (recv_initial_metadata_->state) {
@ -1722,17 +1720,17 @@ ArenaPromise<ServerMetadataHandle> ClientCallData::MakeNextPromise(
recv_initial_metadata_->state))); // unreachable
}
} else {
GPR_ASSERT(call_args.server_initial_metadata == nullptr);
CHECK_EQ(call_args.server_initial_metadata, nullptr);
}
if (send_message() != nullptr) {
send_message()->GotPipe(call_args.client_to_server_messages);
} else {
GPR_ASSERT(call_args.client_to_server_messages == nullptr);
CHECK_EQ(call_args.client_to_server_messages, nullptr);
}
if (receive_message() != nullptr) {
receive_message()->GotPipe(call_args.server_to_client_messages);
} else {
GPR_ASSERT(call_args.server_to_client_messages == nullptr);
CHECK_EQ(call_args.server_to_client_messages, nullptr);
}
return ArenaPromise<ServerMetadataHandle>(
[this]() { return PollTrailingMetadata(); });
@ -1747,10 +1745,10 @@ Poll<ServerMetadataHandle> ClientCallData::PollTrailingMetadata() {
gpr_log(GPR_INFO, "%s ClientCallData.PollTrailingMetadata %s",
LogTag().c_str(), DebugString().c_str());
}
GPR_ASSERT(poll_ctx_ != nullptr);
CHECK_NE(poll_ctx_, nullptr);
if (send_initial_state_ == SendInitialState::kQueued) {
// First poll: pass the send_initial_metadata op down the stack.
GPR_ASSERT(send_initial_metadata_batch_.is_captured());
CHECK(send_initial_metadata_batch_.is_captured());
send_initial_state_ = SendInitialState::kForwarded;
if (recv_trailing_state_ == RecvTrailingState::kQueued) {
// (and the recv_trailing_metadata op if it's part of the queuing)
@ -1820,7 +1818,7 @@ void ClientCallData::RecvTrailingMetadataReady(grpc_error_handle error) {
SetStatusFromError(recv_trailing_metadata_, error);
}
// Record that we've got the callback.
GPR_ASSERT(recv_trailing_state_ == RecvTrailingState::kForwarded);
CHECK(recv_trailing_state_ == RecvTrailingState::kForwarded);
recv_trailing_state_ = RecvTrailingState::kComplete;
if (receive_message() != nullptr) {
receive_message()->Done(*recv_trailing_metadata_, &flusher);
@ -1908,7 +1906,7 @@ class ServerCallData::PollContext {
created_.line(), "; Old: ", self_->poll_ctx_->created_.file(), ":",
self_->poll_ctx_->created_.line()));
}
GPR_ASSERT(self_->poll_ctx_ == nullptr);
CHECK_EQ(self_->poll_ctx_, nullptr);
self_->poll_ctx_ = this;
scoped_activity_.Init(self_);
have_scoped_activity_ = true;
@ -2016,7 +2014,7 @@ ServerCallData::~ServerCallData() {
if (send_initial_metadata_ != nullptr) {
send_initial_metadata_->~SendInitialMetadata();
}
GPR_ASSERT(poll_ctx_ == nullptr);
CHECK_EQ(poll_ctx_, nullptr);
}
std::string ServerCallData::DebugTag() const {
@ -2025,7 +2023,7 @@ std::string ServerCallData::DebugTag() const {
// Activity implementation.
void ServerCallData::ForceImmediateRepoll(WakeupMask) {
GPR_ASSERT(poll_ctx_ != nullptr);
CHECK_NE(poll_ctx_, nullptr);
poll_ctx_->Repoll();
}
@ -2045,10 +2043,9 @@ void ServerCallData::StartBatch(grpc_transport_stream_op_batch* b) {
// If this is a cancel stream, cancel anything we have pending and
// propagate the cancellation.
if (batch->cancel_stream) {
GPR_ASSERT(!batch->send_initial_metadata &&
!batch->send_trailing_metadata && !batch->send_message &&
!batch->recv_initial_metadata && !batch->recv_message &&
!batch->recv_trailing_metadata);
CHECK(!batch->send_initial_metadata && !batch->send_trailing_metadata &&
!batch->send_message && !batch->recv_initial_metadata &&
!batch->recv_message && !batch->recv_trailing_metadata);
PollContext poll_ctx(this, &flusher);
Completed(batch->payload->cancel_stream.cancel_error,
batch->payload->cancel_stream.tarpit, &flusher);
@ -2063,11 +2060,11 @@ void ServerCallData::StartBatch(grpc_transport_stream_op_batch* b) {
// recv_initial_metadata: we hook the response of this so we can start the
// promise at an appropriate time.
if (batch->recv_initial_metadata) {
GPR_ASSERT(!batch->send_initial_metadata &&
!batch->send_trailing_metadata && !batch->send_message &&
!batch->recv_message && !batch->recv_trailing_metadata);
CHECK(!batch->send_initial_metadata && !batch->send_trailing_metadata &&
!batch->send_message && !batch->recv_message &&
!batch->recv_trailing_metadata);
// Otherwise, we should not have seen a send_initial_metadata op yet.
GPR_ASSERT(recv_initial_state_ == RecvInitialState::kInitial);
CHECK(recv_initial_state_ == RecvInitialState::kInitial);
// Hook the callback so we know when to start the promise.
recv_initial_metadata_ =
batch->payload->recv_initial_metadata.recv_initial_metadata;
@ -2249,14 +2246,13 @@ void ServerCallData::Completed(grpc_error_handle error,
// - return a wrapper around PollTrailingMetadata as the promise.
ArenaPromise<ServerMetadataHandle> ServerCallData::MakeNextPromise(
CallArgs call_args) {
GPR_ASSERT(recv_initial_state_ == RecvInitialState::kComplete);
GPR_ASSERT(std::move(call_args.client_initial_metadata).get() ==
recv_initial_metadata_);
CHECK(recv_initial_state_ == RecvInitialState::kComplete);
CHECK(std::move(call_args.client_initial_metadata).get() ==
recv_initial_metadata_);
forward_recv_initial_metadata_callback_ = true;
if (send_initial_metadata_ != nullptr) {
GPR_ASSERT(send_initial_metadata_->server_initial_metadata_publisher ==
nullptr);
GPR_ASSERT(call_args.server_initial_metadata != nullptr);
CHECK(send_initial_metadata_->server_initial_metadata_publisher == nullptr);
CHECK_NE(call_args.server_initial_metadata, nullptr);
send_initial_metadata_->server_initial_metadata_publisher =
call_args.server_initial_metadata;
switch (send_initial_metadata_->state) {
@ -2279,17 +2275,17 @@ ArenaPromise<ServerMetadataHandle> ServerCallData::MakeNextPromise(
break;
}
} else {
GPR_ASSERT(call_args.server_initial_metadata == nullptr);
CHECK_EQ(call_args.server_initial_metadata, nullptr);
}
if (send_message() != nullptr) {
send_message()->GotPipe(call_args.server_to_client_messages);
} else {
GPR_ASSERT(call_args.server_to_client_messages == nullptr);
CHECK_EQ(call_args.server_to_client_messages, nullptr);
}
if (receive_message() != nullptr) {
receive_message()->GotPipe(call_args.client_to_server_messages);
} else {
GPR_ASSERT(call_args.client_to_server_messages == nullptr);
CHECK_EQ(call_args.client_to_server_messages, nullptr);
}
return ArenaPromise<ServerMetadataHandle>(
[this]() { return PollTrailingMetadata(); });
@ -2354,7 +2350,7 @@ void ServerCallData::RecvInitialMetadataReady(grpc_error_handle error) {
gpr_log(GPR_INFO, "%s: RecvInitialMetadataReady %s", LogTag().c_str(),
error.ToString().c_str());
}
GPR_ASSERT(recv_initial_state_ == RecvInitialState::kForwarded);
CHECK(recv_initial_state_ == RecvInitialState::kForwarded);
// If there was an error we just propagate that through
if (!error.ok()) {
recv_initial_state_ = RecvInitialState::kResponded;
@ -2425,8 +2421,8 @@ void ServerCallData::WakeInsideCombiner(Flusher* flusher) {
SendInitialMetadata::kQueuedAndGotPipe) {
send_initial_metadata_->state =
SendInitialMetadata::kQueuedAndPushedToPipe;
GPR_ASSERT(!send_initial_metadata_->metadata_push_.has_value());
GPR_ASSERT(!send_initial_metadata_->metadata_next_.has_value());
CHECK(!send_initial_metadata_->metadata_push_.has_value());
CHECK(!send_initial_metadata_->metadata_next_.has_value());
send_initial_metadata_->metadata_push_.emplace(
send_initial_metadata_->server_initial_metadata_publisher->Push(
ServerMetadataHandle(
@ -2508,7 +2504,7 @@ void ServerCallData::WakeInsideCombiner(Flusher* flusher) {
if (send_initial_metadata_ != nullptr &&
send_initial_metadata_->state ==
SendInitialMetadata::kQueuedAndPushedToPipe) {
GPR_ASSERT(send_initial_metadata_->metadata_next_.has_value());
CHECK(send_initial_metadata_->metadata_next_.has_value());
auto p = (*send_initial_metadata_->metadata_next_)();
if (grpc_trace_channel.enabled()) {
gpr_log(GPR_INFO,
@ -2557,7 +2553,7 @@ void ServerCallData::WakeInsideCombiner(Flusher* flusher) {
StateString(send_trailing_state_))); // unreachable
break;
case SendTrailingState::kInitial: {
GPR_ASSERT(*md->get_pointer(GrpcStatusMetadata()) != GRPC_STATUS_OK);
CHECK(*md->get_pointer(GrpcStatusMetadata()) != GRPC_STATUS_OK);
Completed(StatusFromMetadata(*md), md->get(GrpcTarPit()).has_value(),
flusher);
} break;

@ -31,6 +31,7 @@
#include "absl/container/inlined_vector.h"
#include "absl/functional/function_ref.h"
#include "absl/log/check.h"
#include "absl/meta/type_traits.h"
#include "absl/status/status.h"
#include "absl/strings/string_view.h"
@ -352,7 +353,7 @@ auto MapResult(const NoInterceptor*, Promise x, void*) {
template <typename Promise, typename Derived>
auto MapResult(absl::Status (Derived::Call::*fn)(ServerMetadata&), Promise x,
FilterCallData<Derived>* call_data) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerTrailingMetadata);
DCHECK(fn == &Derived::Call::OnServerTrailingMetadata);
return Map(std::move(x), [call_data](ServerMetadataHandle md) {
auto status = call_data->call.OnServerTrailingMetadata(*md);
if (!status.ok()) return ServerMetadataFromStatus(status);
@ -363,7 +364,7 @@ auto MapResult(absl::Status (Derived::Call::*fn)(ServerMetadata&), Promise x,
template <typename Promise, typename Derived>
auto MapResult(void (Derived::Call::*fn)(ServerMetadata&), Promise x,
FilterCallData<Derived>* call_data) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerTrailingMetadata);
DCHECK(fn == &Derived::Call::OnServerTrailingMetadata);
return Map(std::move(x), [call_data](ServerMetadataHandle md) {
call_data->call.OnServerTrailingMetadata(*md);
return md;
@ -373,7 +374,7 @@ auto MapResult(void (Derived::Call::*fn)(ServerMetadata&), Promise x,
template <typename Promise, typename Derived>
auto MapResult(void (Derived::Call::*fn)(ServerMetadata&, Derived*), Promise x,
FilterCallData<Derived>* call_data) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerTrailingMetadata);
DCHECK(fn == &Derived::Call::OnServerTrailingMetadata);
return Map(std::move(x), [call_data](ServerMetadataHandle md) {
call_data->call.OnServerTrailingMetadata(*md, call_data->channel);
return md;
@ -486,7 +487,7 @@ template <typename Interceptor, typename Derived>
auto RunCall(Interceptor interceptor, CallArgs call_args,
NextPromiseFactory next_promise_factory,
FilterCallData<Derived>* call_data) {
GPR_DEBUG_ASSERT(interceptor == &Derived::Call::OnClientInitialMetadata);
DCHECK(interceptor == &Derived::Call::OnClientInitialMetadata);
return RunCallImpl<Interceptor, Derived>::Run(
std::move(call_args), std::move(next_promise_factory), call_data);
}
@ -498,7 +499,7 @@ template <typename Derived>
inline void InterceptClientToServerMessage(
ServerMetadataHandle (Derived::Call::*fn)(const Message&),
FilterCallData<Derived>* call_data, const CallArgs& call_args) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientToServerMessage);
DCHECK(fn == &Derived::Call::OnClientToServerMessage);
call_args.client_to_server_messages->InterceptAndMap(
[call_data](MessageHandle msg) -> absl::optional<MessageHandle> {
auto return_md = call_data->call.OnClientToServerMessage(*msg);
@ -513,7 +514,7 @@ template <typename Derived>
inline void InterceptClientToServerMessage(
ServerMetadataHandle (Derived::Call::*fn)(const Message&, Derived*),
FilterCallData<Derived>* call_data, const CallArgs& call_args) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientToServerMessage);
DCHECK(fn == &Derived::Call::OnClientToServerMessage);
call_args.client_to_server_messages->InterceptAndMap(
[call_data](MessageHandle msg) -> absl::optional<MessageHandle> {
auto return_md =
@ -529,7 +530,7 @@ template <typename Derived>
inline void InterceptClientToServerMessage(
MessageHandle (Derived::Call::*fn)(MessageHandle, Derived*),
FilterCallData<Derived>* call_data, const CallArgs& call_args) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientToServerMessage);
DCHECK(fn == &Derived::Call::OnClientToServerMessage);
call_args.client_to_server_messages->InterceptAndMap(
[call_data](MessageHandle msg) -> absl::optional<MessageHandle> {
return call_data->call.OnClientToServerMessage(std::move(msg),
@ -541,7 +542,7 @@ template <typename Derived>
inline void InterceptClientToServerMessage(
absl::StatusOr<MessageHandle> (Derived::Call::*fn)(MessageHandle, Derived*),
FilterCallData<Derived>* call_data, const CallArgs& call_args) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientToServerMessage);
DCHECK(fn == &Derived::Call::OnClientToServerMessage);
call_args.client_to_server_messages->InterceptAndMap(
[call_data](MessageHandle msg) -> absl::optional<MessageHandle> {
auto r = call_data->call.OnClientToServerMessage(std::move(msg),
@ -560,7 +561,7 @@ template <typename Derived>
inline void InterceptClientToServerMessage(
ServerMetadataHandle (Derived::Call::*fn)(const Message&),
typename Derived::Call* call, Derived*, PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientToServerMessage);
DCHECK(fn == &Derived::Call::OnClientToServerMessage);
call_spine->client_to_server_messages().receiver.InterceptAndMap(
[call, call_spine](MessageHandle msg) -> absl::optional<MessageHandle> {
auto return_md = call->OnClientToServerMessage(*msg);
@ -575,7 +576,7 @@ inline void InterceptClientToServerMessage(
ServerMetadataHandle (Derived::Call::*fn)(const Message&, Derived*),
typename Derived::Call* call, Derived* channel,
PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientToServerMessage);
DCHECK(fn == &Derived::Call::OnClientToServerMessage);
call_spine->client_to_server_messages().receiver.InterceptAndMap(
[call, call_spine,
channel](MessageHandle msg) -> absl::optional<MessageHandle> {
@ -591,7 +592,7 @@ inline void InterceptClientToServerMessage(
MessageHandle (Derived::Call::*fn)(MessageHandle, Derived*),
typename Derived::Call* call, Derived* channel,
PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientToServerMessage);
DCHECK(fn == &Derived::Call::OnClientToServerMessage);
call_spine->client_to_server_messages().receiver.InterceptAndMap(
[call, channel](MessageHandle msg) {
return call->OnClientToServerMessage(std::move(msg), channel);
@ -603,7 +604,7 @@ inline void InterceptClientToServerMessage(
absl::StatusOr<MessageHandle> (Derived::Call::*fn)(MessageHandle, Derived*),
typename Derived::Call* call, Derived* channel,
PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientToServerMessage);
DCHECK(fn == &Derived::Call::OnClientToServerMessage);
call_spine->client_to_server_messages().receiver.InterceptAndMap(
[call, call_spine,
channel](MessageHandle msg) -> absl::optional<MessageHandle> {
@ -622,7 +623,7 @@ template <typename Derived>
inline void InterceptClientInitialMetadata(
void (Derived::Call::*fn)(ClientMetadata& md), typename Derived::Call* call,
Derived*, PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientInitialMetadata);
DCHECK(fn == &Derived::Call::OnClientInitialMetadata);
call_spine->client_initial_metadata().receiver.InterceptAndMap(
[call](ClientMetadataHandle md) {
call->OnClientInitialMetadata(*md);
@ -635,7 +636,7 @@ inline void InterceptClientInitialMetadata(
void (Derived::Call::*fn)(ClientMetadata& md, Derived* channel),
typename Derived::Call* call, Derived* channel,
PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientInitialMetadata);
DCHECK(fn == &Derived::Call::OnClientInitialMetadata);
call_spine->client_initial_metadata().receiver.InterceptAndMap(
[call, channel](ClientMetadataHandle md) {
call->OnClientInitialMetadata(*md, channel);
@ -647,7 +648,7 @@ template <typename Derived>
inline void InterceptClientInitialMetadata(
ServerMetadataHandle (Derived::Call::*fn)(ClientMetadata& md),
typename Derived::Call* call, Derived*, PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientInitialMetadata);
DCHECK(fn == &Derived::Call::OnClientInitialMetadata);
call_spine->client_initial_metadata().receiver.InterceptAndMap(
[call_spine,
call](ClientMetadataHandle md) -> absl::optional<ClientMetadataHandle> {
@ -664,7 +665,7 @@ inline void InterceptClientInitialMetadata(
Derived* channel),
typename Derived::Call* call, Derived* channel,
PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientInitialMetadata);
DCHECK(fn == &Derived::Call::OnClientInitialMetadata);
call_spine->client_initial_metadata().receiver.InterceptAndMap(
[call_spine, call, channel](
ClientMetadataHandle md) -> absl::optional<ClientMetadataHandle> {
@ -679,7 +680,7 @@ template <typename Derived>
inline void InterceptClientInitialMetadata(
absl::Status (Derived::Call::*fn)(ClientMetadata& md),
typename Derived::Call* call, Derived*, PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientInitialMetadata);
DCHECK(fn == &Derived::Call::OnClientInitialMetadata);
call_spine->client_initial_metadata().receiver.InterceptAndMap(
[call_spine,
call](ClientMetadataHandle md) -> absl::optional<ClientMetadataHandle> {
@ -696,7 +697,7 @@ inline void InterceptClientInitialMetadata(
absl::Status (Derived::Call::*fn)(ClientMetadata& md, Derived* channel),
typename Derived::Call* call, Derived* channel,
PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnClientInitialMetadata);
DCHECK(fn == &Derived::Call::OnClientInitialMetadata);
call_spine->client_initial_metadata().receiver.InterceptAndMap(
[call_spine, call, channel](
ClientMetadataHandle md) -> absl::optional<ClientMetadataHandle> {
@ -717,7 +718,7 @@ InterceptClientInitialMetadata(Promise (Derived::Call::*promise_factory)(
ClientMetadata& md, Derived* channel),
typename Derived::Call* call, Derived* channel,
PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(promise_factory == &Derived::Call::OnClientInitialMetadata);
DCHECK(promise_factory == &Derived::Call::OnClientInitialMetadata);
call_spine->client_initial_metadata().receiver.InterceptAndMap(
[call, call_spine, channel](ClientMetadataHandle md) {
ClientMetadata& md_ref = *md;
@ -741,7 +742,7 @@ template <typename Derived>
inline void InterceptServerInitialMetadata(
void (Derived::Call::*fn)(ServerMetadata&),
FilterCallData<Derived>* call_data, const CallArgs& call_args) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerInitialMetadata);
DCHECK(fn == &Derived::Call::OnServerInitialMetadata);
call_args.server_initial_metadata->InterceptAndMap(
[call_data](ServerMetadataHandle md) {
call_data->call.OnServerInitialMetadata(*md);
@ -753,7 +754,7 @@ template <typename Derived>
inline void InterceptServerInitialMetadata(
absl::Status (Derived::Call::*fn)(ServerMetadata&),
FilterCallData<Derived>* call_data, const CallArgs& call_args) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerInitialMetadata);
DCHECK(fn == &Derived::Call::OnServerInitialMetadata);
call_args.server_initial_metadata->InterceptAndMap(
[call_data](
ServerMetadataHandle md) -> absl::optional<ServerMetadataHandle> {
@ -770,7 +771,7 @@ template <typename Derived>
inline void InterceptServerInitialMetadata(
void (Derived::Call::*fn)(ServerMetadata&, Derived*),
FilterCallData<Derived>* call_data, const CallArgs& call_args) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerInitialMetadata);
DCHECK(fn == &Derived::Call::OnServerInitialMetadata);
call_args.server_initial_metadata->InterceptAndMap(
[call_data](ServerMetadataHandle md) {
call_data->call.OnServerInitialMetadata(*md, call_data->channel);
@ -782,7 +783,7 @@ template <typename Derived>
inline void InterceptServerInitialMetadata(
absl::Status (Derived::Call::*fn)(ServerMetadata&, Derived*),
FilterCallData<Derived>* call_data, const CallArgs& call_args) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerInitialMetadata);
DCHECK(fn == &Derived::Call::OnServerInitialMetadata);
call_args.server_initial_metadata->InterceptAndMap(
[call_data](
ServerMetadataHandle md) -> absl::optional<ServerMetadataHandle> {
@ -803,7 +804,7 @@ template <typename Derived>
inline void InterceptServerInitialMetadata(
void (Derived::Call::*fn)(ServerMetadata&), typename Derived::Call* call,
Derived*, PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerInitialMetadata);
DCHECK(fn == &Derived::Call::OnServerInitialMetadata);
call_spine->server_initial_metadata().sender.InterceptAndMap(
[call](ServerMetadataHandle md) {
call->OnServerInitialMetadata(*md);
@ -815,7 +816,7 @@ template <typename Derived>
inline void InterceptServerInitialMetadata(
absl::Status (Derived::Call::*fn)(ServerMetadata&),
typename Derived::Call* call, Derived*, PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerInitialMetadata);
DCHECK(fn == &Derived::Call::OnServerInitialMetadata);
call_spine->server_initial_metadata().sender.InterceptAndMap(
[call, call_spine](
ServerMetadataHandle md) -> absl::optional<ServerMetadataHandle> {
@ -832,7 +833,7 @@ inline void InterceptServerInitialMetadata(
void (Derived::Call::*fn)(ServerMetadata&, Derived*),
typename Derived::Call* call, Derived* channel,
PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerInitialMetadata);
DCHECK(fn == &Derived::Call::OnServerInitialMetadata);
call_spine->server_initial_metadata().sender.InterceptAndMap(
[call, channel](ServerMetadataHandle md) {
call->OnServerInitialMetadata(*md, channel);
@ -845,7 +846,7 @@ inline void InterceptServerInitialMetadata(
absl::Status (Derived::Call::*fn)(ServerMetadata&, Derived*),
typename Derived::Call* call, Derived* channel,
PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerInitialMetadata);
DCHECK(fn == &Derived::Call::OnServerInitialMetadata);
call_spine->server_initial_metadata().sender.InterceptAndMap(
[call, call_spine, channel](
ServerMetadataHandle md) -> absl::optional<ServerMetadataHandle> {
@ -864,7 +865,7 @@ template <typename Derived>
inline void InterceptServerToClientMessage(
ServerMetadataHandle (Derived::Call::*fn)(const Message&),
FilterCallData<Derived>* call_data, const CallArgs& call_args) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerToClientMessage);
DCHECK(fn == &Derived::Call::OnServerToClientMessage);
call_args.server_to_client_messages->InterceptAndMap(
[call_data](MessageHandle msg) -> absl::optional<MessageHandle> {
auto return_md = call_data->call.OnServerToClientMessage(*msg);
@ -879,7 +880,7 @@ template <typename Derived>
inline void InterceptServerToClientMessage(
ServerMetadataHandle (Derived::Call::*fn)(const Message&, Derived*),
FilterCallData<Derived>* call_data, const CallArgs& call_args) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerToClientMessage);
DCHECK(fn == &Derived::Call::OnServerToClientMessage);
call_args.server_to_client_messages->InterceptAndMap(
[call_data](MessageHandle msg) -> absl::optional<MessageHandle> {
auto return_md =
@ -895,7 +896,7 @@ template <typename Derived>
inline void InterceptServerToClientMessage(
MessageHandle (Derived::Call::*fn)(MessageHandle, Derived*),
FilterCallData<Derived>* call_data, const CallArgs& call_args) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerToClientMessage);
DCHECK(fn == &Derived::Call::OnServerToClientMessage);
call_args.server_to_client_messages->InterceptAndMap(
[call_data](MessageHandle msg) -> absl::optional<MessageHandle> {
return call_data->call.OnServerToClientMessage(std::move(msg),
@ -907,7 +908,7 @@ template <typename Derived>
inline void InterceptServerToClientMessage(
absl::StatusOr<MessageHandle> (Derived::Call::*fn)(MessageHandle, Derived*),
FilterCallData<Derived>* call_data, const CallArgs& call_args) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerToClientMessage);
DCHECK(fn == &Derived::Call::OnServerToClientMessage);
call_args.server_to_client_messages->InterceptAndMap(
[call_data](MessageHandle msg) -> absl::optional<MessageHandle> {
auto r = call_data->call.OnServerToClientMessage(std::move(msg),
@ -926,7 +927,7 @@ template <typename Derived>
inline void InterceptServerToClientMessage(
ServerMetadataHandle (Derived::Call::*fn)(const Message&),
typename Derived::Call* call, Derived*, PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerToClientMessage);
DCHECK(fn == &Derived::Call::OnServerToClientMessage);
call_spine->server_to_client_messages().sender.InterceptAndMap(
[call, call_spine](MessageHandle msg) -> absl::optional<MessageHandle> {
auto return_md = call->OnServerToClientMessage(*msg);
@ -941,7 +942,7 @@ inline void InterceptServerToClientMessage(
ServerMetadataHandle (Derived::Call::*fn)(const Message&, Derived*),
typename Derived::Call* call, Derived* channel,
PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerToClientMessage);
DCHECK(fn == &Derived::Call::OnServerToClientMessage);
call_spine->server_to_client_messages().sender.InterceptAndMap(
[call, call_spine,
channel](MessageHandle msg) -> absl::optional<MessageHandle> {
@ -957,7 +958,7 @@ inline void InterceptServerToClientMessage(
MessageHandle (Derived::Call::*fn)(MessageHandle, Derived*),
typename Derived::Call* call, Derived* channel,
PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerToClientMessage);
DCHECK(fn == &Derived::Call::OnServerToClientMessage);
call_spine->server_to_client_messages().sender.InterceptAndMap(
[call, channel](MessageHandle msg) {
return call->OnServerToClientMessage(std::move(msg), channel);
@ -969,7 +970,7 @@ inline void InterceptServerToClientMessage(
absl::StatusOr<MessageHandle> (Derived::Call::*fn)(MessageHandle, Derived*),
typename Derived::Call* call, Derived* channel,
PipeBasedCallSpine* call_spine) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnServerToClientMessage);
DCHECK(fn == &Derived::Call::OnServerToClientMessage);
call_spine->server_to_client_messages().sender.InterceptAndMap(
[call, call_spine,
channel](MessageHandle msg) -> absl::optional<MessageHandle> {
@ -1012,7 +1013,7 @@ inline void InterceptFinalize(const NoInterceptor*, void*, void*) {}
template <class Call>
inline void InterceptFinalize(void (Call::*fn)(const grpc_call_final_info*),
void*, Call* call) {
GPR_DEBUG_ASSERT(fn == &Call::OnFinalize);
DCHECK(fn == &Call::OnFinalize);
GetContext<CallFinalization>()->Add(
[call](const grpc_call_final_info* final_info) {
call->OnFinalize(final_info);
@ -1023,7 +1024,7 @@ template <class Derived>
inline void InterceptFinalize(
void (Derived::Call::*fn)(const grpc_call_final_info*, Derived*),
Derived* channel, typename Derived::Call* call) {
GPR_DEBUG_ASSERT(fn == &Derived::Call::OnFinalize);
DCHECK(fn == &Derived::Call::OnFinalize);
GetContext<CallFinalization>()->Add(
[call, channel](const grpc_call_final_info* final_info) {
call->OnFinalize(final_info, channel);
@ -1212,8 +1213,7 @@ class BaseCallData : public Activity, private Wakeable {
~BaseCallData() override;
void set_pollent(grpc_polling_entity* pollent) {
GPR_ASSERT(nullptr ==
pollent_.exchange(pollent, std::memory_order_release));
CHECK(nullptr == pollent_.exchange(pollent, std::memory_order_release));
}
// Activity implementation (partial).
@ -1259,7 +1259,7 @@ class BaseCallData : public Activity, private Wakeable {
~Flusher();
void Resume(grpc_transport_stream_op_batch* batch) {
GPR_ASSERT(!call_->is_last());
CHECK(!call_->is_last());
if (batch->HasOp()) {
release_.push_back(batch);
} else if (batch->on_complete != nullptr) {
@ -1338,7 +1338,7 @@ class BaseCallData : public Activity, private Wakeable {
PipeSender<MessageHandle>* original_sender() override { abort(); }
void GotPipe(PipeReceiver<MessageHandle>* receiver) override {
GPR_ASSERT(receiver_ == nullptr);
CHECK_EQ(receiver_, nullptr);
receiver_ = receiver;
}
@ -1346,7 +1346,7 @@ class BaseCallData : public Activity, private Wakeable {
PipeSender<MessageHandle>* Push() override { return &pipe_.sender; }
PipeReceiver<MessageHandle>* Pull() override {
GPR_ASSERT(receiver_ != nullptr);
CHECK_NE(receiver_, nullptr);
return receiver_;
}
@ -1367,12 +1367,12 @@ class BaseCallData : public Activity, private Wakeable {
void GotPipe(PipeReceiver<MessageHandle>*) override { abort(); }
void GotPipe(PipeSender<MessageHandle>* sender) override {
GPR_ASSERT(sender_ == nullptr);
CHECK_EQ(sender_, nullptr);
sender_ = sender;
}
PipeSender<MessageHandle>* Push() override {
GPR_ASSERT(sender_ != nullptr);
CHECK_NE(sender_, nullptr);
return sender_;
}
PipeReceiver<MessageHandle>* Pull() override { return &pipe_.receiver; }
@ -1890,7 +1890,7 @@ struct CallDataFilterWithFlagsMethods {
if ((kFlags & kFilterIsLast) != 0) {
ExecCtx::Run(DEBUG_LOCATION, then_schedule_closure, absl::OkStatus());
} else {
GPR_ASSERT(then_schedule_closure == nullptr);
CHECK_EQ(then_schedule_closure, nullptr);
}
}
};
@ -1927,7 +1927,7 @@ template <typename F, uint8_t kFlags>
struct ChannelFilterWithFlagsMethods {
static absl::Status InitChannelElem(grpc_channel_element* elem,
grpc_channel_element_args* args) {
GPR_ASSERT(args->is_last == ((kFlags & kFilterIsLast) != 0));
CHECK(args->is_last == ((kFlags & kFilterIsLast) != 0));
auto status = F::Create(args->channel_args,
ChannelFilter::Args(args->channel_stack, elem));
if (!status.ok()) {

@ -23,6 +23,7 @@
#include <string>
#include "absl/container/inlined_vector.h"
#include "absl/log/check.h"
#include "absl/strings/ascii.h"
#include "absl/strings/str_format.h"
#include "absl/strings/str_split.h"
@ -120,7 +121,7 @@ CompressionAlgorithmSet::CompressionAlgorithmForLevel(
return GRPC_COMPRESS_NONE;
}
GPR_ASSERT(level > 0);
CHECK_GT(level, 0);
// Establish a "ranking" or compression algorithms in increasing order of
// compression.

@ -23,6 +23,8 @@
#include <zconf.h>
#include <zlib.h>
#include "absl/log/check.h"
#include <grpc/slice_buffer.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@ -41,20 +43,20 @@ static int zlib_body(z_stream* zs, grpc_slice_buffer* input,
grpc_slice outbuf = GRPC_SLICE_MALLOC(OUTPUT_BLOCK_SIZE);
const uInt uint_max = ~uInt{0};
GPR_ASSERT(GRPC_SLICE_LENGTH(outbuf) <= uint_max);
CHECK(GRPC_SLICE_LENGTH(outbuf) <= uint_max);
zs->avail_out = static_cast<uInt> GRPC_SLICE_LENGTH(outbuf);
zs->next_out = GRPC_SLICE_START_PTR(outbuf);
flush = Z_NO_FLUSH;
for (i = 0; i < input->count; i++) {
if (i == input->count - 1) flush = Z_FINISH;
GPR_ASSERT(GRPC_SLICE_LENGTH(input->slices[i]) <= uint_max);
CHECK(GRPC_SLICE_LENGTH(input->slices[i]) <= uint_max);
zs->avail_in = static_cast<uInt> GRPC_SLICE_LENGTH(input->slices[i]);
zs->next_in = GRPC_SLICE_START_PTR(input->slices[i]);
do {
if (zs->avail_out == 0) {
grpc_slice_buffer_add_indexed(output, outbuf);
outbuf = GRPC_SLICE_MALLOC(OUTPUT_BLOCK_SIZE);
GPR_ASSERT(GRPC_SLICE_LENGTH(outbuf) <= uint_max);
CHECK(GRPC_SLICE_LENGTH(outbuf) <= uint_max);
zs->avail_out = static_cast<uInt> GRPC_SLICE_LENGTH(outbuf);
zs->next_out = GRPC_SLICE_START_PTR(outbuf);
}
@ -74,7 +76,7 @@ static int zlib_body(z_stream* zs, grpc_slice_buffer* input,
goto error;
}
GPR_ASSERT(outbuf.refcount);
CHECK(outbuf.refcount);
outbuf.data.refcounted.length -= zs->avail_out;
grpc_slice_buffer_add_indexed(output, outbuf);
@ -104,7 +106,7 @@ static int zlib_compress(grpc_slice_buffer* input, grpc_slice_buffer* output,
zs.zfree = zfree_gpr;
r = deflateInit2(&zs, Z_DEFAULT_COMPRESSION, Z_DEFLATED, 15 | (gzip ? 16 : 0),
8, Z_DEFAULT_STRATEGY);
GPR_ASSERT(r == Z_OK);
CHECK(r == Z_OK);
r = zlib_body(&zs, input, output, deflate) && output->length < input->length;
if (!r) {
for (i = count_before; i < output->count; i++) {
@ -128,7 +130,7 @@ static int zlib_decompress(grpc_slice_buffer* input, grpc_slice_buffer* output,
zs.zalloc = zalloc_gpr;
zs.zfree = zfree_gpr;
r = inflateInit2(&zs, 15 | (gzip ? 16 : 0));
GPR_ASSERT(r == Z_OK);
CHECK(r == Z_OK);
r = zlib_body(&zs, input, output, inflate);
if (!r) {
for (i = count_before; i < output->count; i++) {

@ -18,6 +18,8 @@
#include <utility>
#include <vector>
#include "absl/log/check.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
@ -49,18 +51,18 @@ CoreConfiguration::CoreConfiguration(Builder* builder)
void CoreConfiguration::RegisterBuilder(
absl::AnyInvocable<void(Builder*)> builder) {
GPR_ASSERT(config_.load(std::memory_order_relaxed) == nullptr &&
"CoreConfiguration was already instantiated before builder "
"registration was completed");
CHECK(config_.load(std::memory_order_relaxed) == nullptr)
<< "CoreConfiguration was already instantiated before builder "
"registration was completed";
RegisteredBuilder* n = new RegisteredBuilder();
n->builder = std::move(builder);
n->next = builders_.load(std::memory_order_relaxed);
while (!builders_.compare_exchange_weak(n->next, n, std::memory_order_acq_rel,
std::memory_order_relaxed)) {
}
GPR_ASSERT(config_.load(std::memory_order_relaxed) == nullptr &&
"CoreConfiguration was already instantiated before builder "
"registration was completed");
CHECK(config_.load(std::memory_order_relaxed) == nullptr)
<< "CoreConfiguration was already instantiated before builder "
"registration was completed";
}
const CoreConfiguration& CoreConfiguration::BuildNewAndMaybeSet() {

@ -18,6 +18,7 @@
#include <atomic>
#include "absl/functional/any_invocable.h"
#include "absl/log/check.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
@ -129,10 +130,10 @@ class GRPC_DLL CoreConfiguration {
~WithSubstituteBuilder() {
// Reset and restore.
Reset();
GPR_ASSERT(CoreConfiguration::config_.exchange(
config_restore_, std::memory_order_acquire) == nullptr);
GPR_ASSERT(CoreConfiguration::builders_.exchange(
builders_restore_, std::memory_order_acquire) == nullptr);
CHECK(CoreConfiguration::config_.exchange(
config_restore_, std::memory_order_acquire) == nullptr);
CHECK(CoreConfiguration::builders_.exchange(
builders_restore_, std::memory_order_acquire) == nullptr);
}
private:

@ -17,6 +17,7 @@
#include <stdio.h>
#include "absl/flags/marshalling.h"
#include "absl/log/check.h"
#include "absl/strings/numbers.h"
#include "absl/strings/str_join.h"
#include "absl/types/optional.h"
@ -36,7 +37,7 @@ absl::optional<std::string> LoadEnv(absl::string_view environment_variable) {
std::string LoadConfigFromEnv(absl::string_view environment_variable,
const char* default_value) {
GPR_ASSERT_INTERNAL(!environment_variable.empty());
CHECK(!environment_variable.empty());
return LoadEnv(environment_variable).value_or(default_value);
}

@ -17,6 +17,7 @@
#include <algorithm>
#include <atomic>
#include "absl/log/check.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_join.h"
@ -28,7 +29,7 @@ namespace grpc_core {
std::atomic<EventLog*> EventLog::g_instance_{nullptr};
EventLog::~EventLog() {
GPR_ASSERT(g_instance_.load(std::memory_order_acquire) != this);
CHECK(g_instance_.load(std::memory_order_acquire) != this);
}
void EventLog::BeginCollection() {

@ -23,6 +23,7 @@
#include <utility>
#include "absl/functional/any_invocable.h"
#include "absl/log/check.h"
#include "absl/strings/str_join.h"
#include "absl/strings/str_split.h"
#include "absl/strings/string_view.h"
@ -146,7 +147,7 @@ GPR_ATTRIBUTE_NOINLINE Experiments LoadExperimentsFromConfigVariableInner() {
j++) {
// Require that we can check dependent requirements with a linear sweep
// (implies the experiments generator must DAG sort the experiments)
GPR_ASSERT(g_experiment_metadata[i].required_experiments[j] < i);
CHECK(g_experiment_metadata[i].required_experiments[j] < i);
if (!experiments
.enabled[g_experiment_metadata[i].required_experiments[j]]) {
experiments.enabled[i] = false;
@ -244,11 +245,11 @@ void PrintExperimentsList() {
}
void ForceEnableExperiment(absl::string_view experiment, bool enable) {
GPR_ASSERT(Loaded()->load(std::memory_order_relaxed) == false);
CHECK(Loaded()->load(std::memory_order_relaxed) == false);
for (size_t i = 0; i < kNumExperiments; i++) {
if (g_experiment_metadata[i].name != experiment) continue;
if (ForcedExperiments()[i].forced) {
GPR_ASSERT(ForcedExperiments()[i].value == enable);
CHECK(ForcedExperiments()[i].value == enable);
} else {
ForcedExperiments()[i].forced = true;
ForcedExperiments()[i].value = enable;

@ -24,6 +24,7 @@
#include <utility>
#include "absl/functional/bind_front.h"
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/strings/str_format.h"
@ -183,7 +184,7 @@ HttpRequest::HttpRequest(
GRPC_CLOSURE_INIT(&continue_done_write_after_schedule_on_exec_ctx_,
ContinueDoneWriteAfterScheduleOnExecCtx, this,
grpc_schedule_on_exec_ctx);
GPR_ASSERT(pollent);
CHECK(pollent);
grpc_polling_entity_add_to_pollset_set(pollent, pollset_set_);
}
@ -216,7 +217,7 @@ void HttpRequest::Start() {
void HttpRequest::Orphan() {
{
MutexLock lock(&mu_);
GPR_ASSERT(!cancelled_);
CHECK(!cancelled_);
cancelled_ = true;
// cancel potentially pending DNS resolution.
if (dns_request_handle_.has_value() &&

@ -22,6 +22,7 @@
#include <algorithm>
#include "absl/log/check.h"
#include "absl/status/status.h"
#include <grpc/support/alloc.h>
@ -177,7 +178,7 @@ static grpc_error_handle add_header(grpc_http_parser* parser) {
grpc_http_header hdr = {nullptr, nullptr};
grpc_error_handle error;
GPR_ASSERT(cur != end);
CHECK(cur != end);
if (*cur == ' ' || *cur == '\t') {
error = GRPC_ERROR_CREATE("Continued header lines not supported yet");
@ -191,14 +192,14 @@ static grpc_error_handle add_header(grpc_http_parser* parser) {
error = GRPC_ERROR_CREATE("Didn't find ':' in header string");
goto done;
}
GPR_ASSERT(cur >= beg);
CHECK(cur >= beg);
hdr.key = buf2str(beg, static_cast<size_t>(cur - beg));
cur++; // skip :
while (cur != end && (*cur == ' ' || *cur == '\t')) {
cur++;
}
GPR_ASSERT((size_t)(end - cur) >= parser->cur_line_end_length);
CHECK((size_t)(end - cur) >= parser->cur_line_end_length);
size = static_cast<size_t>(end - cur) - parser->cur_line_end_length;
if ((size != 0) && (cur[size - 1] == '\r')) {
size--;

@ -24,6 +24,7 @@
#include <vector>
#include "absl/base/attributes.h"
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
@ -279,14 +280,14 @@ bool JsonReader::StartContainer(Json::Type type) {
if (type == Json::Type::kObject) {
scope.data = Json::Object();
} else {
GPR_ASSERT(type == Json::Type::kArray);
CHECK(type == Json::Type::kArray);
scope.data = Json::Array();
}
return true;
}
void JsonReader::EndContainer() {
GPR_ASSERT(!stack_.empty());
CHECK(!stack_.empty());
Scope scope = std::move(stack_.back());
stack_.pop_back();
key_ = std::move(scope.parent_object_key);

@ -17,6 +17,8 @@
#include <atomic>
#include <cstdint>
#include "absl/log/check.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
@ -26,10 +28,9 @@ ConnectionQuota::ConnectionQuota() = default;
void ConnectionQuota::SetMaxIncomingConnections(int max_incoming_connections) {
// The maximum can only be configured once.
GPR_ASSERT(max_incoming_connections < INT_MAX);
GPR_ASSERT(max_incoming_connections_.exchange(max_incoming_connections,
std::memory_order_release) ==
INT_MAX);
CHECK_LT(max_incoming_connections, INT_MAX);
CHECK(max_incoming_connections_.exchange(
max_incoming_connections, std::memory_order_release) == INT_MAX);
}
// Returns true if the incoming connection is allowed to be accepted on the
@ -62,9 +63,8 @@ void ConnectionQuota::ReleaseConnections(int num_connections) {
if (max_incoming_connections_.load(std::memory_order_relaxed) == INT_MAX) {
return;
}
GPR_ASSERT(active_incoming_connections_.fetch_sub(
num_connections, std::memory_order_acq_rel) >=
num_connections);
CHECK(active_incoming_connections_.fetch_sub(
num_connections, std::memory_order_acq_rel) >= num_connections);
}
} // namespace grpc_core

@ -25,6 +25,7 @@
#include <tuple>
#include <utility>
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/strings/str_cat.h"
@ -252,9 +253,9 @@ GrpcMemoryAllocatorImpl::GrpcMemoryAllocatorImpl(
}
GrpcMemoryAllocatorImpl::~GrpcMemoryAllocatorImpl() {
GPR_ASSERT(free_bytes_.load(std::memory_order_acquire) +
sizeof(GrpcMemoryAllocatorImpl) ==
taken_bytes_.load(std::memory_order_relaxed));
CHECK(free_bytes_.load(std::memory_order_acquire) +
sizeof(GrpcMemoryAllocatorImpl) ==
taken_bytes_.load(std::memory_order_relaxed));
memory_quota_->Return(taken_bytes_.load(std::memory_order_relaxed));
}
@ -265,7 +266,7 @@ void GrpcMemoryAllocatorImpl::Shutdown() {
reclamation_handles[kNumReclamationPasses];
{
MutexLock lock(&reclaimer_mu_);
GPR_ASSERT(!shutdown_);
CHECK(!shutdown_);
shutdown_ = true;
memory_quota = memory_quota_;
for (size_t i = 0; i < kNumReclamationPasses; i++) {
@ -277,8 +278,8 @@ void GrpcMemoryAllocatorImpl::Shutdown() {
size_t GrpcMemoryAllocatorImpl::Reserve(MemoryRequest request) {
// Validate request - performed here so we don't bloat the generated code with
// inlined asserts.
GPR_ASSERT(request.min() <= request.max());
GPR_ASSERT(request.max() <= MemoryRequest::max_allowed_size());
CHECK(request.min() <= request.max());
CHECK(request.max() <= MemoryRequest::max_allowed_size());
size_t old_free = free_bytes_.load(std::memory_order_relaxed);
while (true) {
@ -357,7 +358,7 @@ void GrpcMemoryAllocatorImpl::MaybeDonateBack() {
if (GRPC_TRACE_FLAG_ENABLED(grpc_resource_quota_trace)) {
gpr_log(GPR_INFO, "[%p] Early return %" PRIdPTR " bytes", this, ret);
}
GPR_ASSERT(taken_bytes_.fetch_sub(ret, std::memory_order_relaxed) >= ret);
CHECK(taken_bytes_.fetch_sub(ret, std::memory_order_relaxed) >= ret);
memory_quota_->Return(ret);
return;
}
@ -478,7 +479,7 @@ void BasicMemoryQuota::Start() {
reclaimer_activity_ =
MakeActivity(std::move(reclamation_loop), ExecCtxWakeupScheduler(),
[](absl::Status status) {
GPR_ASSERT(status.code() == absl::StatusCode::kCancelled);
CHECK(status.code() == absl::StatusCode::kCancelled);
});
}
@ -498,7 +499,7 @@ void BasicMemoryQuota::SetSize(size_t new_size) {
void BasicMemoryQuota::Take(GrpcMemoryAllocatorImpl* allocator, size_t amount) {
// If there's a request for nothing, then do nothing!
if (amount == 0) return;
GPR_DEBUG_ASSERT(amount <= std::numeric_limits<intptr_t>::max());
DCHECK(amount <= std::numeric_limits<intptr_t>::max());
// Grab memory from the quota.
auto prior = free_bytes_.fetch_sub(amount, std::memory_order_acq_rel);
// If we push into overcommit, awake the reclaimer.

@ -28,6 +28,7 @@
#include "absl/base/thread_annotations.h"
#include "absl/container/flat_hash_set.h"
#include "absl/log/check.h"
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
@ -137,7 +138,7 @@ class ReclaimerQueue {
explicit Handle(F reclaimer, std::shared_ptr<State> state)
: sweep_(new SweepFn<F>(std::move(reclaimer), std::move(state))) {}
~Handle() override {
GPR_DEBUG_ASSERT(sweep_.load(std::memory_order_relaxed) == nullptr);
DCHECK_EQ(sweep_.load(std::memory_order_relaxed), nullptr);
}
Handle(const Handle&) = delete;
@ -438,7 +439,7 @@ class GrpcMemoryAllocatorImpl final : public EventEngineMemoryAllocatorImpl {
template <typename F>
void PostReclaimer(ReclamationPass pass, F fn) {
MutexLock lock(&reclaimer_mu_);
GPR_ASSERT(!shutdown_);
CHECK(!shutdown_);
InsertReclaimer(static_cast<size_t>(pass), std::move(fn));
}

@ -14,6 +14,8 @@
#include "src/core/lib/resource_quota/thread_quota.h"
#include "absl/log/check.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
@ -37,7 +39,7 @@ bool ThreadQuota::Reserve(size_t num_threads) {
void ThreadQuota::Release(size_t num_threads) {
MutexLock lock(&mu_);
GPR_ASSERT(num_threads <= allocated_);
CHECK(num_threads <= allocated_);
allocated_ -= num_threads;
}

@ -105,6 +105,7 @@ CC_FILES=[
'third_party/abseil-cpp/absl/hash/internal/hash.cc',
'third_party/abseil-cpp/absl/hash/internal/low_level_hash.cc',
'third_party/abseil-cpp/absl/log/globals.cc',
'third_party/abseil-cpp/absl/log/internal/check_op.cc',
'third_party/abseil-cpp/absl/log/internal/conditions.cc',
'third_party/abseil-cpp/absl/log/internal/fnmatch.cc',
'third_party/abseil-cpp/absl/log/internal/globals.cc',

Loading…
Cancel
Save