leev / ngx_http_geoip2_module

Nginx GeoIP2 module
BSD 2-Clause "Simplified" License
983 stars 186 forks source link

Segmentation fault (segfault) when using multiple `geoip2` directives with `auto_reload` #75

Closed lucasrodcosta closed 5 years ago

lucasrodcosta commented 5 years ago

Hi everyone!

I'm observing a weird behaviour when I use the ngx_http_geoip2_module with multiple geoip2 directives (each one to load a different Maxmind's database) with auto_reload in them.

In summary, I've realised that in these situations just one database are being checked by module.
Besides that, when we update (with a touch, for instance) a database that is not being checked, Nginx starts to produce some segmentation faults.

I've noticed this issue in my production environment, but fortunately it's easy to reproduce it.
I created this gist with all the necessary code to reproduce.
Also, I created a video showing the issue. It's available in the following .tar.gz file (since Github doesn't support embedded videos): ngx_http_geoip2_module.tar.gz.

Thank you!

leev commented 5 years ago

Thanks for reporting the issue @lucasrodcosta. I'll take a look.

lucasrodcosta commented 5 years ago

Hi @leev! Do you have any update on this?

joseph-long commented 5 years ago

Is it possible this could cause symptoms like connections intermittently being reset (i.e. first time you hit a URL, the connection drops; next time, the page loads perfectly fine)? We also have multiple config blocks with autoreload.

leev commented 5 years ago

@lucasrodcosta I have had an initial test and was able to repeat the problem, however I haven't found the cause yet. For now, I recommend not using the autoreload. I will continue investigating to figure out whats happening.

lucasrodcosta commented 5 years ago

Hi @leev. Sorry to bother you, but do you have any update on this?

leev commented 5 years ago

Sorry for the delay. I actually put up a branch last night with a change that looks to be fixing the issue. I want to do some further testing, but would appreciate if you could also test https://github.com/leev/ngx_http_geoip2_module/tree/fix_reloading

lucasrodcosta commented 5 years ago

Hi @leev.

I just tested using that same gist (with the necessary adjustments to use the new branch) and everything worked as expected! \o/

Thank you so much!!! ❤️