diff --git a/BUILD b/BUILD
index 36d1a6db365..9b4e0a47f1f 100644
--- a/BUILD
+++ b/BUILD
@@ -643,6 +643,7 @@ grpc_cc_library(
"//src/core:lib/gpr/tmpfile_posix.cc",
"//src/core:lib/gpr/tmpfile_windows.cc",
"//src/core:lib/gpr/wrap_memcpy.cc",
+ "//src/core:lib/gprpp/crash.cc",
"//src/core:lib/gprpp/fork.cc",
"//src/core:lib/gprpp/global_config_env.cc",
"//src/core:lib/gprpp/host_port.cc",
@@ -658,6 +659,7 @@ grpc_cc_library(
"//src/core:lib/gpr/string.h",
"//src/core:lib/gpr/time_precise.h",
"//src/core:lib/gpr/tmpfile.h",
+ "//src/core:lib/gprpp/crash.h",
"//src/core:lib/gprpp/fork.h",
"//src/core:lib/gprpp/global_config.h",
"//src/core:lib/gprpp/global_config_custom.h",
@@ -691,6 +693,7 @@ grpc_cc_library(
],
visibility = ["@grpc:public"],
deps = [
+ "debug_location",
"//src/core:construct_destruct",
"//src/core:env",
"//src/core:examine_stack",
@@ -1002,6 +1005,7 @@ grpc_cc_library(
"//src/core:channel_args",
"//src/core:channel_args_preconditioning",
"//src/core:channel_stack_type",
+ "//src/core:default_event_engine",
"//src/core:iomgr_fwd",
"//src/core:iomgr_port",
"//src/core:slice",
@@ -1746,6 +1750,7 @@ grpc_cc_library(
"absl/status",
"absl/status:statusor",
"absl/strings",
+ "absl/strings:str_format",
"absl/synchronization",
"absl/memory",
"absl/types:optional",
@@ -1817,6 +1822,7 @@ grpc_cc_library(
"absl/types:optional",
"absl/memory",
"upb_lib",
+ "absl/strings:str_format",
"protobuf_headers",
],
language = "c++",
@@ -2371,6 +2377,7 @@ grpc_cc_library(
"//src/core:lib/iomgr/executor.h",
"//src/core:lib/iomgr/iomgr_internal.h",
],
+ external_deps = ["absl/strings:str_format"],
visibility = [
"@grpc:alt_grpc_base_legacy",
"@grpc:exec_ctx",
@@ -2432,6 +2439,7 @@ grpc_cc_library(
],
external_deps = [
"absl/strings",
+ "absl/strings:str_format",
],
tags = ["nofixdeps"],
visibility = ["@grpc:iomgr_timer"],
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1622f33b189..d947df615d4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1565,6 +1565,7 @@ add_library(gpr
src/core/lib/gpr/tmpfile_posix.cc
src/core/lib/gpr/tmpfile_windows.cc
src/core/lib/gpr/wrap_memcpy.cc
+ src/core/lib/gprpp/crash.cc
src/core/lib/gprpp/env_linux.cc
src/core/lib/gprpp/env_posix.cc
src/core/lib/gprpp/env_windows.cc
diff --git a/Makefile b/Makefile
index 27ff6139b4f..92940dc1887 100644
--- a/Makefile
+++ b/Makefile
@@ -867,6 +867,7 @@ LIBGPR_SRC = \
src/core/lib/gpr/tmpfile_posix.cc \
src/core/lib/gpr/tmpfile_windows.cc \
src/core/lib/gpr/wrap_memcpy.cc \
+ src/core/lib/gprpp/crash.cc \
src/core/lib/gprpp/env_linux.cc \
src/core/lib/gprpp/env_posix.cc \
src/core/lib/gprpp/env_windows.cc \
diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl
index e830eea132a..3780b652d21 100644
--- a/bazel/grpc_deps.bzl
+++ b/bazel/grpc_deps.bzl
@@ -206,7 +206,7 @@ def grpc_deps():
)
native.bind(
- name = "googleapis_logging_proto",
+ name = "googleapis_logging_cc_proto",
actual = "@com_google_googleapis//google/logging/v2:logging_cc_proto",
)
diff --git a/build_autogenerated.yaml b/build_autogenerated.yaml
index 3d22a961460..a5a6c78b9be 100644
--- a/build_autogenerated.yaml
+++ b/build_autogenerated.yaml
@@ -176,6 +176,8 @@ libs:
- src/core/lib/gpr/tmpfile.h
- src/core/lib/gpr/useful.h
- src/core/lib/gprpp/construct_destruct.h
+ - src/core/lib/gprpp/crash.h
+ - src/core/lib/gprpp/debug_location.h
- src/core/lib/gprpp/env.h
- src/core/lib/gprpp/examine_stack.h
- src/core/lib/gprpp/fork.h
@@ -221,6 +223,7 @@ libs:
- src/core/lib/gpr/tmpfile_posix.cc
- src/core/lib/gpr/tmpfile_windows.cc
- src/core/lib/gpr/wrap_memcpy.cc
+ - src/core/lib/gprpp/crash.cc
- src/core/lib/gprpp/env_linux.cc
- src/core/lib/gprpp/env_posix.cc
- src/core/lib/gprpp/env_windows.cc
@@ -810,7 +813,6 @@ libs:
- src/core/lib/gprpp/bitset.h
- src/core/lib/gprpp/chunked_vector.h
- src/core/lib/gprpp/cpp_impl_of.h
- - src/core/lib/gprpp/debug_location.h
- src/core/lib/gprpp/dual_ref_counted.h
- src/core/lib/gprpp/load_file.h
- src/core/lib/gprpp/manual_constructor.h
@@ -2119,7 +2121,6 @@ libs:
- src/core/lib/gprpp/bitset.h
- src/core/lib/gprpp/chunked_vector.h
- src/core/lib/gprpp/cpp_impl_of.h
- - src/core/lib/gprpp/debug_location.h
- src/core/lib/gprpp/dual_ref_counted.h
- src/core/lib/gprpp/load_file.h
- src/core/lib/gprpp/manual_constructor.h
@@ -3556,7 +3557,6 @@ libs:
- src/core/lib/gprpp/bitset.h
- src/core/lib/gprpp/chunked_vector.h
- src/core/lib/gprpp/cpp_impl_of.h
- - src/core/lib/gprpp/debug_location.h
- src/core/lib/gprpp/dual_ref_counted.h
- src/core/lib/gprpp/load_file.h
- src/core/lib/gprpp/manual_constructor.h
@@ -4367,7 +4367,6 @@ targets:
headers:
- src/core/lib/gprpp/atomic_utils.h
- src/core/lib/gprpp/bitset.h
- - src/core/lib/gprpp/debug_location.h
- src/core/lib/gprpp/orphanable.h
- src/core/lib/gprpp/ref_counted.h
- src/core/lib/gprpp/ref_counted_ptr.h
@@ -5668,7 +5667,6 @@ targets:
- src/core/lib/gprpp/bitset.h
- src/core/lib/gprpp/chunked_vector.h
- src/core/lib/gprpp/cpp_impl_of.h
- - src/core/lib/gprpp/debug_location.h
- src/core/lib/gprpp/manual_constructor.h
- src/core/lib/gprpp/orphanable.h
- src/core/lib/gprpp/ref_counted.h
@@ -6663,7 +6661,6 @@ targets:
- src/core/lib/gpr/spinlock.h
- src/core/lib/gprpp/atomic_utils.h
- src/core/lib/gprpp/bitset.h
- - src/core/lib/gprpp/debug_location.h
- src/core/lib/gprpp/manual_constructor.h
- src/core/lib/gprpp/orphanable.h
- src/core/lib/gprpp/ref_counted.h
@@ -6940,7 +6937,6 @@ targets:
- src/core/lib/gprpp/atomic_utils.h
- src/core/lib/gprpp/bitset.h
- src/core/lib/gprpp/cpp_impl_of.h
- - src/core/lib/gprpp/debug_location.h
- src/core/lib/gprpp/manual_constructor.h
- src/core/lib/gprpp/orphanable.h
- src/core/lib/gprpp/ref_counted.h
@@ -7032,7 +7028,6 @@ targets:
- src/core/lib/gprpp/atomic_utils.h
- src/core/lib/gprpp/bitset.h
- src/core/lib/gprpp/cpp_impl_of.h
- - src/core/lib/gprpp/debug_location.h
- src/core/lib/gprpp/manual_constructor.h
- src/core/lib/gprpp/orphanable.h
- src/core/lib/gprpp/ref_counted.h
@@ -7301,7 +7296,6 @@ targets:
- src/core/lib/gprpp/bitset.h
- src/core/lib/gprpp/chunked_vector.h
- src/core/lib/gprpp/cpp_impl_of.h
- - src/core/lib/gprpp/debug_location.h
- src/core/lib/gprpp/dual_ref_counted.h
- src/core/lib/gprpp/load_file.h
- src/core/lib/gprpp/manual_constructor.h
@@ -8860,7 +8854,6 @@ targets:
headers:
- src/core/lib/gprpp/atomic_utils.h
- src/core/lib/gprpp/bitset.h
- - src/core/lib/gprpp/debug_location.h
- src/core/lib/gprpp/orphanable.h
- src/core/lib/gprpp/ref_counted.h
- src/core/lib/gprpp/ref_counted_ptr.h
@@ -8976,7 +8969,6 @@ targets:
- src/core/lib/gprpp/atomic_utils.h
- src/core/lib/gprpp/bitset.h
- src/core/lib/gprpp/cpp_impl_of.h
- - src/core/lib/gprpp/debug_location.h
- src/core/lib/gprpp/manual_constructor.h
- src/core/lib/gprpp/orphanable.h
- src/core/lib/gprpp/ref_counted.h
@@ -9333,7 +9325,6 @@ targets:
language: c++
headers:
- src/core/lib/gprpp/atomic_utils.h
- - src/core/lib/gprpp/debug_location.h
- src/core/lib/gprpp/orphanable.h
- src/core/lib/gprpp/ref_counted.h
- src/core/lib/gprpp/ref_counted_ptr.h
@@ -9541,7 +9532,6 @@ targets:
- src/core/lib/debug/trace.h
- src/core/lib/gpr/spinlock.h
- src/core/lib/gprpp/bitset.h
- - src/core/lib/gprpp/debug_location.h
- src/core/lib/gprpp/manual_constructor.h
- src/core/lib/gprpp/status_helper.h
- src/core/lib/gprpp/time.h
@@ -9640,7 +9630,6 @@ targets:
- src/core/lib/gprpp/atomic_utils.h
- src/core/lib/gprpp/bitset.h
- src/core/lib/gprpp/cpp_impl_of.h
- - src/core/lib/gprpp/debug_location.h
- src/core/lib/gprpp/manual_constructor.h
- src/core/lib/gprpp/orphanable.h
- src/core/lib/gprpp/ref_counted.h
@@ -11684,7 +11673,6 @@ targets:
language: c++
headers:
- src/core/lib/gprpp/atomic_utils.h
- - src/core/lib/gprpp/debug_location.h
- src/core/lib/gprpp/ref_counted.h
- src/core/lib/gprpp/ref_counted_ptr.h
- src/core/lib/resource_quota/thread_quota.h
@@ -12012,7 +12000,6 @@ targets:
- src/core/lib/gpr/spinlock.h
- src/core/lib/gprpp/atomic_utils.h
- src/core/lib/gprpp/bitset.h
- - src/core/lib/gprpp/debug_location.h
- src/core/lib/gprpp/manual_constructor.h
- src/core/lib/gprpp/orphanable.h
- src/core/lib/gprpp/ref_counted.h
diff --git a/config.m4 b/config.m4
index 797edd3bffe..782b64ae94e 100644
--- a/config.m4
+++ b/config.m4
@@ -557,6 +557,7 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/gpr/tmpfile_posix.cc \
src/core/lib/gpr/tmpfile_windows.cc \
src/core/lib/gpr/wrap_memcpy.cc \
+ src/core/lib/gprpp/crash.cc \
src/core/lib/gprpp/env_linux.cc \
src/core/lib/gprpp/env_posix.cc \
src/core/lib/gprpp/env_windows.cc \
diff --git a/config.w32 b/config.w32
index f004d31c5d7..5b8d724e60f 100644
--- a/config.w32
+++ b/config.w32
@@ -523,6 +523,7 @@ if (PHP_GRPC != "no") {
"src\\core\\lib\\gpr\\tmpfile_posix.cc " +
"src\\core\\lib\\gpr\\tmpfile_windows.cc " +
"src\\core\\lib\\gpr\\wrap_memcpy.cc " +
+ "src\\core\\lib\\gprpp\\crash.cc " +
"src\\core\\lib\\gprpp\\env_linux.cc " +
"src\\core\\lib\\gprpp\\env_posix.cc " +
"src\\core\\lib\\gprpp\\env_windows.cc " +
diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec
index 75978d8614a..c9fd9ecfdfb 100644
--- a/gRPC-C++.podspec
+++ b/gRPC-C++.podspec
@@ -769,6 +769,7 @@ Pod::Spec.new do |s|
'src/core/lib/gprpp/chunked_vector.h',
'src/core/lib/gprpp/construct_destruct.h',
'src/core/lib/gprpp/cpp_impl_of.h',
+ 'src/core/lib/gprpp/crash.h',
'src/core/lib/gprpp/debug_location.h',
'src/core/lib/gprpp/dual_ref_counted.h',
'src/core/lib/gprpp/env.h',
@@ -1679,6 +1680,7 @@ Pod::Spec.new do |s|
'src/core/lib/gprpp/chunked_vector.h',
'src/core/lib/gprpp/construct_destruct.h',
'src/core/lib/gprpp/cpp_impl_of.h',
+ 'src/core/lib/gprpp/crash.h',
'src/core/lib/gprpp/debug_location.h',
'src/core/lib/gprpp/dual_ref_counted.h',
'src/core/lib/gprpp/env.h',
diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec
index 703f92ece4e..f1ddc814b1d 100644
--- a/gRPC-Core.podspec
+++ b/gRPC-Core.podspec
@@ -1216,6 +1216,8 @@ Pod::Spec.new do |s|
'src/core/lib/gprpp/chunked_vector.h',
'src/core/lib/gprpp/construct_destruct.h',
'src/core/lib/gprpp/cpp_impl_of.h',
+ 'src/core/lib/gprpp/crash.cc',
+ 'src/core/lib/gprpp/crash.h',
'src/core/lib/gprpp/debug_location.h',
'src/core/lib/gprpp/dual_ref_counted.h',
'src/core/lib/gprpp/env.h',
@@ -2347,6 +2349,7 @@ Pod::Spec.new do |s|
'src/core/lib/gprpp/chunked_vector.h',
'src/core/lib/gprpp/construct_destruct.h',
'src/core/lib/gprpp/cpp_impl_of.h',
+ 'src/core/lib/gprpp/crash.h',
'src/core/lib/gprpp/debug_location.h',
'src/core/lib/gprpp/dual_ref_counted.h',
'src/core/lib/gprpp/env.h',
diff --git a/grpc.def b/grpc.def
index c0171e080e4..e4fcb379c39 100644
--- a/grpc.def
+++ b/grpc.def
@@ -233,6 +233,7 @@ EXPORTS
gpr_set_log_verbosity
gpr_log_verbosity_init
gpr_set_log_function
+ gpr_assertion_failed
gpr_format_message
gpr_strdup
gpr_asprintf
diff --git a/grpc.gemspec b/grpc.gemspec
index 61d46c5734a..93e24b8e1ee 100644
--- a/grpc.gemspec
+++ b/grpc.gemspec
@@ -1127,6 +1127,8 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/gprpp/chunked_vector.h )
s.files += %w( src/core/lib/gprpp/construct_destruct.h )
s.files += %w( src/core/lib/gprpp/cpp_impl_of.h )
+ s.files += %w( src/core/lib/gprpp/crash.cc )
+ s.files += %w( src/core/lib/gprpp/crash.h )
s.files += %w( src/core/lib/gprpp/debug_location.h )
s.files += %w( src/core/lib/gprpp/dual_ref_counted.h )
s.files += %w( src/core/lib/gprpp/env.h )
diff --git a/grpc.gyp b/grpc.gyp
index 69d21262cc3..f9252aebcde 100644
--- a/grpc.gyp
+++ b/grpc.gyp
@@ -332,6 +332,7 @@
'src/core/lib/gpr/tmpfile_posix.cc',
'src/core/lib/gpr/tmpfile_windows.cc',
'src/core/lib/gpr/wrap_memcpy.cc',
+ 'src/core/lib/gprpp/crash.cc',
'src/core/lib/gprpp/env_linux.cc',
'src/core/lib/gprpp/env_posix.cc',
'src/core/lib/gprpp/env_windows.cc',
diff --git a/include/grpc/support/log.h b/include/grpc/support/log.h
index 3a9cd46f5dd..1f987fd35d5 100644
--- a/include/grpc/support/log.h
+++ b/include/grpc/support/log.h
@@ -84,17 +84,19 @@ typedef struct gpr_log_func_args gpr_log_func_args;
typedef void (*gpr_log_func)(gpr_log_func_args* args);
GPRAPI void gpr_set_log_function(gpr_log_func func);
+GPRAPI void gpr_assertion_failed(const char* filename, int line,
+ const char* message) GPR_ATTRIBUTE_NORETURN;
+
/** abort() the process if x is zero, having written a line to the log.
Intended for internal invariants. If the error can be recovered from,
without the possibility of corruption, or might best be reflected via
an exception in a higher-level language, consider returning error code. */
-#define GPR_ASSERT(x) \
- do { \
- if (GPR_UNLIKELY(!(x))) { \
- gpr_log(GPR_ERROR, "assertion failed: %s", #x); \
- abort(); \
- } \
+#define GPR_ASSERT(x) \
+ do { \
+ if (GPR_UNLIKELY(!(x))) { \
+ gpr_assertion_failed(__FILE__, __LINE__, #x); \
+ } \
} while (0)
#ifndef NDEBUG
diff --git a/package.xml b/package.xml
index bad8a5155ba..25ac6867a93 100644
--- a/package.xml
+++ b/package.xml
@@ -1109,6 +1109,8 @@
+
+
diff --git a/src/core/BUILD b/src/core/BUILD
index ef9f183b285..4271e525424 100644
--- a/src/core/BUILD
+++ b/src/core/BUILD
@@ -1573,6 +1573,7 @@ grpc_cc_library(
"absl/status",
"absl/status:statusor",
"absl/strings",
+ "absl/strings:str_format",
],
deps = [
"event_engine_poller",
@@ -1608,6 +1609,7 @@ grpc_cc_library(
"absl/status",
"absl/status:statusor",
"absl/strings",
+ "absl/strings:str_format",
],
deps = [
"common_event_engine_closures",
@@ -2590,6 +2592,7 @@ grpc_cc_library(
"absl/status",
"absl/status:statusor",
"absl/strings",
+ "absl/strings:str_format",
"absl/types:optional",
],
language = "c++",
diff --git a/src/core/ext/filters/client_channel/channel_connectivity.cc b/src/core/ext/filters/client_channel/channel_connectivity.cc
index 9f393f8614c..7c87ab6960c 100644
--- a/src/core/ext/filters/client_channel/channel_connectivity.cc
+++ b/src/core/ext/filters/client_channel/channel_connectivity.cc
@@ -33,6 +33,7 @@
#include "src/core/lib/channel/channel_fwd.h"
#include "src/core/lib/channel/channel_stack.h"
#include "src/core/lib/debug/trace.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/dual_ref_counted.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/gprpp/time.h"
@@ -130,10 +131,9 @@ class StateWatcher : public DualRefCounted {
Unref();
return;
}
- gpr_log(GPR_ERROR,
- "grpc_channel_watch_connectivity_state called on "
- "something that is not a client channel");
- GPR_ASSERT(false);
+ Crash(
+ "grpc_channel_watch_connectivity_state called on something that is "
+ "not a client channel");
}
// Ref from object creation is held by the watcher callback.
auto* watcher_timer_init_state = new WatcherTimerInitState(
diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc
index de61e3ca544..af63a734fdc 100644
--- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc
+++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc
@@ -58,7 +58,6 @@
// IWYU pragma: no_include
#include
-#include
#include
#include
@@ -107,6 +106,7 @@
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/gpr/useful.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/debug_location.h"
#include "src/core/lib/gprpp/orphanable.h"
#include "src/core/lib/gprpp/ref_counted.h"
@@ -792,10 +792,9 @@ RefCountedPtr GrpcLb::Helper::CreateSubchannel(
static_cast(
address.GetAttribute(kGrpcLbAddressAttributeKey));
if (attribute == nullptr) {
- gpr_log(GPR_ERROR,
- "[grpclb %p] no TokenAndClientStatsAttribute for address %p",
- parent_.get(), address.ToString().c_str());
- abort();
+ Crash(absl::StrFormat(
+ "[grpclb %p] no TokenAndClientStatsAttribute for address %p",
+ parent_.get(), address.ToString().c_str()));
}
std::string lb_token = attribute->lb_token();
RefCountedPtr client_stats = attribute->client_stats();
diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc
index 5f1fd0d34a8..7e427c417e5 100644
--- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc
+++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc
@@ -36,6 +36,7 @@
#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h"
#include "src/core/lib/address_utils/sockaddr_utils.h"
#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/memory.h"
#include "src/core/lib/iomgr/iocp_windows.h"
#include "src/core/lib/iomgr/sockaddr_windows.h"
diff --git a/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc b/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc
index becdbb51b76..4e283df9e70 100644
--- a/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc
+++ b/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc
@@ -583,7 +583,7 @@ XdsResolver::XdsConfigSelector::CreateMethodConfig(
retry_parts.push_back(
absl::StrFormat(" \"retryableStatusCodes\": [\n %s ]\n",
absl::StrJoin(code_parts, ",\n")));
- retry_parts.push_back(absl::StrFormat(" }"));
+ retry_parts.push_back(" }");
fields.emplace_back(absl::StrJoin(retry_parts, ""));
}
// Set timeout.
diff --git a/src/core/ext/filters/stateful_session/stateful_session_filter.cc b/src/core/ext/filters/stateful_session/stateful_session_filter.cc
index 2221f0fbdc8..443d90083c8 100644
--- a/src/core/ext/filters/stateful_session/stateful_session_filter.cc
+++ b/src/core/ext/filters/stateful_session/stateful_session_filter.cc
@@ -44,6 +44,7 @@
#include "src/core/lib/channel/context.h"
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/debug/trace.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/time.h"
#include "src/core/lib/promise/context.h"
#include "src/core/lib/promise/detail/basic_seq.h"
@@ -106,9 +107,7 @@ void MaybeUpdateServerInitialMetadata(
server_initial_metadata->Append(
"set-cookie", Slice::FromCopiedString(absl::StrJoin(parts, "; ")),
[](absl::string_view error, const Slice&) {
- gpr_log(GPR_ERROR, "ERROR ADDING set-cookie METADATA: %s",
- std::string(error).c_str());
- GPR_ASSERT(false);
+ Crash(absl::StrCat("ERROR ADDING set-cookie METADATA: ", error));
});
}
}
diff --git a/src/core/ext/transport/binder/client/channel_create.cc b/src/core/ext/transport/binder/client/channel_create.cc
index 52db3ae8330..1c785daffb8 100644
--- a/src/core/ext/transport/binder/client/channel_create.cc
+++ b/src/core/ext/transport/binder/client/channel_create.cc
@@ -30,6 +30,8 @@
#include
#include
+#include "src/core/lib/gprpp/crash.h"
+
#ifdef GPR_SUPPORT_BINDER_TRANSPORT
#include
diff --git a/src/core/ext/transport/binder/client/jni_utils.cc b/src/core/ext/transport/binder/client/jni_utils.cc
index c93ec4e0d5f..e0e3f59582b 100644
--- a/src/core/ext/transport/binder/client/jni_utils.cc
+++ b/src/core/ext/transport/binder/client/jni_utils.cc
@@ -20,6 +20,8 @@
#include
+#include "src/core/lib/gprpp/crash.h"
+
#if defined(ANDROID) || defined(__ANDROID__)
namespace grpc_binder {
diff --git a/src/core/ext/transport/binder/security_policy/binder_security_policy.cc b/src/core/ext/transport/binder/security_policy/binder_security_policy.cc
index af24f878b2a..a97bb6c9459 100644
--- a/src/core/ext/transport/binder/security_policy/binder_security_policy.cc
+++ b/src/core/ext/transport/binder/security_policy/binder_security_policy.cc
@@ -26,6 +26,7 @@
#include
#include "src/core/ext/transport/binder/client/jni_utils.h"
+#include "src/core/lib/gprpp/crash.h"
#endif
diff --git a/src/core/ext/transport/binder/server/binder_server_credentials.cc b/src/core/ext/transport/binder/server/binder_server_credentials.cc
index 877bd35ff6f..56440f9d27e 100644
--- a/src/core/ext/transport/binder/server/binder_server_credentials.cc
+++ b/src/core/ext/transport/binder/server/binder_server_credentials.cc
@@ -52,7 +52,7 @@ class BinderServerCredentialsImpl final : public ServerCredentials {
void SetAuthMetadataProcessor(
const std::shared_ptr& /*processor*/) override {
- GPR_ASSERT(false);
+ grpc_core::Crash("unreachable");
}
private:
diff --git a/src/core/ext/transport/binder/transport/binder_transport.cc b/src/core/ext/transport/binder/transport/binder_transport.cc
index 6cb1e091c50..09a8a64947e 100644
--- a/src/core/ext/transport/binder/transport/binder_transport.cc
+++ b/src/core/ext/transport/binder/transport/binder_transport.cc
@@ -35,6 +35,8 @@
#include "src/core/ext/transport/binder/wire_format/wire_reader.h"
#include "src/core/ext/transport/binder/wire_format/wire_reader_impl.h"
#include "src/core/ext/transport/binder/wire_format/wire_writer.h"
+#include "src/core/lib/event_engine/default_event_engine.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/transport/error_utils.h"
diff --git a/src/core/ext/transport/binder/transport/binder_transport.h b/src/core/ext/transport/binder/transport/binder_transport.h
index 93a2034d758..c40a6838127 100644
--- a/src/core/ext/transport/binder/transport/binder_transport.h
+++ b/src/core/ext/transport/binder/transport/binder_transport.h
@@ -32,6 +32,7 @@
#include "src/core/ext/transport/binder/wire_format/binder.h"
#include "src/core/ext/transport/binder/wire_format/wire_reader.h"
#include "src/core/ext/transport/binder/wire_format/wire_writer.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/iomgr/combiner.h"
#include "src/core/lib/transport/transport.h"
#include "src/core/lib/transport/transport_impl.h"
diff --git a/src/core/ext/transport/binder/utils/ndk_binder.cc b/src/core/ext/transport/binder/utils/ndk_binder.cc
index 298f988567b..20dd4908320 100644
--- a/src/core/ext/transport/binder/utils/ndk_binder.cc
+++ b/src/core/ext/transport/binder/utils/ndk_binder.cc
@@ -24,6 +24,7 @@
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/sync.h"
namespace {
diff --git a/src/core/ext/transport/binder/utils/transport_stream_receiver_impl.cc b/src/core/ext/transport/binder/utils/transport_stream_receiver_impl.cc
index d7cbf7a2857..d569d1fb614 100644
--- a/src/core/ext/transport/binder/utils/transport_stream_receiver_impl.cc
+++ b/src/core/ext/transport/binder/utils/transport_stream_receiver_impl.cc
@@ -24,6 +24,8 @@
#include
+#include "src/core/lib/gprpp/crash.h"
+
namespace grpc_binder {
const absl::string_view
diff --git a/src/core/ext/transport/binder/wire_format/binder_android.cc b/src/core/ext/transport/binder/wire_format/binder_android.cc
index c26e84130d0..21e32f2da7c 100644
--- a/src/core/ext/transport/binder/wire_format/binder_android.cc
+++ b/src/core/ext/transport/binder/wire_format/binder_android.cc
@@ -26,6 +26,7 @@
#include
#include "src/core/ext/transport/binder/wire_format/binder_android.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/sync.h"
namespace grpc_binder {
diff --git a/src/core/ext/transport/binder/wire_format/transaction.h b/src/core/ext/transport/binder/wire_format/transaction.h
index 1bd61377c73..2ea1df58e33 100644
--- a/src/core/ext/transport/binder/wire_format/transaction.h
+++ b/src/core/ext/transport/binder/wire_format/transaction.h
@@ -24,6 +24,8 @@
#include
+#include "src/core/lib/gprpp/crash.h"
+
namespace grpc_binder {
ABSL_CONST_INIT extern const int kFlagPrefix;
diff --git a/src/core/ext/transport/binder/wire_format/wire_reader_impl.cc b/src/core/ext/transport/binder/wire_format/wire_reader_impl.cc
index 6688cc2f3c2..407fee796d4 100644
--- a/src/core/ext/transport/binder/wire_format/wire_reader_impl.cc
+++ b/src/core/ext/transport/binder/wire_format/wire_reader_impl.cc
@@ -32,6 +32,7 @@
#include "src/core/ext/transport/binder/utils/transport_stream_receiver.h"
#include "src/core/ext/transport/binder/wire_format/binder.h"
#include "src/core/ext/transport/binder/wire_format/wire_writer.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/status_helper.h"
namespace grpc_binder {
diff --git a/src/core/ext/transport/binder/wire_format/wire_writer.cc b/src/core/ext/transport/binder/wire_format/wire_writer.cc
index 6d804e9dab9..f177af8b5ac 100644
--- a/src/core/ext/transport/binder/wire_format/wire_writer.cc
+++ b/src/core/ext/transport/binder/wire_format/wire_writer.cc
@@ -25,6 +25,9 @@
#include
+#include "src/core/lib/event_engine/default_event_engine.h"
+#include "src/core/lib/gprpp/crash.h"
+
#define RETURN_IF_ERROR(expr) \
do { \
const absl::Status status = (expr); \
diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc
index 7e9928dfd77..e509feaf5aa 100644
--- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc
+++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc
@@ -21,7 +21,6 @@
#include
#include
#include
-#include
#include
#include
@@ -65,6 +64,7 @@
#include "src/core/lib/debug/stats_data.h"
#include "src/core/lib/gpr/useful.h"
#include "src/core/lib/gprpp/bitset.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/debug_location.h"
#include "src/core/lib/gprpp/ref_counted.h"
#include "src/core/lib/gprpp/status_helper.h"
@@ -697,9 +697,9 @@ grpc_chttp2_stream::~grpc_chttp2_stream() {
for (int i = 0; i < STREAM_LIST_COUNT; i++) {
if (GPR_UNLIKELY(included.is_set(i))) {
- gpr_log(GPR_ERROR, "%s stream %d still included in list %d",
- t->is_client ? "client" : "server", id, i);
- abort();
+ grpc_core::Crash(absl::StrFormat("%s stream %d still included in list %d",
+ t->is_client ? "client" : "server", id,
+ i));
}
}
diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc
index 5f6ff3f1252..93c80a71a61 100644
--- a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc
+++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc
@@ -34,6 +34,7 @@
#include "src/core/ext/transport/chttp2/transport/http_trace.h"
#include "src/core/ext/transport/chttp2/transport/varint.h"
#include "src/core/lib/debug/trace.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/surface/validate_metadata.h"
#include "src/core/lib/transport/timeout_encoding.h"
@@ -362,7 +363,7 @@ void HPackCompressor::Encoder::Encode(HttpSchemeMetadata,
EmitIndexed(7); // :scheme: https
break;
case HttpSchemeMetadata::ValueType::kInvalid:
- GPR_ASSERT(false);
+ Crash("invalid http scheme encoding");
break;
}
}
@@ -430,7 +431,7 @@ void HPackCompressor::Encoder::Encode(HttpMethodMetadata,
Slice::FromStaticString("PUT"));
break;
case HttpMethodMetadata::ValueType::kInvalid:
- GPR_ASSERT(false);
+ Crash("invalid http method encoding");
break;
}
}
diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.cc b/src/core/ext/transport/cronet/transport/cronet_transport.cc
index 5f304dd9ecc..e01141eba40 100644
--- a/src/core/ext/transport/cronet/transport/cronet_transport.cc
+++ b/src/core/ext/transport/cronet/transport/cronet_transport.cc
@@ -46,6 +46,7 @@
#include "src/core/ext/transport/chttp2/transport/bin_encoder.h"
#include "src/core/ext/transport/cronet/transport/cronet_status.h"
#include "src/core/lib/debug/trace.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/debug_location.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/iomgr/closure.h"
@@ -1109,7 +1110,7 @@ static enum e_op_result execute_stream_op(struct op_and_state* oas) {
}
} else {
// Should never reach here
- GPR_ASSERT(false);
+ grpc_core::Crash("unreachable");
}
}
stream_state->state_op_done[OP_SEND_MESSAGE] = true;
diff --git a/src/core/lib/address_utils/sockaddr_utils.cc b/src/core/lib/address_utils/sockaddr_utils.cc
index 08a39cd82c1..e45183a89a3 100644
--- a/src/core/lib/address_utils/sockaddr_utils.cc
+++ b/src/core/lib/address_utils/sockaddr_utils.cc
@@ -33,6 +33,7 @@
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/host_port.h"
#include "src/core/lib/iomgr/port.h"
#include "src/core/lib/iomgr/sockaddr.h"
@@ -356,7 +357,7 @@ std::string grpc_sockaddr_get_packed_host(
const char* addr_bytes = reinterpret_cast(&addr6->sin6_addr);
return std::string(addr_bytes, 16);
} else {
- GPR_ASSERT(false);
+ grpc_core::Crash("unknown socket family");
}
}
diff --git a/src/core/lib/channel/promise_based_filter.cc b/src/core/lib/channel/promise_based_filter.cc
index 045dd834f64..929d52dce27 100644
--- a/src/core/lib/channel/promise_based_filter.cc
+++ b/src/core/lib/channel/promise_based_filter.cc
@@ -24,6 +24,7 @@
#include "absl/base/attributes.h"
#include "absl/functional/function_ref.h"
#include "absl/strings/str_cat.h"
+#include "absl/strings/str_format.h"
#include "absl/strings/str_join.h"
#include "absl/types/variant.h"
@@ -31,6 +32,7 @@
#include "src/core/lib/channel/channel_stack.h"
#include "src/core/lib/debug/trace.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/manual_constructor.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/iomgr/error.h"
@@ -318,8 +320,7 @@ void BaseCallData::SendMessage::StartOp(CapturedBatch batch) {
case State::kForwardedBatch:
case State::kBatchCompleted:
case State::kPushedToPipe:
- gpr_log(GPR_ERROR, "ILLEGAL STATE: %s", StateString(state_));
- abort();
+ Crash(absl::StrFormat("ILLEGAL STATE: %s", StateString(state_)));
case State::kCancelled:
case State::kCancelledButNotYetPolled:
return;
@@ -348,8 +349,7 @@ void BaseCallData::SendMessage::GotPipe(PipeReceiver* receiver) {
case State::kForwardedBatch:
case State::kBatchCompleted:
case State::kPushedToPipe:
- gpr_log(GPR_ERROR, "ILLEGAL STATE: %s", StateString(state_));
- abort();
+ Crash(absl::StrFormat("ILLEGAL STATE: %s", StateString(state_)));
case State::kCancelled:
case State::kCancelledButNotYetPolled:
return;
@@ -388,8 +388,7 @@ void BaseCallData::SendMessage::OnComplete(absl::Status status) {
case State::kPushedToPipe:
case State::kGotBatch:
case State::kBatchCompleted:
- gpr_log(GPR_ERROR, "ILLEGAL STATE: %s", StateString(state_));
- abort();
+ Crash(absl::StrFormat("ILLEGAL STATE: %s", StateString(state_)));
break;
case State::kCancelled:
case State::kCancelledButNotYetPolled:
@@ -422,8 +421,7 @@ void BaseCallData::SendMessage::Done(const ServerMetadata& metadata) {
case State::kGotBatchNoPipe:
case State::kGotBatch:
case State::kBatchCompleted:
- gpr_log(GPR_ERROR, "ILLEGAL STATE: %s", StateString(state_));
- abort();
+ Crash(absl::StrFormat("ILLEGAL STATE: %s", StateString(state_)));
break;
case State::kPushedToPipe:
push_.reset();
@@ -574,8 +572,7 @@ void BaseCallData::ReceiveMessage::StartOp(CapturedBatch& batch) {
case State::kPulledFromPipe:
case State::kCompletedWhilePulledFromPipe:
case State::kCompletedWhilePushedToPipe:
- gpr_log(GPR_ERROR, "ILLEGAL STATE: %s", StateString(state_));
- abort();
+ Crash(absl::StrFormat("ILLEGAL STATE: %s", StateString(state_)));
case State::kCancelledWhilstIdle:
case State::kCancelled:
return;
@@ -616,8 +613,7 @@ void BaseCallData::ReceiveMessage::GotPipe(PipeSender* sender) {
case State::kCancelledWhilstForwarding:
case State::kCancelledWhilstIdle:
case State::kBatchCompletedButCancelled:
- gpr_log(GPR_ERROR, "ILLEGAL STATE: %s", StateString(state_));
- abort();
+ Crash(absl::StrFormat("ILLEGAL STATE: %s", StateString(state_)));
case State::kCancelled:
return;
}
@@ -642,8 +638,7 @@ void BaseCallData::ReceiveMessage::OnComplete(absl::Status status) {
case State::kCancelledWhilstIdle:
case State::kCompletedWhilePulledFromPipe:
case State::kCompletedWhilePushedToPipe:
- gpr_log(GPR_ERROR, "ILLEGAL STATE: %s", StateString(state_));
- abort();
+ Crash(absl::StrFormat("ILLEGAL STATE: %s", StateString(state_)));
case State::kForwardedBatchNoPipe:
state_ = State::kBatchCompletedNoPipe;
return;
@@ -702,8 +697,7 @@ void BaseCallData::ReceiveMessage::Done(const ServerMetadata& metadata,
case State::kBatchCompleted:
case State::kBatchCompletedNoPipe:
case State::kBatchCompletedButCancelled:
- gpr_log(GPR_ERROR, "ILLEGAL STATE: %s", StateString(state_));
- abort();
+ Crash(absl::StrFormat("ILLEGAL STATE: %s", StateString(state_)));
case State::kCancelledWhilstIdle:
case State::kCancelledWhilstForwarding:
case State::kCancelled:
@@ -994,10 +988,10 @@ class ClientCallData::PollContext {
case RecvInitialMetadata::
kRespondedToTrailingMetadataPriorToHook:
case RecvInitialMetadata::kRespondedButNeedToSetLatch:
- gpr_log(GPR_ERROR, "ILLEGAL STATE: %s",
- RecvInitialMetadata::StateString(
- self_->recv_initial_metadata_->state));
- abort(); // not reachable
+ Crash(absl::StrFormat("ILLEGAL STATE: %s",
+ RecvInitialMetadata::StateString(
+ self_->recv_initial_metadata_
+ ->state))); // not reachable
break;
case RecvInitialMetadata::kHookedWaitingForLatch:
case RecvInitialMetadata::kHookedAndGotLatch:
@@ -1033,10 +1027,10 @@ class ClientCallData::PollContext {
case RecvInitialMetadata::
kRespondedToTrailingMetadataPriorToHook:
case RecvInitialMetadata::kRespondedButNeedToSetLatch:
- gpr_log(GPR_ERROR, "ILLEGAL STATE: %s",
- RecvInitialMetadata::StateString(
- self_->recv_initial_metadata_->state));
- abort(); // not reachable
+ Crash(absl::StrFormat("ILLEGAL STATE: %s",
+ RecvInitialMetadata::StateString(
+ self_->recv_initial_metadata_
+ ->state))); // not reachable
break;
case RecvInitialMetadata::kCompleteWaitingForLatch:
case RecvInitialMetadata::kCompleteAndGotLatch:
@@ -1263,10 +1257,10 @@ void ClientCallData::StartBatch(grpc_transport_stream_op_batch* b) {
case RecvInitialMetadata::kCompleteAndSetLatch:
case RecvInitialMetadata::kResponded:
case RecvInitialMetadata::kRespondedButNeedToSetLatch:
- gpr_log(
- GPR_ERROR, "ILLEGAL STATE: %s",
- RecvInitialMetadata::StateString(recv_initial_metadata_->state));
- abort(); // unreachable
+ Crash(absl::StrFormat(
+ "ILLEGAL STATE: %s",
+ RecvInitialMetadata::StateString(
+ recv_initial_metadata_->state))); // unreachable
}
if (hook) {
auto cb = [](void* ptr, grpc_error_handle error) {
@@ -1383,10 +1377,9 @@ void ClientCallData::Cancel(grpc_error_handle error, Flusher* flusher) {
case RecvInitialMetadata::kResponded:
break;
case RecvInitialMetadata::kRespondedButNeedToSetLatch:
- gpr_log(
- GPR_ERROR, "ILLEGAL STATE: %s",
- RecvInitialMetadata::StateString(recv_initial_metadata_->state));
- abort();
+ Crash(absl::StrFormat(
+ "ILLEGAL STATE: %s",
+ RecvInitialMetadata::StateString(recv_initial_metadata_->state)));
break;
}
}
@@ -1441,10 +1434,10 @@ void ClientCallData::RecvInitialMetadataReady(grpc_error_handle error) {
case RecvInitialMetadata::kResponded:
case RecvInitialMetadata::kRespondedToTrailingMetadataPriorToHook:
case RecvInitialMetadata::kRespondedButNeedToSetLatch:
- gpr_log(
- GPR_ERROR, "ILLEGAL STATE: %s",
- RecvInitialMetadata::StateString(recv_initial_metadata_->state));
- abort(); // unreachable
+ Crash(absl::StrFormat(
+ "ILLEGAL STATE: %s",
+ RecvInitialMetadata::StateString(
+ recv_initial_metadata_->state))); // unreachable
}
flusher.AddClosure(
std::exchange(recv_initial_metadata_->original_on_ready, nullptr),
@@ -1473,10 +1466,10 @@ void ClientCallData::RecvInitialMetadataReady(grpc_error_handle error) {
case RecvInitialMetadata::kResponded:
case RecvInitialMetadata::kRespondedToTrailingMetadataPriorToHook:
case RecvInitialMetadata::kRespondedButNeedToSetLatch:
- gpr_log(
- GPR_ERROR, "ILLEGAL STATE: %s",
- RecvInitialMetadata::StateString(recv_initial_metadata_->state));
- abort(); // unreachable
+ Crash(absl::StrFormat(
+ "ILLEGAL STATE: %s",
+ RecvInitialMetadata::StateString(
+ recv_initial_metadata_->state))); // unreachable
}
}
WakeInsideCombiner(&flusher);
@@ -1537,10 +1530,10 @@ ArenaPromise ClientCallData::MakeNextPromise(
case RecvInitialMetadata::kResponded:
case RecvInitialMetadata::kRespondedToTrailingMetadataPriorToHook:
case RecvInitialMetadata::kRespondedButNeedToSetLatch:
- gpr_log(
- GPR_ERROR, "ILLEGAL STATE: %s",
- RecvInitialMetadata::StateString(recv_initial_metadata_->state));
- abort(); // unreachable
+ Crash(absl::StrFormat(
+ "ILLEGAL STATE: %s",
+ RecvInitialMetadata::StateString(
+ recv_initial_metadata_->state))); // unreachable
}
} else {
GPR_ASSERT(call_args.server_initial_metadata == nullptr);
@@ -1602,9 +1595,8 @@ Poll ClientCallData::PollTrailingMetadata() {
case RecvTrailingState::kResponded:
// We've already responded to the caller: we can't do anything and we
// should never reach here.
- gpr_log(GPR_ERROR, "ILLEGAL STATE: %s",
- StateString(recv_trailing_state_));
- abort();
+ Crash(absl::StrFormat("ILLEGAL STATE: %s",
+ StateString(recv_trailing_state_)));
}
GPR_UNREACHABLE_CODE(return Pending{});
}
@@ -1903,10 +1895,10 @@ void ServerCallData::StartBatch(grpc_transport_stream_op_batch* b) {
case SendInitialMetadata::kQueuedWaitingForLatch:
case SendInitialMetadata::kQueuedAndSetLatch:
case SendInitialMetadata::kForwarded:
- gpr_log(
- GPR_ERROR, "ILLEGAL STATE: %s",
- SendInitialMetadata::StateString(send_initial_metadata_->state));
- abort(); // not reachable
+ Crash(absl::StrFormat(
+ "ILLEGAL STATE: %s",
+ SendInitialMetadata::StateString(
+ send_initial_metadata_->state))); // not reachable
}
send_initial_metadata_->batch = batch;
wake = true;
@@ -1942,9 +1934,9 @@ void ServerCallData::StartBatch(grpc_transport_stream_op_batch* b) {
case SendTrailingState::kQueued:
case SendTrailingState::kQueuedBehindSendMessage:
case SendTrailingState::kForwarded:
- gpr_log(GPR_ERROR, "ILLEGAL STATE: %s",
- StateString(send_trailing_state_));
- abort(); // unreachable
+ Crash(
+ absl::StrFormat("ILLEGAL STATE: %s",
+ StateString(send_trailing_state_))); // unreachable
break;
case SendTrailingState::kCancelled:
batch.CancelWith(
@@ -2022,10 +2014,10 @@ ArenaPromise ServerCallData::MakeNextPromise(
case SendInitialMetadata::kQueuedAndGotLatch:
case SendInitialMetadata::kQueuedAndSetLatch:
case SendInitialMetadata::kForwarded:
- gpr_log(
- GPR_ERROR, "ILLEGAL STATE: %s",
- SendInitialMetadata::StateString(send_initial_metadata_->state));
- abort(); // not reachable
+ Crash(absl::StrFormat(
+ "ILLEGAL STATE: %s",
+ SendInitialMetadata::StateString(
+ send_initial_metadata_->state))); // not reachable
break;
case SendInitialMetadata::kQueuedWaitingForLatch:
send_initial_metadata_->state = SendInitialMetadata::kQueuedAndGotLatch;
@@ -2062,9 +2054,8 @@ Poll ServerCallData::PollTrailingMetadata() {
return WrapMetadata(send_trailing_metadata_batch_->payload
->send_trailing_metadata.send_trailing_metadata);
case SendTrailingState::kForwarded:
- gpr_log(GPR_ERROR, "ILLEGAL STATE: %s",
- StateString(send_trailing_state_));
- abort(); // unreachable
+ Crash(absl::StrFormat("ILLEGAL STATE: %s",
+ StateString(send_trailing_state_))); // unreachable
case SendTrailingState::kCancelled:
// We could translate cancelled_error to metadata and return it... BUT
// we're not gonna be running much longer and the results going to be
@@ -2233,9 +2224,9 @@ void ServerCallData::WakeInsideCombiner(Flusher* flusher) {
send_trailing_state_ = SendTrailingState::kForwarded;
} break;
case SendTrailingState::kForwarded:
- gpr_log(GPR_ERROR, "ILLEGAL STATE: %s",
- StateString(send_trailing_state_));
- abort(); // unreachable
+ Crash(absl::StrFormat(
+ "ILLEGAL STATE: %s",
+ StateString(send_trailing_state_))); // unreachable
break;
case SendTrailingState::kInitial: {
GPR_ASSERT(*md->get_pointer(GrpcStatusMetadata()) != GRPC_STATUS_OK);
diff --git a/src/core/lib/compression/compression_internal.cc b/src/core/lib/compression/compression_internal.cc
index eb1a31afbc2..36044e0b6c2 100644
--- a/src/core/lib/compression/compression_internal.cc
+++ b/src/core/lib/compression/compression_internal.cc
@@ -26,6 +26,7 @@
#include "absl/container/inlined_vector.h"
#include "absl/strings/ascii.h"
+#include "absl/strings/str_format.h"
#include "absl/strings/str_split.h"
#include "absl/types/variant.h"
@@ -33,6 +34,7 @@
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/debug/trace.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/surface/api_trace.h"
namespace grpc_core {
@@ -112,9 +114,8 @@ CompressionAlgorithmSet::CompressionAlgorithmForLevel(
GRPC_API_TRACE("grpc_message_compression_algorithm_for_level(level=%d)", 1,
((int)level));
if (level > GRPC_COMPRESS_LEVEL_HIGH) {
- gpr_log(GPR_ERROR, "Unknown message compression level %d.",
- static_cast(level));
- abort();
+ Crash(absl::StrFormat("Unknown message compression level %d.",
+ static_cast(level)));
}
if (level == GRPC_COMPRESS_LEVEL_NONE) {
diff --git a/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc b/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc
index d087534208c..b212756b080 100644
--- a/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc
+++ b/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc
@@ -22,6 +22,7 @@
#include "absl/status/status.h"
#include "absl/status/statusor.h"
+#include "absl/strings/str_format.h"
#include
#include
@@ -30,6 +31,7 @@
#include "src/core/lib/event_engine/poller.h"
#include "src/core/lib/event_engine/time_util.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/iomgr/port.h"
// This polling engine is only relevant on linux kernels supporting epoll
@@ -463,10 +465,9 @@ int Epoll1Poller::DoEpollWait(EventEngine::Duration timeout) {
grpc_event_engine::experimental::Milliseconds(timeout)));
} while (r < 0 && errno == EINTR);
if (r < 0) {
- gpr_log(GPR_ERROR,
- "(event_engine) Epoll1Poller:%p encountered epoll_wait error: %s",
- this, grpc_core::StrError(errno).c_str());
- GPR_ASSERT(false);
+ grpc_core::Crash(absl::StrFormat(
+ "(event_engine) Epoll1Poller:%p encountered epoll_wait error: %s", this,
+ grpc_core::StrError(errno).c_str()));
}
g_epoll_set_.num_events = r;
g_epoll_set_.cursor = 0;
@@ -573,34 +574,34 @@ using ::grpc_event_engine::experimental::EventEngine;
using ::grpc_event_engine::experimental::Poller;
Epoll1Poller::Epoll1Poller(Scheduler* /* engine */) {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
-void Epoll1Poller::Shutdown() { GPR_ASSERT(false && "unimplemented"); }
+void Epoll1Poller::Shutdown() { grpc_core::Crash("unimplemented"); }
-Epoll1Poller::~Epoll1Poller() { GPR_ASSERT(false && "unimplemented"); }
+Epoll1Poller::~Epoll1Poller() { grpc_core::Crash("unimplemented"); }
EventHandle* Epoll1Poller::CreateHandle(int /*fd*/, absl::string_view /*name*/,
bool /*track_err*/) {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
bool Epoll1Poller::ProcessEpollEvents(int /*max_epoll_events_to_handle*/,
Events& /*pending_events*/) {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
int Epoll1Poller::DoEpollWait(EventEngine::Duration /*timeout*/) {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
Poller::WorkResult Epoll1Poller::Work(
EventEngine::Duration /*timeout*/,
absl::FunctionRef /*schedule_poll_again*/) {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
-void Epoll1Poller::Kick() { GPR_ASSERT(false && "unimplemented"); }
+void Epoll1Poller::Kick() { grpc_core::Crash("unimplemented"); }
// If GRPC_LINUX_EPOLL is not defined, it means epoll is not available. Return
// nullptr.
diff --git a/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc b/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc
index 47467c4c6ac..32b892a6d7c 100644
--- a/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc
+++ b/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc
@@ -17,7 +17,6 @@
#include "src/core/lib/event_engine/posix_engine/ev_poll_posix.h"
#include
-#include
#include
#include
@@ -28,6 +27,7 @@
#include "absl/functional/any_invocable.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
+#include "absl/strings/str_format.h"
#include
#include
@@ -38,6 +38,7 @@
#include "src/core/lib/event_engine/poller.h"
#include "src/core/lib/event_engine/posix_engine/event_poller.h"
#include "src/core/lib/event_engine/posix_engine/posix_engine_closure.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/memory.h"
#include "src/core/lib/iomgr/port.h"
@@ -415,10 +416,9 @@ int PollEventHandle::NotifyOnLocked(PosixEngineClosure** st,
return 1;
} else {
// upcallptr was set to a different closure. This is an error!
- gpr_log(GPR_ERROR,
- "User called a notify_on function with a previous callback still "
- "pending");
- abort();
+ grpc_core::Crash(
+ "User called a notify_on function with a previous callback still "
+ "pending");
}
return 0;
}
@@ -719,18 +719,15 @@ Poller::WorkResult PollPoller::Work(
// may crash.
r = poll(pfds, pfd_count, timeout_ms);
} else {
- gpr_log(GPR_ERROR,
- "Attempted a blocking poll when declared non-polling.");
- GPR_ASSERT(false);
+ grpc_core::Crash("Attempted a blocking poll when declared non-polling.");
}
if (r <= 0) {
if (r < 0 && errno != EINTR) {
// Abort fail here.
- gpr_log(GPR_ERROR,
- "(event_engine) PollPoller:%p encountered poll error: %s", this,
- grpc_core::StrError(errno).c_str());
- GPR_ASSERT(false);
+ grpc_core::Crash(absl::StrFormat(
+ "(event_engine) PollPoller:%p encountered poll error: %s", this,
+ grpc_core::StrError(errno).c_str()));
}
for (i = 1; i < pfd_count; i++) {
@@ -852,29 +849,31 @@ PollPoller* MakePollPoller(Scheduler* scheduler, bool use_phony_poll) {
#else // GRPC_POSIX_SOCKET_EV_POLL
+#include "src/core/lib/gprpp/crash.h"
+
namespace grpc_event_engine {
namespace experimental {
PollPoller::PollPoller(Scheduler* /* engine */) {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
-void PollPoller::Shutdown() { GPR_ASSERT(false && "unimplemented"); }
+void PollPoller::Shutdown() { grpc_core::Crash("unimplemented"); }
-PollPoller::~PollPoller() { GPR_ASSERT(false && "unimplemented"); }
+PollPoller::~PollPoller() { grpc_core::Crash("unimplemented"); }
EventHandle* PollPoller::CreateHandle(int /*fd*/, absl::string_view /*name*/,
bool /*track_err*/) {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
Poller::WorkResult PollPoller::Work(
EventEngine::Duration /*timeout*/,
absl::FunctionRef /*schedule_poll_again*/) {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
-void PollPoller::Kick() { GPR_ASSERT(false && "unimplemented"); }
+void PollPoller::Kick() { grpc_core::Crash("unimplemented"); }
// If GRPC_LINUX_EPOLL is not defined, it means epoll is not available. Return
// nullptr.
@@ -884,15 +883,15 @@ PollPoller* MakePollPoller(Scheduler* /*scheduler*/,
}
void PollPoller::KickExternal(bool /*ext*/) {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
void PollPoller::PollerHandlesListAddHandle(PollEventHandle* /*handle*/) {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
void PollPoller::PollerHandlesListRemoveHandle(PollEventHandle* /*handle*/) {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
} // namespace experimental
diff --git a/src/core/lib/event_engine/posix_engine/lockfree_event.cc b/src/core/lib/event_engine/posix_engine/lockfree_event.cc
index 9967e5d9df5..5f17244a446 100644
--- a/src/core/lib/event_engine/posix_engine/lockfree_event.cc
+++ b/src/core/lib/event_engine/posix_engine/lockfree_event.cc
@@ -15,8 +15,6 @@
#include "src/core/lib/event_engine/posix_engine/lockfree_event.h"
-#include
-
#include
#include
@@ -27,6 +25,7 @@
#include "src/core/lib/event_engine/posix_engine/event_poller.h"
#include "src/core/lib/event_engine/posix_engine/posix_engine_closure.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/status_helper.h"
// 'state' holds the to call when the fd is readable or writable respectively.
@@ -149,10 +148,9 @@ void LockfreeEvent::NotifyOn(PosixEngineClosure* closure) {
}
// There is already a closure!. This indicates a bug in the code.
- gpr_log(GPR_ERROR,
- "LockfreeEvent::NotifyOn: notify_on called with a previous "
- "callback still pending");
- abort();
+ grpc_core::Crash(
+ "LockfreeEvent::NotifyOn: notify_on called with a previous "
+ "callback still pending");
}
}
}
diff --git a/src/core/lib/event_engine/posix_engine/posix_endpoint.cc b/src/core/lib/event_engine/posix_engine/posix_endpoint.cc
index 243f9f8d090..c0a7d704f02 100644
--- a/src/core/lib/event_engine/posix_engine/posix_endpoint.cc
+++ b/src/core/lib/event_engine/posix_engine/posix_endpoint.cc
@@ -856,7 +856,7 @@ TcpZerocopySendRecord* PosixEndpointImpl::TcpGetSendZerocopyRecord(
}
void PosixEndpointImpl::HandleError(absl::Status /*status*/) {
- GPR_ASSERT(false && "Error handling not supported on this platform");
+ grpc_core::Crash("Error handling not supported on this platform");
}
void PosixEndpointImpl::ZerocopyDisableAndWaitForRemaining() {}
@@ -866,7 +866,7 @@ bool PosixEndpointImpl::WriteWithTimestamps(struct msghdr* /*msg*/,
ssize_t* /*sent_length*/,
int* /*saved_errno*/,
int /*additional_flags*/) {
- GPR_ASSERT(false && "Write with timestamps not supported for this platform");
+ grpc_core::Crash("Write with timestamps not supported for this platform");
}
#endif // GRPC_LINUX_ERRQUEUE
@@ -1299,7 +1299,7 @@ std::unique_ptr CreatePosixEndpoint(
EventHandle* /*handle*/, PosixEngineClosure* /*on_shutdown*/,
std::shared_ptr /*engine*/,
const PosixTcpOptions& /*options*/) {
- GPR_ASSERT(false && "Cannot create PosixEndpoint on this platform");
+ grpc_core::Crash("Cannot create PosixEndpoint on this platform");
}
} // namespace experimental
diff --git a/src/core/lib/event_engine/posix_engine/posix_endpoint.h b/src/core/lib/event_engine/posix_engine/posix_endpoint.h
index 62dc4b8eb96..2d73af72e1e 100644
--- a/src/core/lib/event_engine/posix_engine/posix_endpoint.h
+++ b/src/core/lib/event_engine/posix_engine/posix_endpoint.h
@@ -42,6 +42,7 @@
#include "src/core/lib/event_engine/posix_engine/posix_engine_closure.h"
#include "src/core/lib/event_engine/posix_engine/tcp_socket_utils.h"
#include "src/core/lib/event_engine/posix_engine/traced_buffer_list.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/ref_counted.h"
#include "src/core/lib/gprpp/sync.h"
#include "src/core/lib/iomgr/port.h"
@@ -344,7 +345,7 @@ class TcpZerocopySendCtx {
// state was CHECK and is_in_write is false. This means that after the
// previous sendmsg returned and set is_in_write to false, it did
// not update the z-copy change from CHECK to OPEN.
- GPR_ASSERT(false && "OMem state error!");
+ grpc_core::Crash("OMem state error!");
}
}
@@ -641,25 +642,25 @@ class PosixEndpoint
grpc_event_engine::experimental::SliceBuffer* /*buffer*/,
const grpc_event_engine::experimental::EventEngine::Endpoint::
ReadArgs* /*args*/) override {
- GPR_ASSERT(false && "PosixEndpoint::Read not supported on this platform");
+ grpc_core::Crash("PosixEndpoint::Read not supported on this platform");
}
void Write(absl::AnyInvocable /*on_writable*/,
grpc_event_engine::experimental::SliceBuffer* /*data*/,
const grpc_event_engine::experimental::EventEngine::Endpoint::
WriteArgs* /*args*/) override {
- GPR_ASSERT(false && "PosixEndpoint::Write not supported on this platform");
+ grpc_core::Crash("PosixEndpoint::Write not supported on this platform");
}
const grpc_event_engine::experimental::EventEngine::ResolvedAddress&
GetPeerAddress() const override {
- GPR_ASSERT(false &&
- "PosixEndpoint::GetPeerAddress not supported on this platform");
+ grpc_core::Crash(
+ "PosixEndpoint::GetPeerAddress not supported on this platform");
}
const grpc_event_engine::experimental::EventEngine::ResolvedAddress&
GetLocalAddress() const override {
- GPR_ASSERT(false &&
- "PosixEndpoint::GetLocalAddress not supported on this platform");
+ grpc_core::Crash(
+ "PosixEndpoint::GetLocalAddress not supported on this platform");
}
~PosixEndpoint() override = default;
diff --git a/src/core/lib/event_engine/posix_engine/posix_engine.cc b/src/core/lib/event_engine/posix_engine/posix_engine.cc
index fea380acdac..507da3326ff 100644
--- a/src/core/lib/event_engine/posix_engine/posix_engine.cc
+++ b/src/core/lib/event_engine/posix_engine/posix_engine.cc
@@ -41,6 +41,7 @@
#include "src/core/lib/event_engine/tcp_socket_utils.h"
#include "src/core/lib/event_engine/trace.h"
#include "src/core/lib/event_engine/utils.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/sync.h"
#ifdef GRPC_POSIX_SOCKET_TCP
@@ -465,12 +466,10 @@ EventEngine::TaskHandle PosixEventEngine::RunAfterInternal(
std::unique_ptr PosixEventEngine::GetDNSResolver(
EventEngine::DNSResolver::ResolverOptions const& /*options*/) {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
-bool PosixEventEngine::IsWorkerThread() {
- GPR_ASSERT(false && "unimplemented");
-}
+bool PosixEventEngine::IsWorkerThread() { grpc_core::Crash("unimplemented"); }
bool PosixEventEngine::CancelConnect(EventEngine::ConnectionHandle handle) {
#ifdef GRPC_POSIX_SOCKET_TCP
@@ -523,8 +522,8 @@ bool PosixEventEngine::CancelConnect(EventEngine::ConnectionHandle handle) {
}
return connection_cancel_success;
#else // GRPC_POSIX_SOCKET_TCP
- GPR_ASSERT(false &&
- "EventEngine::CancelConnect is not supported on this platform");
+ grpc_core::Crash(
+ "EventEngine::CancelConnect is not supported on this platform");
#endif // GRPC_POSIX_SOCKET_TCP
}
@@ -546,7 +545,7 @@ EventEngine::ConnectionHandle PosixEventEngine::Connect(
(*socket).mapped_target_addr,
std::move(memory_allocator), options, timeout);
#else // GRPC_POSIX_SOCKET_TCP
- GPR_ASSERT(false && "EventEngine::Connect is not supported on this platform");
+ grpc_core::Crash("EventEngine::Connect is not supported on this platform");
#endif // GRPC_POSIX_SOCKET_TCP
}
@@ -562,8 +561,8 @@ PosixEventEngine::CreateListener(
std::move(memory_allocator_factory), poller_manager_->Poller(),
shared_from_this());
#else // GRPC_POSIX_SOCKET_TCP
- GPR_ASSERT(false &&
- "EventEngine::CreateListener is not supported on this platform");
+ grpc_core::Crash(
+ "EventEngine::CreateListener is not supported on this platform");
#endif // GRPC_POSIX_SOCKET_TCP
}
diff --git a/src/core/lib/event_engine/posix_engine/posix_engine_listener.h b/src/core/lib/event_engine/posix_engine/posix_engine_listener.h
index e6c4a827f18..33a7a179011 100644
--- a/src/core/lib/event_engine/posix_engine/posix_engine_listener.h
+++ b/src/core/lib/event_engine/posix_engine/posix_engine_listener.h
@@ -203,6 +203,8 @@ class PosixEngineListener
#else // GRPC_POSIX_SOCKET_TCP
+#include "src/core/lib/gprpp/crash.h"
+
class PosixEngineListener
: public grpc_event_engine::experimental::EventEngine::Listener {
public:
@@ -210,12 +212,12 @@ class PosixEngineListener
~PosixEngineListener() override = default;
absl::StatusOr Bind(const grpc_event_engine::experimental::EventEngine::
ResolvedAddress& /*addr*/) override {
- GPR_ASSERT(false &&
- "EventEngine::Listener::Bind not supported on this platform");
+ grpc_core::Crash(
+ "EventEngine::Listener::Bind not supported on this platform");
}
absl::Status Start() override {
- GPR_ASSERT(false &&
- "EventEngine::Listener::Start not supported on this platform");
+ grpc_core::Crash(
+ "EventEngine::Listener::Start not supported on this platform");
}
};
diff --git a/src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.cc b/src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.cc
index 1b2815b9ead..ba678de0dd8 100644
--- a/src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.cc
+++ b/src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.cc
@@ -31,6 +31,7 @@
#include "src/core/lib/event_engine/posix_engine/tcp_socket_utils.h"
#include "src/core/lib/event_engine/tcp_socket_utils.h"
+#include "src/core/lib/gprpp/crash.h" // IWYU pragma: keep
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/iomgr/port.h"
#include "src/core/lib/iomgr/socket_mutator.h"
@@ -288,7 +289,7 @@ absl::StatusOr ListenerContainerAddAllLocalAddresses(
(void)listener_sockets;
(void)options;
(void)requested_port;
- GPR_ASSERT(false && "System does not support ifaddrs");
+ grpc_core::Crash("System does not support ifaddrs");
#endif
}
@@ -353,25 +354,24 @@ absl::StatusOr
CreateAndPrepareListenerSocket(const PosixTcpOptions& /*options*/,
const grpc_event_engine::experimental::
EventEngine::ResolvedAddress& /*addr*/) {
- GPR_ASSERT(
- false &&
+ grpc_core::Crash(
"CreateAndPrepareListenerSocket is not supported on this platform");
}
absl::StatusOr ListenerContainerAddWildcardAddresses(
ListenerSocketsContainer& /*listener_sockets*/,
const PosixTcpOptions& /*options*/, int /*requested_port*/) {
- GPR_ASSERT(false &&
- "ListenerContainerAddWildcardAddresses is not supported on this "
- "platform");
+ grpc_core::Crash(
+ "ListenerContainerAddWildcardAddresses is not supported on this "
+ "platform");
}
absl::StatusOr ListenerContainerAddAllLocalAddresses(
ListenerSocketsContainer& /*listener_sockets*/,
const PosixTcpOptions& /*options*/, int /*requested_port*/) {
- GPR_ASSERT(false &&
- "ListenerContainerAddAllLocalAddresses is not supported on this "
- "platform");
+ grpc_core::Crash(
+ "ListenerContainerAddAllLocalAddresses is not supported on this "
+ "platform");
}
#endif // GRPC_POSIX_SOCKET_UTILS_COMMON
diff --git a/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc b/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc
index 114fd8ed796..201a3964625 100644
--- a/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc
+++ b/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc
@@ -29,6 +29,7 @@
#include
#include "src/core/lib/gpr/useful.h"
+#include "src/core/lib/gprpp/crash.h" // IWYU pragma: keep
#include "src/core/lib/iomgr/port.h"
#ifdef GRPC_POSIX_SOCKET_UTILS_COMMON
@@ -753,31 +754,31 @@ PosixSocketWrapper::CreateAndPrepareTcpClientSocket(
#else // GRPC_POSIX_SOCKET_UTILS_COMMON
absl::StatusOr PosixSocketWrapper::SetSocketRcvLowat(int /*bytes*/) {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
absl::Status PosixSocketWrapper::SetSocketZeroCopy() {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
absl::Status PosixSocketWrapper::SetSocketNonBlocking(int /*non_blocking*/) {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
absl::Status PosixSocketWrapper::SetSocketCloexec(int /*close_on_exec*/) {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
absl::Status PosixSocketWrapper::SetSocketReuseAddr(int /*reuse*/) {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
absl::Status PosixSocketWrapper::SetSocketLowLatency(int /*low_latency*/) {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
absl::Status PosixSocketWrapper::SetSocketReusePort(int /*reuse*/) {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
void PosixSocketWrapper::ConfigureDefaultTcpUserTimeout(bool /*enable*/,
@@ -786,49 +787,49 @@ void PosixSocketWrapper::ConfigureDefaultTcpUserTimeout(bool /*enable*/,
void PosixSocketWrapper::TrySetSocketTcpUserTimeout(
const PosixTcpOptions& /*options*/, bool /*is_client*/) {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
absl::Status PosixSocketWrapper::SetSocketNoSigpipeIfPossible() {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
absl::Status PosixSocketWrapper::SetSocketIpPktInfoIfPossible() {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
absl::Status PosixSocketWrapper::SetSocketIpv6RecvPktInfoIfPossible() {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
absl::Status PosixSocketWrapper::SetSocketSndBuf(int /*buffer_size_bytes*/) {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
absl::Status PosixSocketWrapper::SetSocketRcvBuf(int /*buffer_size_bytes*/) {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
absl::Status PosixSocketWrapper::SetSocketMutator(
grpc_fd_usage /*usage*/, grpc_socket_mutator* /*mutator*/) {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
absl::Status PosixSocketWrapper::ApplySocketMutatorInOptions(
grpc_fd_usage /*usage*/, const PosixTcpOptions& /*options*/) {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
bool PosixSocketWrapper::SetSocketDualStack() {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
bool PosixSocketWrapper::IsSocketReusePortSupported() {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
bool PosixSocketWrapper::IsIpv6LoopbackAvailable() {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
absl::StatusOr PosixSocketWrapper::CreateDualStackSocket(
@@ -836,14 +837,14 @@ absl::StatusOr PosixSocketWrapper::CreateDualStackSocket(
/* socket_factory */,
const experimental::EventEngine::ResolvedAddress& /*addr*/, int /*type*/,
int /*protocol*/, DSMode& /*dsmode*/) {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
absl::StatusOr
PosixSocketWrapper::CreateAndPrepareTcpClientSocket(
const PosixTcpOptions& /*options*/,
const EventEngine::ResolvedAddress& /*target_addr*/) {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
#endif // GRPC_POSIX_SOCKET_UTILS_COMMON
diff --git a/src/core/lib/event_engine/posix_engine/traced_buffer_list.cc b/src/core/lib/event_engine/posix_engine/traced_buffer_list.cc
index e5119f0c840..947299ce1b7 100644
--- a/src/core/lib/event_engine/posix_engine/traced_buffer_list.cc
+++ b/src/core/lib/event_engine/posix_engine/traced_buffer_list.cc
@@ -316,12 +316,14 @@ void TcpSetWriteTimestampsCallback(
#else // GRPC_LINUX_ERRQUEUE
+#include "src/core/lib/gprpp/crash.h"
+
namespace grpc_event_engine {
namespace experimental {
void TcpSetWriteTimestampsCallback(
absl::AnyInvocable /*fn*/) {
- GPR_ASSERT(false && "Timestamps callback is not enabled for this platform");
+ grpc_core::Crash("Timestamps callback is not enabled for this platform");
}
} // namespace experimental
diff --git a/src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.cc b/src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.cc
index e62d412fad2..2a24d6a5d50 100644
--- a/src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.cc
+++ b/src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.cc
@@ -19,8 +19,7 @@
#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
-#include // IWYU pragma: keep
-
+#include "src/core/lib/gprpp/crash.h" // IWYU pragma: keep
#include "src/core/lib/iomgr/port.h"
#ifdef GRPC_LINUX_EVENTFD
@@ -105,13 +104,15 @@ EventFdWakeupFd::CreateEventFdWakeupFd() {
#else // GRPC_LINUX_EVENTFD
-absl::Status EventFdWakeupFd::Init() { GPR_ASSERT(false && "unimplemented"); }
+#include "src/core/lib/gprpp/crash.h"
+
+absl::Status EventFdWakeupFd::Init() { grpc_core::Crash("unimplemented"); }
absl::Status EventFdWakeupFd::ConsumeWakeup() {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
-absl::Status EventFdWakeupFd::Wakeup() { GPR_ASSERT(false && "unimplemented"); }
+absl::Status EventFdWakeupFd::Wakeup() { grpc_core::Crash("unimplemented"); }
bool EventFdWakeupFd::IsSupported() { return false; }
diff --git a/src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.cc b/src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.cc
index d26327f2a66..8901bf570a0 100644
--- a/src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.cc
+++ b/src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.cc
@@ -20,8 +20,7 @@
#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
-#include // IWYU pragma: keep
-
+#include "src/core/lib/gprpp/crash.h" // IWYU pragma: keep
#include "src/core/lib/iomgr/port.h"
#ifdef GRPC_POSIX_WAKEUP_FD
@@ -131,13 +130,13 @@ absl::StatusOr> PipeWakeupFd::CreatePipeWakeupFd() {
#else // GRPC_POSIX_WAKEUP_FD
-absl::Status PipeWakeupFd::Init() { GPR_ASSERT(false && "unimplemented"); }
+absl::Status PipeWakeupFd::Init() { grpc_core::Crash("unimplemented"); }
absl::Status PipeWakeupFd::ConsumeWakeup() {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
-absl::Status PipeWakeupFd::Wakeup() { GPR_ASSERT(false && "unimplemented"); }
+absl::Status PipeWakeupFd::Wakeup() { grpc_core::Crash("unimplemented"); }
bool PipeWakeupFd::IsSupported() { return false; }
diff --git a/src/core/lib/event_engine/windows/iocp.cc b/src/core/lib/event_engine/windows/iocp.cc
index 23fe4969eb0..b0e67ef5b37 100644
--- a/src/core/lib/event_engine/windows/iocp.cc
+++ b/src/core/lib/event_engine/windows/iocp.cc
@@ -26,6 +26,7 @@
#include "src/core/lib/event_engine/trace.h"
#include "src/core/lib/event_engine/windows/iocp.h"
#include "src/core/lib/event_engine/windows/win_socket.h"
+#include "src/core/lib/gprpp/crash.h"
namespace grpc_event_engine {
namespace experimental {
@@ -94,8 +95,8 @@ Poller::WorkResult IOCP::Work(EventEngine::Duration timeout,
if (completion_key == (ULONG_PTR)&kick_token_) {
return Poller::WorkResult::kKicked;
}
- gpr_log(GPR_ERROR, "Unknown custom completion key: %p", completion_key);
- abort();
+ grpc_core::Crash(
+ absl::StrFormat("Unknown custom completion key: %p", completion_key));
}
if (GRPC_TRACE_FLAG_ENABLED(grpc_event_engine_trace)) {
gpr_log(GPR_DEBUG, "IOCP::%p got event on OVERLAPPED::%p", this,
diff --git a/src/core/lib/event_engine/windows/windows_endpoint.cc b/src/core/lib/event_engine/windows/windows_endpoint.cc
index c77b925c96f..1c9ee4c5390 100644
--- a/src/core/lib/event_engine/windows/windows_endpoint.cc
+++ b/src/core/lib/event_engine/windows/windows_endpoint.cc
@@ -43,9 +43,9 @@ constexpr int64_t kDefaultTargetReadSize = 8192;
constexpr int kMaxWSABUFCount = 16;
void AbortOnEvent(absl::Status) {
- GPR_ASSERT(false &&
- "INTERNAL ERROR: Asked to handle read/write event with an invalid "
- "callback");
+ grpc_core::Crash(
+ "INTERNAL ERROR: Asked to handle read/write event with an invalid "
+ "callback");
}
} // namespace
@@ -63,8 +63,7 @@ WindowsEndpoint::WindowsEndpoint(
sockaddr addr;
int addr_len = sizeof(addr);
if (getsockname(socket_->socket(), &addr, &addr_len) < 0) {
- gpr_log(GPR_ERROR, "Unrecoverable error: Failed to get local socket name.");
- abort();
+ grpc_core::Crash("Unrecoverable error: Failed to get local socket name.");
}
local_address_ = EventEngine::ResolvedAddress(&addr, addr_len);
local_address_string_ = *ResolvedAddressToURI(local_address_);
diff --git a/src/core/lib/event_engine/windows/windows_engine.cc b/src/core/lib/event_engine/windows/windows_engine.cc
index 28b648848c3..ffddaf09103 100644
--- a/src/core/lib/event_engine/windows/windows_engine.cc
+++ b/src/core/lib/event_engine/windows/windows_engine.cc
@@ -32,6 +32,7 @@
#include "src/core/lib/event_engine/utils.h"
#include "src/core/lib/event_engine/windows/iocp.h"
#include "src/core/lib/event_engine/windows/windows_engine.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/sync.h"
#include "src/core/lib/gprpp/time.h"
@@ -133,22 +134,20 @@ EventEngine::TaskHandle WindowsEventEngine::RunAfterInternal(
std::unique_ptr WindowsEventEngine::GetDNSResolver(
EventEngine::DNSResolver::ResolverOptions const& /*options*/) {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
-bool WindowsEventEngine::IsWorkerThread() {
- GPR_ASSERT(false && "unimplemented");
-}
+bool WindowsEventEngine::IsWorkerThread() { grpc_core::Crash("unimplemented"); }
bool WindowsEventEngine::CancelConnect(EventEngine::ConnectionHandle handle) {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
EventEngine::ConnectionHandle WindowsEventEngine::Connect(
OnConnectCallback on_connect, const ResolvedAddress& addr,
const EndpointConfig& args, MemoryAllocator memory_allocator,
Duration deadline) {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
absl::StatusOr>
@@ -157,7 +156,7 @@ WindowsEventEngine::CreateListener(
absl::AnyInvocable on_shutdown,
const EndpointConfig& config,
std::unique_ptr memory_allocator_factory) {
- GPR_ASSERT(false && "unimplemented");
+ grpc_core::Crash("unimplemented");
}
} // namespace experimental
diff --git a/src/core/lib/gpr/alloc.cc b/src/core/lib/gpr/alloc.cc
index e7d94541e9f..7d0f7eb36d5 100644
--- a/src/core/lib/gpr/alloc.cc
+++ b/src/core/lib/gpr/alloc.cc
@@ -24,6 +24,8 @@
#include
#include
+#include "src/core/lib/gprpp/crash.h"
+
void* gpr_malloc(size_t size) {
void* p;
if (size == 0) return nullptr;
diff --git a/src/core/lib/gpr/cpu_linux.cc b/src/core/lib/gpr/cpu_linux.cc
index eee30a8112c..670ca6551c1 100644
--- a/src/core/lib/gpr/cpu_linux.cc
+++ b/src/core/lib/gpr/cpu_linux.cc
@@ -33,6 +33,7 @@
#include
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/strerror.h"
static int ncpus = 0;
diff --git a/src/core/lib/gpr/cpu_posix.cc b/src/core/lib/gpr/cpu_posix.cc
index f1b23f2d554..4b58d869f68 100644
--- a/src/core/lib/gpr/cpu_posix.cc
+++ b/src/core/lib/gpr/cpu_posix.cc
@@ -30,6 +30,7 @@
#include
#include "src/core/lib/gpr/useful.h"
+#include "src/core/lib/gprpp/crash.h"
static long ncpus = 0;
diff --git a/src/core/lib/gpr/cpu_windows.cc b/src/core/lib/gpr/cpu_windows.cc
index d31b379ada7..94af1e419c6 100644
--- a/src/core/lib/gpr/cpu_windows.cc
+++ b/src/core/lib/gpr/cpu_windows.cc
@@ -22,6 +22,8 @@
#include
#include
+#include "src/core/lib/gprpp/crash.h"
+
unsigned gpr_cpu_num_cores(void) {
SYSTEM_INFO si;
GetSystemInfo(&si);
diff --git a/src/core/lib/gpr/log.cc b/src/core/lib/gpr/log.cc
index 3e151a7337f..d290b95ad0d 100644
--- a/src/core/lib/gpr/log.cc
+++ b/src/core/lib/gpr/log.cc
@@ -21,11 +21,14 @@
#include
#include
+#include "absl/strings/str_cat.h"
+
#include
#include
#include
#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/global_config.h"
#ifndef GPR_DEFAULT_LOG_VERBOSITY_STRING
@@ -48,8 +51,13 @@ static gpr_atm g_min_severity_to_print = GPR_LOG_SEVERITY_UNSET;
static gpr_atm g_min_severity_to_print_stacktrace = GPR_LOG_SEVERITY_UNSET;
void gpr_unreachable_code(const char* reason, const char* file, int line) {
- gpr_log(file, line, GPR_LOG_SEVERITY_ERROR, "UNREACHABLE CODE: %s", reason);
- abort();
+ grpc_core::Crash(absl::StrCat("UNREACHABLE CODE: ", reason),
+ grpc_core::SourceLocation(file, line));
+}
+
+void gpr_assertion_failed(const char* filename, int line, const char* message) {
+ grpc_core::Crash(absl::StrCat("ASSERTION FAILED: ", message),
+ grpc_core::SourceLocation(filename, line));
}
const char* gpr_log_severity_string(gpr_log_severity severity) {
diff --git a/src/core/lib/gpr/log_android.cc b/src/core/lib/gpr/log_android.cc
index 38b84d7bcbb..92d17115361 100644
--- a/src/core/lib/gpr/log_android.cc
+++ b/src/core/lib/gpr/log_android.cc
@@ -28,6 +28,8 @@
#include
#include
+#include "src/core/lib/gprpp/crash.h"
+
static android_LogPriority severity_to_log_priority(gpr_log_severity severity) {
switch (severity) {
case GPR_LOG_SEVERITY_DEBUG:
diff --git a/src/core/lib/gpr/log_linux.cc b/src/core/lib/gpr/log_linux.cc
index e5f8c871544..7a597f3bb59 100644
--- a/src/core/lib/gpr/log_linux.cc
+++ b/src/core/lib/gpr/log_linux.cc
@@ -44,6 +44,7 @@
#include
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/examine_stack.h"
int gpr_should_log_stacktrace(gpr_log_severity severity);
diff --git a/src/core/lib/gpr/log_posix.cc b/src/core/lib/gpr/log_posix.cc
index 3f9e1e23677..18088486118 100644
--- a/src/core/lib/gpr/log_posix.cc
+++ b/src/core/lib/gpr/log_posix.cc
@@ -35,6 +35,7 @@
#include
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/examine_stack.h"
int gpr_should_log_stacktrace(gpr_log_severity severity);
diff --git a/src/core/lib/gpr/log_windows.cc b/src/core/lib/gpr/log_windows.cc
index 145186d2fe6..fe249e31c15 100644
--- a/src/core/lib/gpr/log_windows.cc
+++ b/src/core/lib/gpr/log_windows.cc
@@ -30,6 +30,7 @@
#include
#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/examine_stack.h"
int gpr_should_log_stacktrace(gpr_log_severity severity);
diff --git a/src/core/lib/gpr/string.cc b/src/core/lib/gpr/string.cc
index d4e662d4d38..4d23c89c78b 100644
--- a/src/core/lib/gpr/string.cc
+++ b/src/core/lib/gpr/string.cc
@@ -35,6 +35,7 @@
#include
#include "src/core/lib/gpr/useful.h"
+#include "src/core/lib/gprpp/crash.h"
char* gpr_strdup(const char* src) {
char* dst;
diff --git a/src/core/lib/gpr/sync_abseil.cc b/src/core/lib/gpr/sync_abseil.cc
index 1c0a2950acc..85fb6cbd354 100644
--- a/src/core/lib/gpr/sync_abseil.cc
+++ b/src/core/lib/gpr/sync_abseil.cc
@@ -33,6 +33,8 @@
#include
#include
+#include "src/core/lib/gprpp/crash.h"
+
void gpr_mu_init(gpr_mu* mu) {
static_assert(sizeof(gpr_mu) == sizeof(absl::Mutex),
"gpr_mu and Mutex must be the same size");
diff --git a/src/core/lib/gpr/sync_posix.cc b/src/core/lib/gpr/sync_posix.cc
index e5ebf453185..c3cf035ba4d 100644
--- a/src/core/lib/gpr/sync_posix.cc
+++ b/src/core/lib/gpr/sync_posix.cc
@@ -29,6 +29,8 @@
#include
#include
+#include "src/core/lib/gprpp/crash.h"
+
void gpr_mu_init(gpr_mu* mu) {
#ifdef GRPC_ASAN_ENABLED
GPR_ASSERT(pthread_mutex_init(&mu->mutex, nullptr) == 0);
diff --git a/src/core/lib/gpr/sync_windows.cc b/src/core/lib/gpr/sync_windows.cc
index cb24ad73c7f..f06c73efb04 100644
--- a/src/core/lib/gpr/sync_windows.cc
+++ b/src/core/lib/gpr/sync_windows.cc
@@ -27,6 +27,8 @@
#include
#include
+#include "src/core/lib/gprpp/crash.h"
+
void gpr_mu_init(gpr_mu* mu) {
InitializeCriticalSection(&mu->cs);
mu->locked = 0;
diff --git a/src/core/lib/gpr/time.cc b/src/core/lib/gpr/time.cc
index 3390e5c9be4..472cd204e11 100644
--- a/src/core/lib/gpr/time.cc
+++ b/src/core/lib/gpr/time.cc
@@ -27,6 +27,8 @@
#include
#include
+#include "src/core/lib/gprpp/crash.h"
+
int gpr_time_cmp(gpr_timespec a, gpr_timespec b) {
int cmp = (a.tv_sec > b.tv_sec) - (a.tv_sec < b.tv_sec);
GPR_ASSERT(a.clock_type == b.clock_type);
diff --git a/src/core/lib/gpr/time_posix.cc b/src/core/lib/gpr/time_posix.cc
index 9741ab7d508..bc4b9be2218 100644
--- a/src/core/lib/gpr/time_posix.cc
+++ b/src/core/lib/gpr/time_posix.cc
@@ -32,6 +32,8 @@
#include
#include
+#include "src/core/lib/gprpp/crash.h"
+
static struct timespec timespec_from_gpr(gpr_timespec gts) {
struct timespec rv;
if (sizeof(time_t) < sizeof(int64_t)) {
diff --git a/src/core/lib/gpr/time_precise.cc b/src/core/lib/gpr/time_precise.cc
index e2cd07fab5d..46efc61722e 100644
--- a/src/core/lib/gpr/time_precise.cc
+++ b/src/core/lib/gpr/time_precise.cc
@@ -29,6 +29,7 @@
#include
#include "src/core/lib/gpr/time_precise.h"
+#include "src/core/lib/gprpp/crash.h"
#ifndef GPR_CYCLE_COUNTER_CUSTOM
#if GPR_CYCLE_COUNTER_RDTSC_32 || GPR_CYCLE_COUNTER_RDTSC_64
diff --git a/src/core/lib/gpr/time_windows.cc b/src/core/lib/gpr/time_windows.cc
index 77bcbe8f2e4..52b23c421d8 100644
--- a/src/core/lib/gpr/time_windows.cc
+++ b/src/core/lib/gpr/time_windows.cc
@@ -30,6 +30,7 @@
#include
#include "src/core/lib/gpr/time_precise.h"
+#include "src/core/lib/gprpp/crash.h"
static LARGE_INTEGER g_start_time = []() {
LARGE_INTEGER x;
diff --git a/src/core/lib/gpr/tmpfile_msys.cc b/src/core/lib/gpr/tmpfile_msys.cc
index f77cbda2d75..42372a5ce65 100644
--- a/src/core/lib/gpr/tmpfile_msys.cc
+++ b/src/core/lib/gpr/tmpfile_msys.cc
@@ -31,6 +31,7 @@
#include "src/core/lib/gpr/string_windows.h"
#include "src/core/lib/gpr/tmpfile.h"
+#include "src/core/lib/gprpp/crash.h"
FILE* gpr_tmpfile(const char* prefix, char** tmp_filename_out) {
FILE* result = NULL;
diff --git a/src/core/lib/gpr/tmpfile_posix.cc b/src/core/lib/gpr/tmpfile_posix.cc
index 7eceb779922..4d838af72bc 100644
--- a/src/core/lib/gpr/tmpfile_posix.cc
+++ b/src/core/lib/gpr/tmpfile_posix.cc
@@ -31,6 +31,7 @@
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/gpr/tmpfile.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/strerror.h"
FILE* gpr_tmpfile(const char* prefix, char** tmp_filename) {
diff --git a/src/core/lib/gpr/tmpfile_windows.cc b/src/core/lib/gpr/tmpfile_windows.cc
index 6f63991976d..37ac4f64bcb 100644
--- a/src/core/lib/gpr/tmpfile_windows.cc
+++ b/src/core/lib/gpr/tmpfile_windows.cc
@@ -30,6 +30,7 @@
#include
#include "src/core/lib/gpr/tmpfile.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/tchar.h"
FILE* gpr_tmpfile(const char* prefix, char** tmp_filename_out) {
diff --git a/src/core/lib/gprpp/crash.cc b/src/core/lib/gprpp/crash.cc
new file mode 100644
index 00000000000..e287359d6ce
--- /dev/null
+++ b/src/core/lib/gprpp/crash.cc
@@ -0,0 +1,33 @@
+// Copyright 2022 gRPC authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include
+
+#include "src/core/lib/gprpp/crash.h"
+
+#include
+
+#include
+
+#include
+
+namespace grpc_core {
+
+void Crash(absl::string_view message, SourceLocation location) {
+ gpr_log(location.file(), location.line(), GPR_LOG_SEVERITY_ERROR, "%s",
+ std::string(message).c_str());
+ abort();
+}
+
+} // namespace grpc_core
diff --git a/src/core/lib/gprpp/crash.h b/src/core/lib/gprpp/crash.h
new file mode 100644
index 00000000000..f2998ba291e
--- /dev/null
+++ b/src/core/lib/gprpp/crash.h
@@ -0,0 +1,34 @@
+// Copyright 2022 gRPC authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef GRPC_CORE_LIB_GPRPP_CRASH_H
+#define GRPC_CORE_LIB_GPRPP_CRASH_H
+
+#include
+
+#include "absl/strings/string_view.h"
+
+#include "src/core/lib/gprpp/debug_location.h"
+
+namespace grpc_core {
+
+// Crash the program after printing `message`.
+// ::grpc_core:: prefix to SourceLocation is required to work around a symbol
+// mismatch bug on MSVC.
+[[noreturn]] void Crash(absl::string_view message,
+ ::grpc_core::SourceLocation location = {});
+
+} // namespace grpc_core
+
+#endif // GRPC_CORE_LIB_GPRPP_CRASH_H
diff --git a/src/core/lib/gprpp/stat_windows.cc b/src/core/lib/gprpp/stat_windows.cc
index ce7ff315769..20fc4335566 100644
--- a/src/core/lib/gprpp/stat_windows.cc
+++ b/src/core/lib/gprpp/stat_windows.cc
@@ -24,6 +24,7 @@
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/stat.h"
#include "src/core/lib/gprpp/strerror.h"
diff --git a/src/core/lib/gprpp/thd_windows.cc b/src/core/lib/gprpp/thd_windows.cc
index 37784a60d53..8bd310ff359 100644
--- a/src/core/lib/gprpp/thd_windows.cc
+++ b/src/core/lib/gprpp/thd_windows.cc
@@ -30,6 +30,7 @@
#include
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/memory.h"
#include "src/core/lib/gprpp/thd.h"
diff --git a/src/core/lib/iomgr/buffer_list.cc b/src/core/lib/iomgr/buffer_list.cc
index 8da4c645752..11ebc9cc773 100644
--- a/src/core/lib/iomgr/buffer_list.cc
+++ b/src/core/lib/iomgr/buffer_list.cc
@@ -23,6 +23,7 @@
#include
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/sync.h"
#include "src/core/lib/iomgr/port.h"
diff --git a/src/core/lib/iomgr/call_combiner.cc b/src/core/lib/iomgr/call_combiner.cc
index 7b3dcfcf9c0..2b2996c2c4f 100644
--- a/src/core/lib/iomgr/call_combiner.cc
+++ b/src/core/lib/iomgr/call_combiner.cc
@@ -26,6 +26,7 @@
#include "src/core/lib/debug/stats.h"
#include "src/core/lib/debug/stats_data.h"
+#include "src/core/lib/gprpp/crash.h"
namespace grpc_core {
diff --git a/src/core/lib/iomgr/closure.h b/src/core/lib/iomgr/closure.h
index 04c45487c6d..54aaaac15f3 100644
--- a/src/core/lib/iomgr/closure.h
+++ b/src/core/lib/iomgr/closure.h
@@ -27,6 +27,7 @@
#include
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/debug_location.h"
#include "src/core/lib/gprpp/manual_constructor.h"
#include "src/core/lib/gprpp/mpscq.h"
diff --git a/src/core/lib/iomgr/combiner.cc b/src/core/lib/iomgr/combiner.cc
index 5c3b3b1bc86..1601802d1f8 100644
--- a/src/core/lib/iomgr/combiner.cc
+++ b/src/core/lib/iomgr/combiner.cc
@@ -27,6 +27,7 @@
#include
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/mpscq.h"
#include "src/core/lib/iomgr/executor.h"
#include "src/core/lib/iomgr/iomgr_internal.h"
diff --git a/src/core/lib/iomgr/endpoint_pair_posix.cc b/src/core/lib/iomgr/endpoint_pair_posix.cc
index 41b9d2ac299..754bd350cc3 100644
--- a/src/core/lib/iomgr/endpoint_pair_posix.cc
+++ b/src/core/lib/iomgr/endpoint_pair_posix.cc
@@ -37,6 +37,7 @@
#include "src/core/lib/event_engine/channel_args_endpoint_config.h"
#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/iomgr/endpoint_pair.h"
#include "src/core/lib/iomgr/socket_utils_posix.h"
#include "src/core/lib/iomgr/tcp_posix.h"
diff --git a/src/core/lib/iomgr/endpoint_pair_windows.cc b/src/core/lib/iomgr/endpoint_pair_windows.cc
index 8ebfff1c53a..e6f1db7a6b8 100644
--- a/src/core/lib/iomgr/endpoint_pair_windows.cc
+++ b/src/core/lib/iomgr/endpoint_pair_windows.cc
@@ -28,6 +28,7 @@
#include
#include "src/core/lib/address_utils/sockaddr_utils.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/iomgr/endpoint_pair.h"
#include "src/core/lib/iomgr/sockaddr.h"
#include "src/core/lib/iomgr/socket_windows.h"
diff --git a/src/core/lib/iomgr/error.cc b/src/core/lib/iomgr/error.cc
index f43809dccc2..c11c56f2ea7 100644
--- a/src/core/lib/iomgr/error.cc
+++ b/src/core/lib/iomgr/error.cc
@@ -29,6 +29,8 @@
#include
#include
+#include "src/core/lib/gprpp/crash.h"
+
#ifdef GPR_WINDOWS
#include
#endif
diff --git a/src/core/lib/iomgr/error.h b/src/core/lib/iomgr/error.h
index 5502689948b..1b5d4930c09 100644
--- a/src/core/lib/iomgr/error.h
+++ b/src/core/lib/iomgr/error.h
@@ -33,6 +33,7 @@
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/gpr/spinlock.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/slice/slice_internal.h"
diff --git a/src/core/lib/iomgr/ev_epoll1_linux.cc b/src/core/lib/iomgr/ev_epoll1_linux.cc
index b616793e1f3..83b379552af 100644
--- a/src/core/lib/iomgr/ev_epoll1_linux.cc
+++ b/src/core/lib/iomgr/ev_epoll1_linux.cc
@@ -20,6 +20,7 @@
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/iomgr/port.h"
// This polling engine is only relevant on linux kernels supporting epoll
diff --git a/src/core/lib/iomgr/ev_poll_posix.cc b/src/core/lib/iomgr/ev_poll_posix.cc
index 7304b082825..21d9f8ce284 100644
--- a/src/core/lib/iomgr/ev_poll_posix.cc
+++ b/src/core/lib/iomgr/ev_poll_posix.cc
@@ -35,6 +35,7 @@
#include
#include "absl/strings/str_cat.h"
+#include "absl/strings/str_format.h"
#include
#include
@@ -42,6 +43,7 @@
#include "src/core/lib/debug/stats.h"
#include "src/core/lib/debug/stats_data.h"
#include "src/core/lib/gpr/useful.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/thd.h"
#include "src/core/lib/iomgr/block_annotate.h"
#include "src/core/lib/iomgr/ev_poll_posix.h"
@@ -521,10 +523,9 @@ static void notify_on_locked(grpc_fd* fd, grpc_closure** st,
maybe_wake_one_watcher_locked(fd);
} else {
// upcallptr was set to a different closure. This is an error!
- gpr_log(GPR_ERROR,
- "User called a notify_on function with a previous callback still "
- "pending");
- abort();
+ grpc_core::Crash(
+ "User called a notify_on function with a previous callback still "
+ "pending");
}
}
@@ -1426,8 +1427,7 @@ int phony_poll(struct pollfd fds[], nfds_t nfds, int timeout) {
if (timeout == 0) {
return real_poll_function(fds, nfds, 0);
} else {
- gpr_log(GPR_ERROR, "Attempted a blocking poll when declared non-polling.");
- GPR_ASSERT(false);
+ grpc_core::Crash("Attempted a blocking poll when declared non-polling.");
return -1;
}
}
diff --git a/src/core/lib/iomgr/ev_posix.cc b/src/core/lib/iomgr/ev_posix.cc
index 9ffff74059b..afa76299700 100644
--- a/src/core/lib/iomgr/ev_posix.cc
+++ b/src/core/lib/iomgr/ev_posix.cc
@@ -26,12 +26,15 @@
#include
+#include "absl/strings/str_format.h"
+
#include
#include
#include
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/gpr/useful.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/global_config.h"
#include "src/core/lib/iomgr/ev_epoll1_linux.h"
#include "src/core/lib/iomgr/ev_poll_posix.h"
@@ -187,9 +190,8 @@ void grpc_event_engine_init(void) {
gpr_free(strings);
if (g_event_engine == nullptr) {
- gpr_log(GPR_ERROR, "No event engine could be initialized from %s",
- value.get());
- abort();
+ grpc_core::Crash(absl::StrFormat(
+ "No event engine could be initialized from %s", value.get()));
}
});
g_event_engine->init_engine();
diff --git a/src/core/lib/iomgr/exec_ctx.cc b/src/core/lib/iomgr/exec_ctx.cc
index 2d7805896b1..65cd319d20c 100644
--- a/src/core/lib/iomgr/exec_ctx.cc
+++ b/src/core/lib/iomgr/exec_ctx.cc
@@ -20,9 +20,12 @@
#include "src/core/lib/iomgr/exec_ctx.h"
+#include "absl/strings/str_format.h"
+
#include
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/iomgr/combiner.h"
#include "src/core/lib/iomgr/error.h"
@@ -85,13 +88,12 @@ void ExecCtx::Run(const DebugLocation& location, grpc_closure* closure,
}
#ifndef NDEBUG
if (closure->scheduled) {
- gpr_log(GPR_ERROR,
- "Closure already scheduled. (closure: %p, created: [%s:%d], "
- "previously scheduled at: [%s: %d], newly scheduled at [%s: %d]",
- closure, closure->file_created, closure->line_created,
- closure->file_initiated, closure->line_initiated, location.file(),
- location.line());
- abort();
+ Crash(absl::StrFormat(
+ "Closure already scheduled. (closure: %p, created: [%s:%d], "
+ "previously scheduled at: [%s: %d], newly scheduled at [%s: %d]",
+ closure, closure->file_created, closure->line_created,
+ closure->file_initiated, closure->line_initiated, location.file(),
+ location.line()));
}
closure->scheduled = true;
closure->file_initiated = location.file();
@@ -110,12 +112,11 @@ void ExecCtx::RunList(const DebugLocation& location, grpc_closure_list* list) {
grpc_closure* next = c->next_data.next;
#ifndef NDEBUG
if (c->scheduled) {
- gpr_log(GPR_ERROR,
- "Closure already scheduled. (closure: %p, created: [%s:%d], "
- "previously scheduled at: [%s: %d], newly scheduled at [%s:%d]",
- c, c->file_created, c->line_created, c->file_initiated,
- c->line_initiated, location.file(), location.line());
- abort();
+ Crash(absl::StrFormat(
+ "Closure already scheduled. (closure: %p, created: [%s:%d], "
+ "previously scheduled at: [%s: %d], newly scheduled at [%s:%d]",
+ c, c->file_created, c->line_created, c->file_initiated,
+ c->line_initiated, location.file(), location.line()));
}
c->scheduled = true;
c->file_initiated = location.file();
diff --git a/src/core/lib/iomgr/exec_ctx.h b/src/core/lib/iomgr/exec_ctx.h
index 2813e8150fe..3d3f7004862 100644
--- a/src/core/lib/iomgr/exec_ctx.h
+++ b/src/core/lib/iomgr/exec_ctx.h
@@ -30,6 +30,7 @@
#include
#include "src/core/lib/gpr/time_precise.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/debug_location.h"
#include "src/core/lib/gprpp/fork.h"
#include "src/core/lib/gprpp/time.h"
diff --git a/src/core/lib/iomgr/executor.cc b/src/core/lib/iomgr/executor.cc
index 73dcbeb7c7e..c65475e1041 100644
--- a/src/core/lib/iomgr/executor.cc
+++ b/src/core/lib/iomgr/executor.cc
@@ -28,6 +28,7 @@
#include
#include "src/core/lib/gpr/useful.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/memory.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/iomgr/iomgr_internal.h"
diff --git a/src/core/lib/iomgr/fork_posix.cc b/src/core/lib/iomgr/fork_posix.cc
index b308d5cdcb1..07e48e3ba27 100644
--- a/src/core/lib/iomgr/fork_posix.cc
+++ b/src/core/lib/iomgr/fork_posix.cc
@@ -32,6 +32,7 @@
#include
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/fork.h"
#include "src/core/lib/gprpp/thd.h"
#include "src/core/lib/iomgr/ev_posix.h"
diff --git a/src/core/lib/iomgr/grpc_if_nametoindex_posix.cc b/src/core/lib/iomgr/grpc_if_nametoindex_posix.cc
index a5ca75bddfe..fe1ada03592 100644
--- a/src/core/lib/iomgr/grpc_if_nametoindex_posix.cc
+++ b/src/core/lib/iomgr/grpc_if_nametoindex_posix.cc
@@ -27,6 +27,7 @@
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/iomgr/grpc_if_nametoindex.h"
uint32_t grpc_if_nametoindex(char* name) {
diff --git a/src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc b/src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc
index 06bfe207f9e..5555cad6d1b 100644
--- a/src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc
+++ b/src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc
@@ -24,6 +24,7 @@
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/iomgr/grpc_if_nametoindex.h"
uint32_t grpc_if_nametoindex(char* name) {
diff --git a/src/core/lib/iomgr/iocp_windows.cc b/src/core/lib/iomgr/iocp_windows.cc
index 70eccba9fd4..2d0c5eb41dd 100644
--- a/src/core/lib/iomgr/iocp_windows.cc
+++ b/src/core/lib/iomgr/iocp_windows.cc
@@ -32,6 +32,7 @@
#include "src/core/lib/debug/stats.h"
#include "src/core/lib/debug/stats_data.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/thd.h"
#include "src/core/lib/iomgr/iocp_windows.h"
#include "src/core/lib/iomgr/iomgr_internal.h"
@@ -78,8 +79,7 @@ grpc_iocp_work_status grpc_iocp_work(grpc_core::Timestamp deadline) {
// We were awoken from a kick.
return GRPC_IOCP_WORK_KICK;
}
- gpr_log(GPR_ERROR, "Unknown custom completion key.");
- abort();
+ grpc_core::Crash("Unknown custom completion key.");
}
socket = (grpc_winsocket*)completion_key;
diff --git a/src/core/lib/iomgr/iomgr.cc b/src/core/lib/iomgr/iomgr.cc
index 99508dd3899..08c51cdd653 100644
--- a/src/core/lib/iomgr/iomgr.cc
+++ b/src/core/lib/iomgr/iomgr.cc
@@ -31,6 +31,7 @@
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/gpr/useful.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/global_config.h"
#include "src/core/lib/gprpp/thd.h"
#include "src/core/lib/iomgr/buffer_list.h"
diff --git a/src/core/lib/iomgr/iomgr_windows.cc b/src/core/lib/iomgr/iomgr_windows.cc
index bd8db0e0301..b3a4a741072 100644
--- a/src/core/lib/iomgr/iomgr_windows.cc
+++ b/src/core/lib/iomgr/iomgr_windows.cc
@@ -24,6 +24,7 @@
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/iomgr/iocp_windows.h"
#include "src/core/lib/iomgr/iomgr.h"
#include "src/core/lib/iomgr/pollset_windows.h"
diff --git a/src/core/lib/iomgr/load_file.cc b/src/core/lib/iomgr/load_file.cc
index 01538804f57..8a6ac72a818 100644
--- a/src/core/lib/iomgr/load_file.cc
+++ b/src/core/lib/iomgr/load_file.cc
@@ -28,6 +28,7 @@
#include
#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/iomgr/block_annotate.h"
grpc_error_handle grpc_load_file(const char* filename, int add_null_terminator,
diff --git a/src/core/lib/iomgr/lockfree_event.cc b/src/core/lib/iomgr/lockfree_event.cc
index 62d994a3c6b..58130a34cb5 100644
--- a/src/core/lib/iomgr/lockfree_event.cc
+++ b/src/core/lib/iomgr/lockfree_event.cc
@@ -23,6 +23,7 @@
#include
#include "src/core/lib/debug/trace.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/iomgr/exec_ctx.h"
extern grpc_core::DebugOnlyTraceFlag grpc_polling_trace;
@@ -148,10 +149,9 @@ void LockfreeEvent::NotifyOn(grpc_closure* closure) {
}
// There is already a closure!. This indicates a bug in the code
- gpr_log(GPR_ERROR,
- "LockfreeEvent::NotifyOn: notify_on called with a previous "
- "callback still pending");
- abort();
+ Crash(
+ "LockfreeEvent::NotifyOn: notify_on called with a previous "
+ "callback still pending");
}
}
}
diff --git a/src/core/lib/iomgr/polling_entity.cc b/src/core/lib/iomgr/polling_entity.cc
index 445f26606d0..5df50e1ce41 100644
--- a/src/core/lib/iomgr/polling_entity.cc
+++ b/src/core/lib/iomgr/polling_entity.cc
@@ -20,9 +20,13 @@
#include "src/core/lib/iomgr/polling_entity.h"
+#include "absl/strings/str_format.h"
+
#include
#include
+#include "src/core/lib/gprpp/crash.h"
+
grpc_polling_entity grpc_polling_entity_create_from_pollset_set(
grpc_pollset_set* pollset_set) {
grpc_polling_entity pollent;
@@ -70,8 +74,8 @@ void grpc_polling_entity_add_to_pollset_set(grpc_polling_entity* pollent,
GPR_ASSERT(pollent->pollent.pollset_set != nullptr);
grpc_pollset_set_add_pollset_set(pss_dst, pollent->pollent.pollset_set);
} else {
- gpr_log(GPR_ERROR, "Invalid grpc_polling_entity tag '%d'", pollent->tag);
- abort();
+ grpc_core::Crash(
+ absl::StrFormat("Invalid grpc_polling_entity tag '%d'", pollent->tag));
}
}
@@ -90,7 +94,7 @@ void grpc_polling_entity_del_from_pollset_set(grpc_polling_entity* pollent,
GPR_ASSERT(pollent->pollent.pollset_set != nullptr);
grpc_pollset_set_del_pollset_set(pss_dst, pollent->pollent.pollset_set);
} else {
- gpr_log(GPR_ERROR, "Invalid grpc_polling_entity tag '%d'", pollent->tag);
- abort();
+ grpc_core::Crash(
+ absl::StrFormat("Invalid grpc_polling_entity tag '%d'", pollent->tag));
}
}
diff --git a/src/core/lib/iomgr/pollset_windows.cc b/src/core/lib/iomgr/pollset_windows.cc
index 447e3857812..e4091bfe917 100644
--- a/src/core/lib/iomgr/pollset_windows.cc
+++ b/src/core/lib/iomgr/pollset_windows.cc
@@ -24,6 +24,7 @@
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/thd.h"
#include "src/core/lib/iomgr/iocp_windows.h"
#include "src/core/lib/iomgr/iomgr_internal.h"
diff --git a/src/core/lib/iomgr/resolve_address.cc b/src/core/lib/iomgr/resolve_address.cc
index eb040249c36..084fdd96233 100644
--- a/src/core/lib/iomgr/resolve_address.cc
+++ b/src/core/lib/iomgr/resolve_address.cc
@@ -25,6 +25,7 @@
#include
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/no_destruct.h"
namespace grpc_core {
diff --git a/src/core/lib/iomgr/resolve_address_posix.cc b/src/core/lib/iomgr/resolve_address_posix.cc
index 9d7f5374c83..ee5f9092b9e 100644
--- a/src/core/lib/iomgr/resolve_address_posix.cc
+++ b/src/core/lib/iomgr/resolve_address_posix.cc
@@ -32,6 +32,7 @@
#include "src/core/lib/event_engine/default_event_engine.h"
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/gpr/useful.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/host_port.h"
#include "src/core/lib/gprpp/thd.h"
#include "src/core/lib/iomgr/block_annotate.h"
diff --git a/src/core/lib/iomgr/resolve_address_windows.cc b/src/core/lib/iomgr/resolve_address_windows.cc
index 19467f1903f..bb5b78de1c8 100644
--- a/src/core/lib/iomgr/resolve_address_windows.cc
+++ b/src/core/lib/iomgr/resolve_address_windows.cc
@@ -36,6 +36,7 @@
#include "src/core/lib/address_utils/sockaddr_utils.h"
#include "src/core/lib/event_engine/default_event_engine.h"
#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/host_port.h"
#include "src/core/lib/gprpp/thd.h"
#include "src/core/lib/iomgr/block_annotate.h"
diff --git a/src/core/lib/iomgr/sockaddr_utils_posix.cc b/src/core/lib/iomgr/sockaddr_utils_posix.cc
index 4fed986316b..f0535f45acf 100644
--- a/src/core/lib/iomgr/sockaddr_utils_posix.cc
+++ b/src/core/lib/iomgr/sockaddr_utils_posix.cc
@@ -41,6 +41,7 @@
#include
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/iomgr/sockaddr.h"
uint16_t grpc_htons(uint16_t hostshort) { return htons(hostshort); }
diff --git a/src/core/lib/iomgr/socket_mutator.cc b/src/core/lib/iomgr/socket_mutator.cc
index d0ba2887d53..789d98bafb3 100644
--- a/src/core/lib/iomgr/socket_mutator.cc
+++ b/src/core/lib/iomgr/socket_mutator.cc
@@ -26,6 +26,7 @@
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/gpr/useful.h"
+#include "src/core/lib/gprpp/crash.h"
void grpc_socket_mutator_init(grpc_socket_mutator* mutator,
const grpc_socket_mutator_vtable* vtable) {
diff --git a/src/core/lib/iomgr/socket_utils_common_posix.cc b/src/core/lib/iomgr/socket_utils_common_posix.cc
index eff77511a38..df5d9f05a11 100644
--- a/src/core/lib/iomgr/socket_utils_common_posix.cc
+++ b/src/core/lib/iomgr/socket_utils_common_posix.cc
@@ -50,6 +50,7 @@
#include "src/core/lib/address_utils/sockaddr_utils.h"
#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/strerror.h"
#include "src/core/lib/iomgr/sockaddr.h"
diff --git a/src/core/lib/iomgr/socket_utils_linux.cc b/src/core/lib/iomgr/socket_utils_linux.cc
index 64fd83e0514..2e64c21e0b5 100644
--- a/src/core/lib/iomgr/socket_utils_linux.cc
+++ b/src/core/lib/iomgr/socket_utils_linux.cc
@@ -27,6 +27,7 @@
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/iomgr/sockaddr.h"
#include "src/core/lib/iomgr/socket_utils_posix.h"
diff --git a/src/core/lib/iomgr/socket_utils_posix.cc b/src/core/lib/iomgr/socket_utils_posix.cc
index c4a9361d3ea..bd81dd76a2c 100644
--- a/src/core/lib/iomgr/socket_utils_posix.cc
+++ b/src/core/lib/iomgr/socket_utils_posix.cc
@@ -30,6 +30,7 @@
#include
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/iomgr/sockaddr.h"
#include "src/core/lib/iomgr/socket_utils_posix.h"
#endif
diff --git a/src/core/lib/iomgr/socket_utils_windows.cc b/src/core/lib/iomgr/socket_utils_windows.cc
index 71b95e915ac..8b0e8f45f7c 100644
--- a/src/core/lib/iomgr/socket_utils_windows.cc
+++ b/src/core/lib/iomgr/socket_utils_windows.cc
@@ -24,6 +24,7 @@
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/iomgr/sockaddr.h"
#include "src/core/lib/iomgr/socket_utils.h"
diff --git a/src/core/lib/iomgr/socket_windows.cc b/src/core/lib/iomgr/socket_windows.cc
index ba3eb1d0aee..0865f1afd2e 100644
--- a/src/core/lib/iomgr/socket_windows.cc
+++ b/src/core/lib/iomgr/socket_windows.cc
@@ -33,6 +33,7 @@
#include
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/iomgr/iocp_windows.h"
#include "src/core/lib/iomgr/iomgr_internal.h"
#include "src/core/lib/iomgr/pollset.h"
diff --git a/src/core/lib/iomgr/tcp_client_cfstream.cc b/src/core/lib/iomgr/tcp_client_cfstream.cc
index 1ea3dc481b2..7be3637ac42 100644
--- a/src/core/lib/iomgr/tcp_client_cfstream.cc
+++ b/src/core/lib/iomgr/tcp_client_cfstream.cc
@@ -33,6 +33,7 @@
#include
#include "src/core/lib/address_utils/sockaddr_utils.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/host_port.h"
#include "src/core/lib/iomgr/cfstream_handle.h"
#include "src/core/lib/iomgr/closure.h"
diff --git a/src/core/lib/iomgr/tcp_client_posix.cc b/src/core/lib/iomgr/tcp_client_posix.cc
index bc8b1692613..96ccdf298cd 100644
--- a/src/core/lib/iomgr/tcp_client_posix.cc
+++ b/src/core/lib/iomgr/tcp_client_posix.cc
@@ -36,6 +36,7 @@
#include "src/core/lib/address_utils/sockaddr_utils.h"
#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/iomgr/ev_posix.h"
#include "src/core/lib/iomgr/executor.h"
#include "src/core/lib/iomgr/iomgr_internal.h"
diff --git a/src/core/lib/iomgr/tcp_client_windows.cc b/src/core/lib/iomgr/tcp_client_windows.cc
index f66f20c3875..ecf1546e71a 100644
--- a/src/core/lib/iomgr/tcp_client_windows.cc
+++ b/src/core/lib/iomgr/tcp_client_windows.cc
@@ -31,6 +31,7 @@
#include
#include "src/core/lib/address_utils/sockaddr_utils.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/iomgr/iocp_windows.h"
#include "src/core/lib/iomgr/sockaddr.h"
#include "src/core/lib/iomgr/sockaddr_windows.h"
diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc
index d6c3b46743f..623534ef0db 100644
--- a/src/core/lib/iomgr/tcp_posix.cc
+++ b/src/core/lib/iomgr/tcp_posix.cc
@@ -56,6 +56,7 @@
#include "src/core/lib/experiments/experiments.h"
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/gpr/useful.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/strerror.h"
#include "src/core/lib/gprpp/sync.h"
#include "src/core/lib/iomgr/buffer_list.h"
@@ -364,7 +365,7 @@ class TcpZerocopySendCtx {
// state was CHECK and is_in_write is false. This means that after the
// previous sendmsg returned and set is_in_write to false, it did
// not update the z-copy change from CHECK to OPEN.
- GPR_ASSERT(false && "OMem state error!");
+ Crash("OMem state error!");
}
}
diff --git a/src/core/lib/iomgr/tcp_server_posix.cc b/src/core/lib/iomgr/tcp_server_posix.cc
index c881f2479b9..bc227936e31 100644
--- a/src/core/lib/iomgr/tcp_server_posix.cc
+++ b/src/core/lib/iomgr/tcp_server_posix.cc
@@ -51,6 +51,7 @@
#include "src/core/lib/address_utils/sockaddr_utils.h"
#include "src/core/lib/gpr/string.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/memory.h"
#include "src/core/lib/gprpp/strerror.h"
#include "src/core/lib/iomgr/exec_ctx.h"
diff --git a/src/core/lib/iomgr/tcp_server_utils_posix_common.cc b/src/core/lib/iomgr/tcp_server_utils_posix_common.cc
index 2e6c6a335cb..574fd02d0de 100644
--- a/src/core/lib/iomgr/tcp_server_utils_posix_common.cc
+++ b/src/core/lib/iomgr/tcp_server_utils_posix_common.cc
@@ -37,6 +37,7 @@
#include
#include "src/core/lib/address_utils/sockaddr_utils.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/iomgr/sockaddr.h"
#include "src/core/lib/iomgr/tcp_server_utils_posix.h"
diff --git a/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc b/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc
index 159bea5e9ae..a04f0a36a08 100644
--- a/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc
+++ b/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc
@@ -36,6 +36,7 @@
#include
#include "src/core/lib/address_utils/sockaddr_utils.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/iomgr/sockaddr.h"
#include "src/core/lib/iomgr/tcp_server_utils_posix.h"
diff --git a/src/core/lib/iomgr/tcp_server_windows.cc b/src/core/lib/iomgr/tcp_server_windows.cc
index 082ecb79464..6cea16e84e9 100644
--- a/src/core/lib/iomgr/tcp_server_windows.cc
+++ b/src/core/lib/iomgr/tcp_server_windows.cc
@@ -38,6 +38,7 @@
#include
#include "src/core/lib/address_utils/sockaddr_utils.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/iomgr/iocp_windows.h"
#include "src/core/lib/iomgr/pollset_windows.h"
#include "src/core/lib/iomgr/resolve_address.h"
diff --git a/src/core/lib/iomgr/tcp_windows.cc b/src/core/lib/iomgr/tcp_windows.cc
index 215aa1bbc11..42bfa039ef8 100644
--- a/src/core/lib/iomgr/tcp_windows.cc
+++ b/src/core/lib/iomgr/tcp_windows.cc
@@ -33,6 +33,7 @@
#include "src/core/lib/address_utils/sockaddr_utils.h"
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/gpr/useful.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/iomgr/iocp_windows.h"
#include "src/core/lib/iomgr/sockaddr.h"
#include "src/core/lib/iomgr/sockaddr_windows.h"
diff --git a/src/core/lib/iomgr/timer_generic.cc b/src/core/lib/iomgr/timer_generic.cc
index 36ff009233a..3282fe17d08 100644
--- a/src/core/lib/iomgr/timer_generic.cc
+++ b/src/core/lib/iomgr/timer_generic.cc
@@ -23,6 +23,7 @@
#include
#include "absl/strings/str_cat.h"
+#include "absl/strings/str_format.h"
#include
#include
@@ -32,6 +33,7 @@
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/gpr/spinlock.h"
#include "src/core/lib/gpr/useful.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/manual_constructor.h"
#include "src/core/lib/gprpp/time.h"
#include "src/core/lib/gprpp/time_averaged_stats.h"
@@ -130,12 +132,11 @@ static void add_to_ht(grpc_timer* t) {
if (p == t) {
grpc_closure* c = t->closure;
- gpr_log(GPR_ERROR,
- "** Duplicate timer (%p) being added. Closure: (%p), created at: "
- "(%s:%d), scheduled at: (%s:%d) **",
- t, c, c->file_created, c->line_created, c->file_initiated,
- c->line_initiated);
- abort();
+ grpc_core::Crash(absl::StrFormat(
+ "** Duplicate timer (%p) being added. Closure: (%p), created at: "
+ "(%s:%d), scheduled at: (%s:%d) **",
+ t, c, c->file_created, c->line_created, c->file_initiated,
+ c->line_initiated));
}
// Timer not present in the bucket. Insert at head of the list
@@ -167,12 +168,11 @@ static void remove_from_ht(grpc_timer* t) {
if (!removed) {
grpc_closure* c = t->closure;
- gpr_log(GPR_ERROR,
- "** Removing timer (%p) that is not added to hash table. Closure "
- "(%p), created at: (%s:%d), scheduled at: (%s:%d) **",
- t, c, c->file_created, c->line_created, c->file_initiated,
- c->line_initiated);
- abort();
+ grpc_core::Crash(absl::StrFormat(
+ "** Removing timer (%p) that is not added to hash table. Closure "
+ "(%p), created at: (%s:%d), scheduled at: (%s:%d) **",
+ t, c, c->file_created, c->line_created, c->file_initiated,
+ c->line_initiated));
}
t->hash_table_next = nullptr;
@@ -185,13 +185,12 @@ static void remove_from_ht(grpc_timer* t) {
static void validate_non_pending_timer(grpc_timer* t) {
if (!t->pending && is_in_ht(t)) {
grpc_closure* c = t->closure;
- gpr_log(GPR_ERROR,
- "** gpr_timer_cancel() called on a non-pending timer (%p) which "
- "is in the hash table. Closure: (%p), created at: (%s:%d), "
- "scheduled at: (%s:%d) **",
- t, c, c->file_created, c->line_created, c->file_initiated,
- c->line_initiated);
- abort();
+ grpc_core::Crash(absl::StrFormat(
+ "** gpr_timer_cancel() called on a non-pending timer (%p) which "
+ "is in the hash table. Closure: (%p), created at: (%s:%d), "
+ "scheduled at: (%s:%d) **",
+ t, c, c->file_created, c->line_created, c->file_initiated,
+ c->line_initiated));
}
}
diff --git a/src/core/lib/iomgr/timer_manager.cc b/src/core/lib/iomgr/timer_manager.cc
index 5b7fb54b481..d7d8dfb53dd 100644
--- a/src/core/lib/iomgr/timer_manager.cc
+++ b/src/core/lib/iomgr/timer_manager.cc
@@ -26,6 +26,7 @@
#include
#include "src/core/lib/debug/trace.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/thd.h"
#include "src/core/lib/iomgr/timer.h"
diff --git a/src/core/lib/iomgr/unix_sockets_posix.cc b/src/core/lib/iomgr/unix_sockets_posix.cc
index ca798e45be2..e182e6adf13 100644
--- a/src/core/lib/iomgr/unix_sockets_posix.cc
+++ b/src/core/lib/iomgr/unix_sockets_posix.cc
@@ -33,6 +33,7 @@
#include "src/core/lib/address_utils/parse_address.h"
#include "src/core/lib/gpr/useful.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/iomgr/sockaddr.h"
#include "src/core/lib/iomgr/unix_sockets_posix.h"
#include "src/core/lib/transport/error_utils.h"
diff --git a/src/core/lib/iomgr/unix_sockets_posix_noop.cc b/src/core/lib/iomgr/unix_sockets_posix_noop.cc
index 5e78a9fab97..c683145668a 100644
--- a/src/core/lib/iomgr/unix_sockets_posix_noop.cc
+++ b/src/core/lib/iomgr/unix_sockets_posix_noop.cc
@@ -26,6 +26,8 @@
#include
+#include "src/core/lib/gprpp/crash.h"
+
void grpc_create_socketpair_if_unix(int /* sv */[2]) {
// TODO: Either implement this for the non-Unix socket case or make
// sure that it is never called in any such case. Until then, leave an
diff --git a/src/core/lib/iomgr/wakeup_fd_eventfd.cc b/src/core/lib/iomgr/wakeup_fd_eventfd.cc
index e4f31f88d30..38760c2cfb4 100644
--- a/src/core/lib/iomgr/wakeup_fd_eventfd.cc
+++ b/src/core/lib/iomgr/wakeup_fd_eventfd.cc
@@ -28,6 +28,7 @@
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/strerror.h"
#include "src/core/lib/iomgr/wakeup_fd_posix.h"
diff --git a/src/core/lib/iomgr/wakeup_fd_pipe.cc b/src/core/lib/iomgr/wakeup_fd_pipe.cc
index c034a4e14ac..a3936608cc5 100644
--- a/src/core/lib/iomgr/wakeup_fd_pipe.cc
+++ b/src/core/lib/iomgr/wakeup_fd_pipe.cc
@@ -28,6 +28,7 @@
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/strerror.h"
#include "src/core/lib/iomgr/socket_utils_posix.h"
#include "src/core/lib/iomgr/wakeup_fd_pipe.h"
diff --git a/src/core/lib/security/credentials/alts/check_gcp_environment_no_op.cc b/src/core/lib/security/credentials/alts/check_gcp_environment_no_op.cc
index 6cb6d93e580..7c50a81f609 100644
--- a/src/core/lib/security/credentials/alts/check_gcp_environment_no_op.cc
+++ b/src/core/lib/security/credentials/alts/check_gcp_environment_no_op.cc
@@ -22,6 +22,7 @@
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/security/credentials/alts/check_gcp_environment.h"
bool grpc_alts_is_running_on_gcp() {
diff --git a/src/core/lib/security/credentials/alts/check_gcp_environment_windows.cc b/src/core/lib/security/credentials/alts/check_gcp_environment_windows.cc
index c9e492fe628..b034ccaac79 100644
--- a/src/core/lib/security/credentials/alts/check_gcp_environment_windows.cc
+++ b/src/core/lib/security/credentials/alts/check_gcp_environment_windows.cc
@@ -29,6 +29,7 @@
#include
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/security/credentials/alts/check_gcp_environment.h"
namespace grpc_core {
diff --git a/src/core/lib/security/credentials/credentials.cc b/src/core/lib/security/credentials/credentials.cc
index d977265a725..07fbbbeb7f7 100644
--- a/src/core/lib/security/credentials/credentials.cc
+++ b/src/core/lib/security/credentials/credentials.cc
@@ -28,6 +28,7 @@
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/gpr/useful.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/surface/api_trace.h"
diff --git a/src/core/lib/security/credentials/credentials.h b/src/core/lib/security/credentials/credentials.h
index 750e3841d46..cd7c6f45298 100644
--- a/src/core/lib/security/credentials/credentials.h
+++ b/src/core/lib/security/credentials/credentials.h
@@ -35,6 +35,7 @@
#include
#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/ref_counted.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/gprpp/unique_type_name.h"
diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc
index 3bc26a8b983..a63f96bfc91 100644
--- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc
+++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc
@@ -729,7 +729,7 @@ grpc_access_token_credentials::grpc_access_token_credentials(
absl::StrCat("Bearer ", access_token))) {}
std::string grpc_access_token_credentials::debug_string() {
- return absl::StrFormat("AccessTokenCredentials{Token:present}");
+ return "AccessTokenCredentials{Token:present}";
}
grpc_call_credentials* grpc_access_token_credentials_create(
diff --git a/src/core/lib/security/security_connector/fake/fake_security_connector.cc b/src/core/lib/security/security_connector/fake/fake_security_connector.cc
index b3d9438a877..8da210f144c 100644
--- a/src/core/lib/security/security_connector/fake/fake_security_connector.cc
+++ b/src/core/lib/security/security_connector/fake/fake_security_connector.cc
@@ -28,6 +28,7 @@
#include "absl/status/status.h"
#include "absl/strings/str_cat.h"
+#include "absl/strings/str_format.h"
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
@@ -40,6 +41,7 @@
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/gpr/useful.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/debug_location.h"
#include "src/core/lib/gprpp/host_port.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
@@ -123,16 +125,13 @@ class grpc_fake_channel_security_connector final
&fake_security_target_name_override_hostname,
&fake_security_target_name_override_ignored_port);
if (authority_hostname != fake_security_target_name_override_hostname) {
- gpr_log(GPR_ERROR,
- "Authority (host) '%s' != Fake Security Target override '%s'",
- host.data(),
- fake_security_target_name_override_hostname.data());
- abort();
+ grpc_core::Crash(absl::StrFormat(
+ "Authority (host) '%s' != Fake Security Target override '%s'",
+ host.data(), fake_security_target_name_override_hostname.data()));
}
} else if (authority_hostname != target_hostname) {
- gpr_log(GPR_ERROR, "Authority (host) '%s' != Target '%s'", host.data(),
- target_);
- abort();
+ grpc_core::Crash(absl::StrFormat("Authority (host) '%s' != Target '%s'",
+ host.data(), target_));
}
return grpc_core::ImmediateOkStatus();
}
diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc
index 05faba4f29d..f2f783e5204 100644
--- a/src/core/lib/surface/call.cc
+++ b/src/core/lib/surface/call.cc
@@ -71,6 +71,7 @@
#include "src/core/lib/gpr/useful.h"
#include "src/core/lib/gprpp/bitset.h"
#include "src/core/lib/gprpp/cpp_impl_of.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/debug_location.h"
#include "src/core/lib/gprpp/ref_counted.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
@@ -728,8 +729,7 @@ void FilterStackCall::SetCompletionQueue(grpc_completion_queue* cq) {
GPR_ASSERT(cq);
if (grpc_polling_entity_pollset_set(&pollent_) != nullptr) {
- gpr_log(GPR_ERROR, "A pollset_set is already registered for this call.");
- abort();
+ Crash("A pollset_set is already registered for this call.");
}
cq_ = cq;
GRPC_CQ_INTERNAL_REF(cq, "bind");
diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc
index 61fb6cee98d..985342265f0 100644
--- a/src/core/lib/surface/server.cc
+++ b/src/core/lib/surface/server.cc
@@ -45,6 +45,7 @@
#include "src/core/lib/channel/channelz.h"
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/gpr/useful.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/debug_location.h"
#include "src/core/lib/gprpp/mpscq.h"
#include "src/core/lib/gprpp/status_helper.h"
@@ -341,7 +342,7 @@ class Server::AllocatingRequestMatcherBase : public RequestMatcherInterface {
void RequestCallWithPossiblePublish(size_t /*request_queue_index*/,
RequestedCall* /*call*/) final {
- GPR_ASSERT(false);
+ Crash("unreachable");
}
Server* server() const override { return server_; }
diff --git a/src/core/tsi/alts/frame_protector/alts_frame_protector.cc b/src/core/tsi/alts/frame_protector/alts_frame_protector.cc
index bb62a5eb83a..7c9b3109076 100644
--- a/src/core/tsi/alts/frame_protector/alts_frame_protector.cc
+++ b/src/core/tsi/alts/frame_protector/alts_frame_protector.cc
@@ -29,6 +29,7 @@
#include
#include "src/core/lib/gpr/useful.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/tsi/alts/crypt/gsec.h"
#include "src/core/tsi/alts/frame_protector/alts_crypter.h"
#include "src/core/tsi/alts/frame_protector/frame_handler.h"
diff --git a/src/core/tsi/alts/frame_protector/frame_handler.cc b/src/core/tsi/alts/frame_protector/frame_handler.cc
index 5fe8bb8c864..41b172ad2d2 100644
--- a/src/core/tsi/alts/frame_protector/frame_handler.cc
+++ b/src/core/tsi/alts/frame_protector/frame_handler.cc
@@ -29,6 +29,7 @@
#include
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/memory.h"
// Use little endian to interpret a string of bytes as uint32_t.
diff --git a/src/core/tsi/alts/handshaker/alts_handshaker_client.cc b/src/core/tsi/alts/handshaker/alts_handshaker_client.cc
index 9e6fecd7e4c..aa74a0012eb 100644
--- a/src/core/tsi/alts/handshaker/alts_handshaker_client.cc
+++ b/src/core/tsi/alts/handshaker/alts_handshaker_client.cc
@@ -28,6 +28,7 @@
#include
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/sync.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/surface/call.h"
diff --git a/src/core/tsi/alts/handshaker/alts_shared_resource.cc b/src/core/tsi/alts/handshaker/alts_shared_resource.cc
index 53d7decf419..289078ed978 100644
--- a/src/core/tsi/alts/handshaker/alts_shared_resource.cc
+++ b/src/core/tsi/alts/handshaker/alts_shared_resource.cc
@@ -23,6 +23,7 @@
#include
#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/tsi/alts/handshaker/alts_handshaker_client.h"
static alts_shared_resource_dedicated g_alts_resource_dedicated;
diff --git a/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc b/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc
index e2800dc4c72..2f1442d02fa 100644
--- a/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc
+++ b/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc
@@ -33,6 +33,7 @@
#include
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/memory.h"
#include "src/core/lib/gprpp/sync.h"
#include "src/core/lib/gprpp/thd.h"
diff --git a/src/core/tsi/alts/handshaker/transport_security_common_api.h b/src/core/tsi/alts/handshaker/transport_security_common_api.h
index 5da57fb9a45..b355d30e172 100644
--- a/src/core/tsi/alts/handshaker/transport_security_common_api.h
+++ b/src/core/tsi/alts/handshaker/transport_security_common_api.h
@@ -26,6 +26,7 @@
#include
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/proto/grpc/gcp/transport_security_common.upb.h"
// C struct coresponding to protobuf message RpcProtocolVersions.Version
diff --git a/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.cc b/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.cc
index 0e517e19248..8f1329b8d3b 100644
--- a/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.cc
+++ b/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.cc
@@ -25,6 +25,7 @@
#include
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/slice/slice.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.h"
diff --git a/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.cc b/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.cc
index ae2856090d6..25c09f6366b 100644
--- a/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.cc
+++ b/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.cc
@@ -23,6 +23,7 @@
#include
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/slice/slice.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.h"
diff --git a/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc b/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc
index a0756853949..326eca1f0da 100644
--- a/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc
+++ b/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc
@@ -26,6 +26,7 @@
#include
#include "src/core/lib/gpr/useful.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/slice/slice_internal.h"
diff --git a/src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.cc b/src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.cc
index e8f302b91cf..dc12a5133b5 100644
--- a/src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.cc
+++ b/src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.cc
@@ -26,6 +26,7 @@
#include
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/tsi/alts/frame_protector/alts_counter.h"
struct alts_iovec_record_protocol {
diff --git a/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc b/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc
index c9757152500..c32e6b53a85 100644
--- a/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc
+++ b/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc
@@ -26,6 +26,7 @@
#include
#include "src/core/lib/gpr/useful.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/tsi/alts/crypt/gsec.h"
diff --git a/src/core/tsi/fake_transport_security.cc b/src/core/tsi/fake_transport_security.cc
index 4c81572009f..b1371dcfc75 100644
--- a/src/core/tsi/fake_transport_security.cc
+++ b/src/core/tsi/fake_transport_security.cc
@@ -27,6 +27,7 @@
#include
#include "src/core/lib/gpr/useful.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/memory.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/tsi/transport_security_grpc.h"
diff --git a/src/core/tsi/local_transport_security.cc b/src/core/tsi/local_transport_security.cc
index b93edcb7079..6b3668c5282 100644
--- a/src/core/tsi/local_transport_security.cc
+++ b/src/core/tsi/local_transport_security.cc
@@ -28,6 +28,7 @@
#include
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/tsi/transport_security_grpc.h"
diff --git a/src/core/tsi/ssl/key_logging/ssl_key_logging.cc b/src/core/tsi/ssl/key_logging/ssl_key_logging.cc
index dc08684ef78..51499bbfe2b 100644
--- a/src/core/tsi/ssl/key_logging/ssl_key_logging.cc
+++ b/src/core/tsi/ssl/key_logging/ssl_key_logging.cc
@@ -20,6 +20,7 @@
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/sync.h"
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/slice/slice_internal.h"
diff --git a/src/core/tsi/ssl/session_cache/ssl_session_cache.cc b/src/core/tsi/ssl/session_cache/ssl_session_cache.cc
index 456f6f2fbcf..5427c989b2f 100644
--- a/src/core/tsi/ssl/session_cache/ssl_session_cache.cc
+++ b/src/core/tsi/ssl/session_cache/ssl_session_cache.cc
@@ -23,6 +23,7 @@
#include
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/sync.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/tsi/ssl/session_cache/ssl_session.h"
diff --git a/src/core/tsi/ssl/session_cache/ssl_session_openssl.cc b/src/core/tsi/ssl/session_cache/ssl_session_openssl.cc
index 95befc80b7d..487608d7dca 100644
--- a/src/core/tsi/ssl/session_cache/ssl_session_openssl.cc
+++ b/src/core/tsi/ssl/session_cache/ssl_session_openssl.cc
@@ -20,6 +20,7 @@
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/tsi/ssl/session_cache/ssl_session.h"
#ifndef OPENSSL_IS_BORINGSSL
diff --git a/src/core/tsi/ssl_transport_security.cc b/src/core/tsi/ssl_transport_security.cc
index 8ffcecd8de1..ec75c5ca876 100644
--- a/src/core/tsi/ssl_transport_security.cc
+++ b/src/core/tsi/ssl_transport_security.cc
@@ -56,6 +56,7 @@
#include
#include "src/core/lib/gpr/useful.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/tsi/ssl/key_logging/ssl_key_logging.h"
#include "src/core/tsi/ssl/session_cache/ssl_session_cache.h"
#include "src/core/tsi/ssl_transport_security_utils.h"
diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc
index e13d363a740..b986946e64d 100644
--- a/src/cpp/client/client_context.cc
+++ b/src/cpp/client/client_context.cc
@@ -24,6 +24,8 @@
#include
#include
+#include "absl/strings/str_format.h"
+
#include
#include
#include
@@ -39,6 +41,8 @@
#include
#include
+#include "src/core/lib/gprpp/crash.h"
+
namespace grpc {
class Channel;
@@ -141,9 +145,8 @@ void ClientContext::set_compression_algorithm(
compression_algorithm_ = algorithm;
const char* algorithm_name = nullptr;
if (!grpc_compression_algorithm_name(algorithm, &algorithm_name)) {
- gpr_log(GPR_ERROR, "Name for compression algorithm '%d' unknown.",
- algorithm);
- abort();
+ grpc_core::Crash(absl::StrFormat(
+ "Name for compression algorithm '%d' unknown.", algorithm));
}
GPR_ASSERT(algorithm_name != nullptr);
AddMetadata(GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY, algorithm_name);
diff --git a/src/cpp/client/client_interceptor.cc b/src/cpp/client/client_interceptor.cc
index f8c85330434..93181b825cb 100644
--- a/src/cpp/client/client_interceptor.cc
+++ b/src/cpp/client/client_interceptor.cc
@@ -16,9 +16,10 @@
//
//
-#include
#include
+#include "src/core/lib/gprpp/crash.h"
+
namespace grpc {
namespace internal {
@@ -30,9 +31,9 @@ namespace experimental {
void RegisterGlobalClientInterceptorFactory(
ClientInterceptorFactoryInterface* factory) {
if (internal::g_global_client_interceptor_factory != nullptr) {
- GPR_ASSERT(false &&
- "It is illegal to call RegisterGlobalClientInterceptorFactory "
- "multiple times.");
+ grpc_core::Crash(
+ "It is illegal to call RegisterGlobalClientInterceptorFactory "
+ "multiple times.");
}
internal::g_global_client_interceptor_factory = factory;
}
diff --git a/src/cpp/ext/gcp/BUILD b/src/cpp/ext/gcp/BUILD
index a25f621b385..5be21b84849 100644
--- a/src/cpp/ext/gcp/BUILD
+++ b/src/cpp/ext/gcp/BUILD
@@ -103,8 +103,8 @@ grpc_cc_library(
"absl/strings",
"absl/strings:str_format",
"absl/types:optional",
+ "googleapis_logging_cc_proto",
"googleapis_logging_grpc_service",
- "googleapis_logging_proto",
"protobuf_headers",
],
language = "c++",
diff --git a/src/cpp/server/load_reporter/get_cpu_stats_unsupported.cc b/src/cpp/server/load_reporter/get_cpu_stats_unsupported.cc
index dd6417bf88b..83734b9c9d7 100644
--- a/src/cpp/server/load_reporter/get_cpu_stats_unsupported.cc
+++ b/src/cpp/server/load_reporter/get_cpu_stats_unsupported.cc
@@ -22,6 +22,7 @@
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/cpp/server/load_reporter/get_cpu_stats.h"
namespace grpc {
diff --git a/src/cpp/server/server_context.cc b/src/cpp/server/server_context.cc
index 6f3c9fd9eef..ec5d0e2ea6e 100644
--- a/src/cpp/server/server_context.cc
+++ b/src/cpp/server/server_context.cc
@@ -27,6 +27,7 @@
#include
#include
+#include "absl/strings/str_format.h"
#include "absl/strings/string_view.h"
#include
@@ -52,6 +53,7 @@
#include
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/ref_counted.h"
#include "src/core/lib/gprpp/sync.h"
#include "src/core/lib/resource_quota/arena.h"
@@ -132,7 +134,7 @@ class ServerContextBase::CompletionOp final
// RPC. This should set hijacking state for each of the ops.
void SetHijackingState() override {
// Servers don't allow hijacking
- GPR_ASSERT(false);
+ grpc_core::Crash("unreachable");
}
// Should be called after interceptors are done running
@@ -365,9 +367,8 @@ void ServerContextBase::set_compression_algorithm(
compression_algorithm_ = algorithm;
const char* algorithm_name = nullptr;
if (!grpc_compression_algorithm_name(algorithm, &algorithm_name)) {
- gpr_log(GPR_ERROR, "Name for compression algorithm '%d' unknown.",
- algorithm);
- abort();
+ grpc_core::Crash(absl::StrFormat(
+ "Name for compression algorithm '%d' unknown.", algorithm));
}
GPR_ASSERT(algorithm_name != nullptr);
AddInitialMetadata(GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY, algorithm_name);
diff --git a/src/cpp/thread_manager/thread_manager.cc b/src/cpp/thread_manager/thread_manager.cc
index f518482a79e..2675f32af62 100644
--- a/src/cpp/thread_manager/thread_manager.cc
+++ b/src/cpp/thread_manager/thread_manager.cc
@@ -18,12 +18,13 @@
#include "src/cpp/thread_manager/thread_manager.h"
-#include
-
#include
+#include "absl/strings/str_format.h"
+
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/gprpp/thd.h"
#include "src/core/lib/resource_quota/resource_quota.h"
@@ -126,11 +127,10 @@ void ThreadManager::CleanupCompletedThreads() {
void ThreadManager::Initialize() {
if (!thread_quota_->Reserve(min_pollers_)) {
- gpr_log(GPR_ERROR,
- "No thread quota available to even create the minimum required "
- "polling threads (i.e %d). Unable to start the thread manager",
- min_pollers_);
- abort();
+ grpc_core::Crash(absl::StrFormat(
+ "No thread quota available to even create the minimum required "
+ "polling threads (i.e %d). Unable to start the thread manager",
+ min_pollers_));
}
{
diff --git a/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm b/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm
index c9387089d21..b34aac58fcf 100644
--- a/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm
+++ b/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm
@@ -35,6 +35,7 @@
#include
#include
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/gpr/string.h"
diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py
index 43842c1ccf9..6e05ae8173f 100644
--- a/src/python/grpcio/grpc_core_dependencies.py
+++ b/src/python/grpcio/grpc_core_dependencies.py
@@ -532,6 +532,7 @@ CORE_SOURCE_FILES = [
'src/core/lib/gpr/tmpfile_posix.cc',
'src/core/lib/gpr/tmpfile_windows.cc',
'src/core/lib/gpr/wrap_memcpy.cc',
+ 'src/core/lib/gprpp/crash.cc',
'src/core/lib/gprpp/env_linux.cc',
'src/core/lib/gprpp/env_posix.cc',
'src/core/lib/gprpp/env_windows.cc',
diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.c b/src/ruby/ext/grpc/rb_grpc_imports.generated.c
index 58d7a6b2d41..a2fcb9d8a40 100644
--- a/src/ruby/ext/grpc/rb_grpc_imports.generated.c
+++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.c
@@ -256,6 +256,7 @@ gpr_log_message_type gpr_log_message_import;
gpr_set_log_verbosity_type gpr_set_log_verbosity_import;
gpr_log_verbosity_init_type gpr_log_verbosity_init_import;
gpr_set_log_function_type gpr_set_log_function_import;
+gpr_assertion_failed_type gpr_assertion_failed_import;
gpr_format_message_type gpr_format_message_import;
gpr_strdup_type gpr_strdup_import;
gpr_asprintf_type gpr_asprintf_import;
@@ -541,6 +542,7 @@ void grpc_rb_load_imports(HMODULE library) {
gpr_set_log_verbosity_import = (gpr_set_log_verbosity_type) GetProcAddress(library, "gpr_set_log_verbosity");
gpr_log_verbosity_init_import = (gpr_log_verbosity_init_type) GetProcAddress(library, "gpr_log_verbosity_init");
gpr_set_log_function_import = (gpr_set_log_function_type) GetProcAddress(library, "gpr_set_log_function");
+ gpr_assertion_failed_import = (gpr_assertion_failed_type) GetProcAddress(library, "gpr_assertion_failed");
gpr_format_message_import = (gpr_format_message_type) GetProcAddress(library, "gpr_format_message");
gpr_strdup_import = (gpr_strdup_type) GetProcAddress(library, "gpr_strdup");
gpr_asprintf_import = (gpr_asprintf_type) GetProcAddress(library, "gpr_asprintf");
diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.h b/src/ruby/ext/grpc/rb_grpc_imports.generated.h
index e7c46baa812..e9ec9104656 100644
--- a/src/ruby/ext/grpc/rb_grpc_imports.generated.h
+++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.h
@@ -743,6 +743,9 @@ extern gpr_log_verbosity_init_type gpr_log_verbosity_init_import;
typedef void(*gpr_set_log_function_type)(gpr_log_func func);
extern gpr_set_log_function_type gpr_set_log_function_import;
#define gpr_set_log_function gpr_set_log_function_import
+typedef void(*gpr_assertion_failed_type)(const char* filename, int line, const char* message);
+extern gpr_assertion_failed_type gpr_assertion_failed_import;
+#define gpr_assertion_failed gpr_assertion_failed_import
typedef char*(*gpr_format_message_type)(int messageid);
extern gpr_format_message_type gpr_format_message_import;
#define gpr_format_message gpr_format_message_import
diff --git a/templates/test/core/end2end/end2end_defs.include b/templates/test/core/end2end/end2end_defs.include
index 2e84c48b7e1..9bbe9aac27c 100644
--- a/templates/test/core/end2end/end2end_defs.include
+++ b/templates/test/core/end2end/end2end_defs.include
@@ -25,8 +25,11 @@
#include
#include
+#include "absl/strings/str_format.h"
+
#include
+#include "src/core/lib/gprpp/crash.h"
static bool g_pre_init_called = false;
@@ -64,7 +67,6 @@ void grpc_end2end_tests(int argc, char **argv,
continue;
}
% endfor
- gpr_log(GPR_DEBUG, "not a test: '%s'", argv[i]);
- abort();
+ grpc_core::Crash(absl::StrFormat( "not a test: '%s'", argv[i]));
}
}%def>
diff --git a/test/core/address_utils/parse_address_with_named_scope_id_test.cc b/test/core/address_utils/parse_address_with_named_scope_id_test.cc
index 7faa8d497ee..8ed013b7d3a 100644
--- a/test/core/address_utils/parse_address_with_named_scope_id_test.cc
+++ b/test/core/address_utils/parse_address_with_named_scope_id_test.cc
@@ -19,7 +19,6 @@
#include
#include
#include
-#include
#include
#include
@@ -38,6 +37,7 @@
#include
#include "src/core/lib/address_utils/parse_address.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/host_port.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/iomgr/resolved_address.h"
@@ -89,10 +89,9 @@ struct sockaddr_in6 resolve_with_gettaddrinfo(const char* uri_text) {
struct addrinfo* result;
int res = getaddrinfo(host.c_str(), port.c_str(), &hints, &result);
if (res != 0) {
- gpr_log(GPR_ERROR,
- "getaddrinfo failed to resolve host:%s port:%s. Error: %d.",
- host.c_str(), port.c_str(), res);
- abort();
+ grpc_core::Crash(absl::StrFormat(
+ "getaddrinfo failed to resolve host:%s port:%s. Error: %d.",
+ host.c_str(), port.c_str(), res));
}
size_t num_addrs_from_getaddrinfo = 0;
for (struct addrinfo* resp = result; resp != nullptr; resp = resp->ai_next) {
diff --git a/test/core/bad_connection/close_fd_test.cc b/test/core/bad_connection/close_fd_test.cc
index f5724bfd99c..a490ca06ef7 100644
--- a/test/core/bad_connection/close_fd_test.cc
+++ b/test/core/bad_connection/close_fd_test.cc
@@ -22,9 +22,9 @@
//
//
#include
-#include
#include "absl/status/statusor.h"
+#include "absl/strings/str_format.h"
#include
#include
@@ -53,6 +53,7 @@
#include
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/iomgr/endpoint_pair.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/completion_queue.h"
@@ -203,8 +204,7 @@ static const char* fd_type_str(fd_type fdtype) {
} else if (fdtype == SERVER_FD) {
return "server";
} else {
- gpr_log(GPR_ERROR, "Unexpected fd_type %d", fdtype);
- abort();
+ grpc_core::Crash(absl::StrFormat("Unexpected fd_type %d", fdtype));
}
}
diff --git a/test/core/end2end/BUILD b/test/core/end2end/BUILD
index d4babbf29f7..f3b3ea0cb6f 100644
--- a/test/core/end2end/BUILD
+++ b/test/core/end2end/BUILD
@@ -202,6 +202,7 @@ grpc_cc_test(
grpc_cc_test(
name = "inproc_callback_test",
srcs = ["inproc_callback_test.cc"],
+ external_deps = ["absl/strings:str_format"],
language = "C++",
uses_event_engine = False,
uses_polling = False,
diff --git a/test/core/end2end/cq_verifier.cc b/test/core/end2end/cq_verifier.cc
index c4904318241..af6a90b59cd 100644
--- a/test/core/end2end/cq_verifier.cc
+++ b/test/core/end2end/cq_verifier.cc
@@ -20,7 +20,6 @@
#include
#include
-#include
#include
#include
@@ -40,6 +39,7 @@
#include
#include "src/core/lib/compression/message_compress.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/debug_location.h"
#include "src/core/lib/gprpp/match.h"
#include "src/core/lib/surface/event_string.h"
@@ -189,17 +189,15 @@ std::string CqVerifier::ToString() const {
}
void CqVerifier::FailNoEventReceived(const SourceLocation& location) const {
- gpr_log(GPR_ERROR, "[%s:%d] no event received, but expected:%s",
- location.file(), location.line(), ToString().c_str());
- abort();
+ Crash(absl::StrFormat("[%s:%d] no event received, but expected:%s",
+ location.file(), location.line(), ToString().c_str()));
}
void CqVerifier::FailUnexpectedEvent(grpc_event* ev,
const SourceLocation& location) const {
gpr_log(GPR_ERROR, "[%s:%d] cq returned unexpected event: %s",
location.file(), location.line(), grpc_event_string(ev).c_str());
- gpr_log(GPR_ERROR, "expected tags:\n%s", ToString().c_str());
- abort();
+ Crash(absl::StrFormat("expected tags:\n%s", ToString().c_str()));
}
void CqVerifier::Verify(Duration timeout, SourceLocation location) {
diff --git a/test/core/end2end/end2end_tests.cc b/test/core/end2end/end2end_tests.cc
index 4865e2182f2..d95b7abf6e1 100644
--- a/test/core/end2end/end2end_tests.cc
+++ b/test/core/end2end/end2end_tests.cc
@@ -24,8 +24,11 @@
#include
#include
+#include "absl/strings/str_format.h"
+
#include
+#include "src/core/lib/gprpp/crash.h"
static bool g_pre_init_called = false;
@@ -791,7 +794,6 @@ void grpc_end2end_tests(int argc, char **argv,
write_buffering_at_end(config);
continue;
}
- gpr_log(GPR_DEBUG, "not a test: '%s'", argv[i]);
- abort();
+ grpc_core::Crash(absl::StrFormat( "not a test: '%s'", argv[i]));
}
}
diff --git a/test/core/end2end/fixtures/proxy.cc b/test/core/end2end/fixtures/proxy.cc
index 2926dc2c4f4..c1b7da1a446 100644
--- a/test/core/end2end/fixtures/proxy.cc
+++ b/test/core/end2end/fixtures/proxy.cc
@@ -18,7 +18,6 @@
#include "test/core/end2end/fixtures/proxy.h"
-#include
#include
#include
@@ -34,6 +33,7 @@
#include
#include "src/core/lib/channel/channel_args.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/host_port.h"
#include "src/core/lib/gprpp/thd.h"
#include "src/core/lib/surface/call.h"
@@ -454,8 +454,7 @@ static void thread_main(void* arg) {
proxy->cq, gpr_inf_future(GPR_CLOCK_MONOTONIC), nullptr);
switch (ev.type) {
case GRPC_QUEUE_TIMEOUT:
- gpr_log(GPR_ERROR, "Should never reach here");
- abort();
+ grpc_core::Crash("Should never reach here");
case GRPC_QUEUE_SHUTDOWN:
return;
case GRPC_OP_COMPLETE:
diff --git a/test/core/end2end/fuzzers/client_fuzzer.cc b/test/core/end2end/fuzzers/client_fuzzer.cc
index f00e3347489..4bd28df4f60 100644
--- a/test/core/end2end/fuzzers/client_fuzzer.cc
+++ b/test/core/end2end/fuzzers/client_fuzzer.cc
@@ -23,6 +23,7 @@
#include
#include "absl/status/statusor.h"
+#include "absl/strings/str_format.h"
#include
#include
@@ -35,6 +36,7 @@
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/channel_args_preconditioning.h"
#include "src/core/lib/config/core_configuration.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/iomgr/endpoint.h"
#include "src/core/lib/iomgr/exec_ctx.h"
@@ -156,11 +158,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
nullptr);
if (ev.type != GRPC_OP_COMPLETE) {
- gpr_log(GPR_ERROR,
- "[%d/%d requested calls] Unexpected event type (expected "
- "COMPLETE): %s",
- i, requested_calls, grpc_event_string(&ev).c_str());
- abort();
+ grpc_core::Crash(absl::StrFormat(
+ "[%d/%d requested calls] Unexpected event type (expected "
+ "COMPLETE): %s",
+ i, requested_calls, grpc_event_string(&ev).c_str()));
}
}
grpc_completion_queue_shutdown(cq);
@@ -168,9 +169,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
ev = grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME),
nullptr);
if (ev.type != GRPC_QUEUE_SHUTDOWN) {
- gpr_log(GPR_ERROR, "Unexpected event type (expected SHUTDOWN): %s",
- grpc_event_string(&ev).c_str());
- abort();
+ grpc_core::Crash(
+ absl::StrFormat("Unexpected event type (expected SHUTDOWN): %s",
+ grpc_event_string(&ev).c_str()));
}
}
grpc_call_unref(call);
diff --git a/test/core/end2end/h2_ssl_cert_test.cc b/test/core/end2end/h2_ssl_cert_test.cc
index 09de6b439b9..459d52e56d7 100644
--- a/test/core/end2end/h2_ssl_cert_test.cc
+++ b/test/core/end2end/h2_ssl_cert_test.cc
@@ -29,6 +29,7 @@
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/gpr/tmpfile.h"
+#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/host_port.h"
#include "src/core/lib/security/credentials/credentials.h"
#include "src/core/lib/security/security_connector/ssl_utils_config.h"
diff --git a/test/core/end2end/inproc_callback_test.cc b/test/core/end2end/inproc_callback_test.cc
index c7b2566cc45..9e159a45b0d 100644
--- a/test/core/end2end/inproc_callback_test.cc
+++ b/test/core/end2end/inproc_callback_test.cc
@@ -19,6 +19,8 @@
#include
#include
+#include "absl/strings/str_format.h"
+
#include
#include
#include
@@ -29,6 +31,7 @@
#include
#include "src/core/ext/transport/inproc/inproc_transport.h"
+#include "src/core/lib/gprpp/crash.h"
#include "test/core/end2end/end2end_tests.h"
#include "test/core/util/test_config.h"
@@ -147,15 +150,15 @@ static void verify_tags(gpr_timespec deadline) {
if (tags_valid[i]) {
gpr_log(GPR_DEBUG, "Verifying tag %d", static_cast(i));
if (tags[i] != tags_expected[i]) {
- gpr_log(GPR_ERROR, "Got wrong result (%d instead of %d) for tag %d",
- tags[i], tags_expected[i], static_cast