nchan icon indicating copy to clipboard operation
nchan copied to clipboard

Crash with message forwarding on long reply from upstream (avoidable with proper config)

Open sobitcorp opened this issue 4 years ago • 0 comments

The following scenario:

  • Using message forwarding with nchan_publisher_upstream_request (and proxy_pass on the target location)
  • Modifying the message by replying with status 200 followed by the message
  • Sending a long response (more than nginx's current subrequest_output_buffer_size, including all response headers)

causes only a part of the message to be received (typically 4KB minus the size of response headers), followed by nginx worker thread crashing with either a segfault or a sigabrt with the following line logged to the error log: *** Error in 'nginx': double free or corruption (out): 0x... ***

This can be avoided by setting a higher subrequest_output_buffer_size - enough for the longest possible modified response message plus any response headers that the upstream will send.

This behavior will probably be better handled in the upcoming Nchan2, but for now, anyone maintaining the Nchan documentation, please consider documenting the need to set a proper subrequest_output_buffer_size when using message forwarding with modification, as the crash message is very nonspecific and can be hard to debug.

sobitcorp avatar Nov 08 '20 01:11 sobitcorp