2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-02 23:55:27 +00:00

Remove isc__tls_setfatalmode() function and the calls

With _exit() instead of exit() in place, we don't need
isc__tls_setfatalmode() mechanism as the atexit() calls will not be
executed including OpenSSL atexit hooks.
This commit is contained in:
Ondřej Surý
2024-02-07 15:25:13 +01:00
parent 76997983fd
commit 0c18ed7ec6
11 changed files with 2 additions and 27 deletions

View File

@@ -47,6 +47,5 @@ fatal(const char *format, ...) {
vfprintf(stderr, format, args); vfprintf(stderr, format, args);
va_end(args); va_end(args);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
isc__tls_setfatalmode();
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);
} }

View File

@@ -263,7 +263,6 @@ fatal(const char *format, ...) {
vfprintf(stderr, format, args); vfprintf(stderr, format, args);
va_end(args); va_end(args);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
isc__tls_setfatalmode();
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);
} }

View File

@@ -406,7 +406,6 @@ fatal(const char *format, ...) {
vfprintf(stderr, format, args); vfprintf(stderr, format, args);
va_end(args); va_end(args);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
isc__tls_setfatalmode();
if (fatalexit == 0 && exitcode != 0) { if (fatalexit == 0 && exitcode != 0) {
fatalexit = exitcode; fatalexit = exitcode;
} else if (fatalexit == 0) { } else if (fatalexit == 0) {

View File

@@ -84,9 +84,6 @@ fatal(const char *format, ...) {
if (fatalcallback != NULL) { if (fatalcallback != NULL) {
(*fatalcallback)(); (*fatalcallback)();
} }
isc__tls_setfatalmode();
/* Make sure that various atexit() calls are skipped */
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);
} }

View File

@@ -10203,7 +10203,6 @@ fatal(const char *msg, isc_result_t result) {
NAMED_LOGMODULE_SERVER, ISC_LOG_CRITICAL, NAMED_LOGMODULE_SERVER, ISC_LOG_CRITICAL,
"exiting (due to fatal error)"); "exiting (due to fatal error)");
named_os_shutdown(); named_os_shutdown();
isc__tls_setfatalmode();
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);
} }

View File

@@ -279,7 +279,6 @@ fatal(const char *format, ...) {
vfprintf(stderr, format, args); vfprintf(stderr, format, args);
va_end(args); va_end(args);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
isc__tls_setfatalmode();
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);
} }

View File

@@ -46,6 +46,5 @@ fatal(const char *format, ...) {
vfprintf(stderr, format, args); vfprintf(stderr, format, args);
va_end(args); va_end(args);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
isc__tls_setfatalmode();
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);
} }

View File

@@ -897,7 +897,6 @@ fatal(const char *format, ...) {
vfprintf(stderr, format, args); vfprintf(stderr, format, args);
va_end(args); va_end(args);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
isc__tls_setfatalmode();
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);
} }

View File

@@ -48,7 +48,6 @@ fatal(const char *format, ...) {
vfprintf(stderr, format, args); vfprintf(stderr, format, args);
va_end(args); va_end(args);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
isc__tls_setfatalmode();
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);
} }

View File

@@ -615,6 +615,3 @@ isc__tls_shutdown(void);
void void
isc__tls_setdestroycheck(bool check); isc__tls_setdestroycheck(bool check);
void
isc__tls_setfatalmode(void);

View File

@@ -77,12 +77,6 @@ isc__tls_set_thread_id(CRYPTO_THREADID *id) {
} }
#endif #endif
#ifdef ISC_TEST_OPENSSL_MEMORY_LEAKS
static atomic_bool handle_fatal = false;
#else
static atomic_bool handle_fatal = true;
#endif
#if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x30000000L #if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x30000000L
/* /*
* This was crippled with LibreSSL, so just skip it: * This was crippled with LibreSSL, so just skip it:
@@ -115,7 +109,7 @@ isc__tls_free_ex(void *ptr, const char *file, int line) {
if (ptr == NULL) { if (ptr == NULL) {
return; return;
} }
if (!atomic_load(&handle_fatal) || isc__tls_mctx != NULL) { if (isc__tls_mctx != NULL) {
isc__mem_free(isc__tls_mctx, ptr, 0, file, (unsigned int)line); isc__mem_free(isc__tls_mctx, ptr, 0, file, (unsigned int)line);
} }
} }
@@ -143,7 +137,7 @@ isc__tls_free_ex(void *ptr, const char *file, int line) {
if (ptr == NULL) { if (ptr == NULL) {
return; return;
} }
if (!atomic_load(&handle_fatal) || isc__tls_mctx != NULL) { if (isc__tls_mctx != NULL) {
isc__mem_free(isc__tls_mctx, ptr, 0); isc__mem_free(isc__tls_mctx, ptr, 0);
} }
} }
@@ -1796,8 +1790,3 @@ isc_tlsctx_set_random_session_id_context(isc_tlsctx_t *ctx) {
RUNTIME_CHECK( RUNTIME_CHECK(
SSL_CTX_set_session_id_context(ctx, session_id_ctx, len) == 1); SSL_CTX_set_session_id_context(ctx, session_id_ctx, len) == 1);
} }
void
isc__tls_setfatalmode(void) {
atomic_store(&handle_fatal, true);
}