Skip to content

Segmentation fault at line 756 of ngx_http_ubus_module.c #2

@tobiaswaldvogel

Description

@tobiaswaldvogel

I'm using OpenWRT with nginx and luci_statistics on one of my devices and I am collecting data for quite a lot of other devices.

After adding another device the statistics overview page stopped working and I found messages in the syslog about signal 11 (SIGSEV) for nginx worker processes.
After compiling nginx with debug symbols and installing libc with debug symbols I was able to identify the origin with valgrind in line 756 of ngx_http_ubus_module.c, by the looks because in->buf->pos = 0.

After reading a little bit through the nginx API for ngx_http_read_client_request_body I figured out that this is related to client_body_buffer_size, which defaults on my device to 8192. If the request is bigger (in my case 11520) then it is stored in a temp file rather than in buffers.

From http://nginx.org/en/docs/dev/development_guide.html
"The body can be saved in memory buffers or file buffers, if the capacity specified by the client_body_buffer_size directive is not enough to fit the entire body in memory."

As a workaround I increased client_body_buffer_size to 128k, which solved the problem for me.
Probably it is not worth implementing the file read logic, as usually UBUS requests are pretty small. But I would suggest throwing an error message if in->buf->pos == 0, saying that client_body_buffer_size should be increased.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions