This repository has been archived by the owner on Apr 21, 2023. It is now read-only.
ngx_pagespeed crashes on start if there is no http block in config #1220
Comments
Reproduced. Can you try and confirm if this fixes the problem?: diff --git a/src/ngx_pagespeed.cc b/src/ngx_pagespeed.cc
index de60cfb..8676345 100644
--- a/src/ngx_pagespeed.cc
+++ b/src/ngx_pagespeed.cc
@@ -3014,7 +3014,7 @@ ngx_int_t ps_preaccess_handler(ngx_http_request_t* r) {
ngx_int_t ps_etag_filter_init(ngx_conf_t* cf) {
ps_main_conf_t* cfg_m = static_cast<ps_main_conf_t*>(
ngx_http_conf_get_module_main_conf(cf, ngx_pagespeed));
- if (cfg_m->driver_factory != NULL) {
+ if (cfg_m != NULL && cfg_m->driver_factory != NULL) {
ngx_http_ef_next_header_filter = ngx_http_top_header_filter;
ngx_http_top_header_filter = ps_etag_header_filter;
}
@@ -3096,6 +3096,11 @@ ngx_int_t ps_init_module(ngx_cycle_t* cycle) {
ps_main_conf_t* cfg_m = static_cast<ps_main_conf_t*>(
ngx_http_cycle_get_module_main_conf(cycle, ngx_pagespeed));
+ // See https://github.com/pagespeed/ngx_pagespeed/issues/1220
+ if (cfg_m == NULL) {
+ return NGX_OK;
+ }
+
ngx_http_core_main_conf_t* cmcf = static_cast<ngx_http_core_main_conf_t*>(
ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module));
ngx_http_core_srv_conf_t** cscfp = static_cast<ngx_http_core_srv_conf_t**>(
@@ -3163,7 +3168,7 @@ void ps_exit_child_process(ngx_cycle_t* cycle) {
ps_main_conf_t* cfg_m = static_cast<ps_main_conf_t*>(
ngx_http_cycle_get_module_main_conf(cycle, ngx_pagespeed));
NgxBaseFetch::Terminate();
- if (cfg_m->driver_factory != NULL) {
+ if (cfg_m != NULL && cfg_m->driver_factory != NULL) {
cfg_m->driver_factory->ShutDown();
}
}
@@ -3173,7 +3178,7 @@ void ps_exit_child_process(ngx_cycle_t* cycle) {
ngx_int_t ps_init_child_process(ngx_cycle_t* cycle) {
ps_main_conf_t* cfg_m = static_cast<ps_main_conf_t*>(
ngx_http_cycle_get_module_main_conf(cycle, ngx_pagespeed));
- if (cfg_m->driver_factory == NULL) {
+ if (cfg_m == NULL || cfg_m->driver_factory == NULL) {
return NGX_OK;
} |
oschaaf
added a commit
that referenced
this issue
Jul 5, 2016
Perfect, in addition with this patch NGINX's test suite now passes 100% with Pagespeed compiled-in. Many thanks! |
oschaaf
added a commit
that referenced
this issue
Jul 6, 2016
crowell
changed the title
Segment fault with no http block
ngx_pagespeed crashes on start if there is no http block in config
Aug 12, 2016
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
It is plausible to have NGINX with Pagespeed compiled in but no HTTP block. For example the same NGINX binary used as a TCP/UDP or Mail only load balancer. In these cases the Pagespeed module expects the http configuration block and causes NGINX to segfault.
The text was updated successfully, but these errors were encountered: