Hello!
On Tue, Mar 18, 2014 at 4:40 AM, Ross Timson wrote:
> I am using OpenResty to act as an API proxy and I'm experiencing seemingly
> random segfaults which causes the Nginx worker process to crash with 'signal
> 17 (SIGCHLD) received'. This seems to happen both when retrieving data
> direct from the app and from Memcached.
>
I see one obvious mistake in your Lua code that could lead to such
crashes. That is, you incorrectly cache the resty.memcached object
(and thus the underlying cosocket object) on the Lua module level
(i.e., the "memc" variable in your cache.lua module file). This will
make multiple requests access the same cosocket object, which is not
allowed at all. See
https://github.com/agentzh/lua-resty-memcached#limitations
You should only store the resty.memcached object in function local
variables, function parameters, or per-request storage like the
ngx.ctx table.
And yeah, crashing when the Lua programmer makes such mistakes is not
an option. I'll try adding checks to the cosocket API to explicitly
test whether the owner request and the current request do match.
Regards,
-agentzh