ASF Bugzilla – Attachment 35380 Details for
Bug 61558
Apache 2.4.27 crashes often when restarting the service. segfault in libdl-2.24.so or apache2
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Signals and hooks cleanup on exit (v2, 2.4.x)
signals_and_hooks_cleanup_on_exit-v2.patch (text/plain), 10.48 KB, created by
Yann Ylavic
on 2017-09-28 11:35:47 UTC
(
hide
)
Description:
Signals and hooks cleanup on exit (v2, 2.4.x)
Filename:
MIME Type:
Creator:
Yann Ylavic
Created:
2017-09-28 11:35:47 UTC
Size:
10.48 KB
patch
obsolete
>Index: os/unix/unixd.c >=================================================================== >--- os/unix/unixd.c (revision 1809975) >+++ os/unix/unixd.c (working copy) >@@ -437,11 +437,19 @@ AP_DECLARE(apr_status_t) ap_unixd_accept(void **ac > /* Unixes MPMs' */ > > static ap_unixd_mpm_retained_data *retained_data = NULL; >+static apr_status_t retained_data_cleanup(void *unused) >+{ >+ (void)unused; >+ retained_data = NULL; >+ return APR_SUCCESS; >+} >+ > AP_DECLARE(ap_unixd_mpm_retained_data *) ap_unixd_mpm_get_retained_data() > { > if (!retained_data) { > retained_data = ap_retained_data_create("ap_unixd_mpm_retained_data", > sizeof(*retained_data)); >+ apr_pool_pre_cleanup_register(ap_pglobal, NULL, retained_data_cleanup); > retained_data->mpm_state = AP_MPMQ_STARTING; > } > return retained_data; >@@ -449,6 +457,10 @@ AP_DECLARE(ap_unixd_mpm_retained_data *) ap_unixd_ > > static void sig_term(int sig) > { >+ if (!retained_data) { >+ /* Main process (ap_pglobal) is dying */ >+ return; >+ } > retained_data->mpm_state = AP_MPMQ_STOPPING; > if (retained_data->shutdown_pending > && (retained_data->is_ungraceful >@@ -465,6 +477,10 @@ static void sig_term(int sig) > > static void sig_restart(int sig) > { >+ if (!retained_data) { >+ /* Main process (ap_pglobal) is dying */ >+ return; >+ } > retained_data->mpm_state = AP_MPMQ_STOPPING; > if (retained_data->restart_pending > && (retained_data->is_ungraceful >@@ -481,6 +497,10 @@ static void sig_restart(int sig) > > static apr_status_t unset_signals(void *unused) > { >+ if (!retained_data) { >+ /* Main process (ap_pglobal) is dying */ >+ return APR_SUCCESS; >+ } > retained_data->shutdown_pending = retained_data->restart_pending = 0; > retained_data->was_graceful = !retained_data->is_ungraceful; > retained_data->is_ungraceful = 0; >@@ -494,6 +514,10 @@ AP_DECLARE(void) ap_unixd_mpm_set_signals(apr_pool > struct sigaction sa; > #endif > >+ if (!one_process) { >+ ap_fatal_signal_setup(ap_server_conf, pconf); >+ } >+ > /* Signals' handlers depend on retained data */ > (void)ap_unixd_mpm_get_retained_data(); > >Index: server/main.c >=================================================================== >--- server/main.c (revision 1809975) >+++ server/main.c (working copy) >@@ -273,6 +273,30 @@ static int abort_on_oom(int retcode) > return retcode; /* unreachable, hopefully. */ > } > >+/* Deregister all hooks when clearing pconf (pre_cleanup). >+ * TODO: have a hook to deregister and run them from here? >+ * ap_clear_auth_internal() is already a candidate. >+ */ >+static apr_status_t deregister_all_hooks(void *unused) >+{ >+ (void)unused; >+ ap_clear_auth_internal(); >+ apr_hook_deregister_all(); >+ return APR_SUCCESS; >+} >+ >+static void reset_process_pconf(process_rec *process) >+{ >+ if (process->pconf) { >+ apr_pool_clear(process->pconf); >+ } >+ else { >+ apr_pool_create(&process->pconf, process->pool); >+ apr_pool_tag(process->pconf, "pconf"); >+ } >+ apr_pool_pre_cleanup_register(process->pconf, NULL, deregister_all_hooks); >+} >+ > static process_rec *init_process(int *argc, const char * const * *argv) > { > process_rec *process; >@@ -317,8 +341,9 @@ static process_rec *init_process(int *argc, const > process = apr_palloc(cntx, sizeof(process_rec)); > process->pool = cntx; > >- apr_pool_create(&process->pconf, process->pool); >- apr_pool_tag(process->pconf, "pconf"); >+ process->pconf = NULL; >+ reset_process_pconf(process); >+ > process->argc = *argc; > process->argv = *argv; > process->short_name = apr_filepath_name_get((*argv)[0]); >@@ -721,9 +746,7 @@ int main(int argc, const char * const argv[]) > > do { > ap_main_state = AP_SQ_MS_DESTROY_CONFIG; >- apr_hook_deregister_all(); >- apr_pool_clear(pconf); >- ap_clear_auth_internal(); >+ reset_process_pconf(process); > > ap_main_state = AP_SQ_MS_CREATE_CONFIG; > ap_config_generation++; >Index: server/mpm/event/event.c >=================================================================== >--- server/mpm/event/event.c (revision 1809975) >+++ server/mpm/event/event.c (working copy) >@@ -2880,9 +2880,6 @@ static int event_run(apr_pool_t * _pconf, apr_pool > ap_scoreboard_image->global->running_generation = retained->mpm->my_generation; > } > >- if (!one_process) { >- ap_fatal_signal_setup(ap_server_conf, pconf); >- } > ap_unixd_mpm_set_signals(pconf, one_process); > > /* Don't thrash since num_buckets depends on the >Index: server/mpm/prefork/prefork.c >=================================================================== >--- server/mpm/prefork/prefork.c (revision 1809975) >+++ server/mpm/prefork/prefork.c (working copy) >@@ -863,9 +863,6 @@ static int prefork_run(apr_pool_t *_pconf, apr_poo > ap_scoreboard_image->global->running_generation = retained->mpm->my_generation; > } > >- if (!one_process) { >- ap_fatal_signal_setup(ap_server_conf, pconf); >- } > ap_unixd_mpm_set_signals(pconf, one_process); > > if (one_process) { >Index: server/mpm/worker/worker.c >=================================================================== >--- server/mpm/worker/worker.c (revision 1809975) >+++ server/mpm/worker/worker.c (working copy) >@@ -1671,9 +1671,6 @@ static int worker_run(apr_pool_t *_pconf, apr_pool > ap_scoreboard_image->global->running_generation = retained->mpm->my_generation; > } > >- if (!one_process) { >- ap_fatal_signal_setup(ap_server_conf, pconf); >- } > ap_unixd_mpm_set_signals(pconf, one_process); > > /* Don't thrash since num_buckets depends on the >Index: server/mpm_unix.c >=================================================================== >--- server/mpm_unix.c (revision 1809975) >+++ server/mpm_unix.c (working copy) >@@ -1009,6 +1009,33 @@ AP_DECLARE(apr_status_t) ap_fatal_signal_child_set > return APR_SUCCESS; > } > >+/* We can't call sig_coredump (ap_log_error) once pconf is destroyed, so >+ * avoid double faults by restoring each default signal handler on cleanup. >+ */ >+static apr_status_t fatal_signal_cleanup(void *unused) >+{ >+ (void)unused; >+ >+ apr_signal(SIGSEGV, SIG_DFL); >+#ifdef SIGBUS >+ apr_signal(SIGBUS, SIG_DFL); >+#endif /* SIGBUS */ >+#ifdef SIGABORT >+ apr_signal(SIGABORT, SIG_DFL); >+#endif /* SIGABORT */ >+#ifdef SIGABRT >+ apr_signal(SIGABRT, SIG_DFL); >+#endif /* SIGABRT */ >+#ifdef SIGILL >+ apr_signal(SIGILL, SIG_DFL); >+#endif /* SIGILL */ >+#ifdef SIGFPE >+ apr_signal(SIGFPE, SIG_DFL); >+#endif /* SIGFPE */ >+ >+ return APR_SUCCESS; >+} >+ > AP_DECLARE(apr_status_t) ap_fatal_signal_setup(server_rec *s, > apr_pool_t *in_pconf) > { >@@ -1071,6 +1098,8 @@ AP_DECLARE(apr_status_t) ap_fatal_signal_setup(ser > > pconf = in_pconf; > parent_pid = my_pid = getpid(); >+ apr_pool_cleanup_register(pconf, NULL, fatal_signal_cleanup, >+ fatal_signal_cleanup); > > return APR_SUCCESS; > } >Index: server/util_expr_scan.c >=================================================================== >--- server/util_expr_scan.c (revision 1809975) >+++ server/util_expr_scan.c (working copy) >@@ -54,6 +54,7 @@ typedef int flex_int32_t; > typedef unsigned char flex_uint8_t; > typedef unsigned short int flex_uint16_t; > typedef unsigned int flex_uint32_t; >+#endif /* ! C99 */ > > /* Limits of integral types. */ > #ifndef INT8_MIN >@@ -84,8 +85,6 @@ typedef unsigned int flex_uint32_t; > #define UINT32_MAX (4294967295U) > #endif > >-#endif /* ! C99 */ >- > #endif /* ! FLEXINT_H */ > > #ifdef __cplusplus >@@ -159,15 +158,7 @@ typedef void* yyscan_t; > > /* Size of default input buffer. */ > #ifndef YY_BUF_SIZE >-#ifdef __ia64__ >-/* On IA-64, the buffer size is 16k, not 8k. >- * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. >- * Ditto for the __ia64__ case accordingly. >- */ >-#define YY_BUF_SIZE 32768 >-#else > #define YY_BUF_SIZE 16384 >-#endif /* __ia64__ */ > #endif > > /* The state buf must be large enough to hold one state per character in the main buffer. >@@ -611,7 +602,7 @@ static yyconst flex_int16_t yy_chk[319] = > PERROR("String too long"); \ > } while (0) > >-#line 615 "util_expr_scan.c" >+#line 606 "util_expr_scan.c" > > #define INITIAL 0 > #define str 1 >@@ -747,12 +738,7 @@ static int input (yyscan_t yyscanner ); > > /* Amount of stuff to slurp up with each read. */ > #ifndef YY_READ_BUF_SIZE >-#ifdef __ia64__ >-/* On IA-64, the buffer size is 16k, not 8k */ >-#define YY_READ_BUF_SIZE 16384 >-#else > #define YY_READ_BUF_SIZE 8192 >-#endif /* __ia64__ */ > #endif > > /* Copy whatever the last rule matched to the standard output. */ >@@ -760,7 +746,7 @@ static int input (yyscan_t yyscanner ); > /* This used to be an fputs(), but since the string might contain NUL's, > * we now use fwrite(). > */ >-#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) >+#define ECHO fwrite( yytext, yyleng, 1, yyout ) > #endif > > /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, >@@ -771,7 +757,7 @@ static int input (yyscan_t yyscanner ); > if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ > { \ > int c = '*'; \ >- size_t n; \ >+ int n; \ > for ( n = 0; n < max_size && \ > (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ > buf[n] = (char) c; \ >@@ -882,7 +868,7 @@ YY_DECL > /* > * Whitespaces > */ >-#line 886 "util_expr_scan.c" >+#line 872 "util_expr_scan.c" > > yylval = yylval_param; > >@@ -1519,7 +1505,7 @@ YY_RULE_SETUP > #line 398 "util_expr_scan.l" > YY_FATAL_ERROR( "flex scanner jammed" ); > YY_BREAK >-#line 1523 "util_expr_scan.c" >+#line 1509 "util_expr_scan.c" > case YY_STATE_EOF(INITIAL): > case YY_STATE_EOF(regex): > yyterminate(); >@@ -2251,8 +2237,8 @@ YY_BUFFER_STATE ap_expr_yy_scan_string (yyconst ch > > /** Setup the input buffer state to scan the given bytes. The next call to ap_expr_yylex() will > * scan from a @e copy of @a bytes. >- * @param yybytes the byte buffer to scan >- * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. >+ * @param bytes the byte buffer to scan >+ * @param len the number of bytes in the buffer pointed to by @a bytes. > * @param yyscanner The scanner object. > * @return the newly allocated buffer state object. > */ >Index: . >=================================================================== >--- . (revision 1809975) >+++ . (working copy) > >Property changes on: . >___________________________________________________________________ >Modified: svn:mergeinfo >## -0,0 +0,1 ## > Merged /httpd/httpd/trunk:r1809881,1809973,1809976
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 61558
:
35362
|
35363
|
35364
|
35365
|
35366
|
35367
|
35368
|
35369
|
35372
|
35375
|
35376
|
35377
|
35378
|
35379
|
35380
|
35381