Restrictions to modifying request->headers_in.headers in NGX_HTTP_PREACCESS_PHASE?

Ryan Burn rnickb731 at
Wed Mar 28 19:47:04 UTC 2018


I have a module that registers a handler to run in
NGX_HTTP_PREACCESS_PHASE. The handler adds headers to
request->headers_in.headers. This works as I would expect most of the
time. But I am seeing cases of some crashes when calling


Are there any restrictions where you are not allowed to push to
headers_in.headers like that in the preaccess phase?

This is the line that where the segfault is reported as happening:

And the backtrace (taken from

#0  0x0000561139f929ec in ngx_list_push ()
#1  0x00007f7a1adbb6ab in
ngx_opentracing::inject_span_context(opentracing::v1::Tracer const&,
ngx_http_request_s*, opentracing::v1::SpanContext const&) () from
#2  0x00007f7a1adbcf81 in
ngx_http_core_loc_conf_s*, ngx_opentracing::opentracing_loc_conf_t*)
() from /etc/nginx/modules/
#3  0x00007f7a1adbdce6 in
ngx_opentracing::on_enter_block(ngx_http_request_s*) () from
#4  0x000056113a097a33 in ngx_http_core_generic_phase ()
#5  0x000056113a093645 in ngx_http_core_run_phases ()
#6  0x000056113a08f03e in ngx_http_process_request ()
#7  0x000056113a09068c in ngx_http_process_request_line ()
#8  0x000056113a0a6be1 in ngx_epoll_process_events.lto_priv ()
#9  0x000056113a0c45df in ngx_process_events_and_timers ()
#10 0x000056113a0a8405 in ngx_worker_process_cycle ()
#11 0x000056113a0be07f in ngx_spawn_process ()
#12 0x000056113a0a9715 in ngx_master_process_cycle ()
#13 0x0000561139f8a654 in main ()

More information about the nginx-devel mailing list