I am running django 1.9.4 on gunicorn19.4.5 with the gevent worker (gevent==1.0.2, greenlet==0.4.9). My app is deployed on heroku. For some requests, I have noticed this error: "*** Error in `/app/.heroku/python/bin/python': double free or corruption (out): 0x000000000403bc90 ***". I can't reproduce it deterministically, but it happen in about 5% of all requests. I was able to get the stack trace for it and everytime it's the same:
May 19 13:50:35 <app-name> app/web.2: File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/gis/geos/geometry.py", line 125, in __del__.
May 19 13:50:35 <app-name> app/web.2: capi.destroy_geom(self._ptr).
May 19 13:50:35 <app-name> app/web.2: File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/gis/geos/libgeos.py", line 157, in __call__.
May 19 13:50:35 <app-name> app/web.2: return self.func(*args, **kwargs).
May 19 13:50:35 <app-name> app/web.2: File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/gis/geos/prototypes/threadsafe.py", line 52, in __call__.
May 19 13:50:35 <app-name> app/web.2: if not self.thread_context.handle:.
May 19 13:50:35 <app-name> app/web.2: File "/app/.heroku/python/lib/python2.7/site-packages/gevent/local.py", line 173, in __getattribute__.
May 19 13:50:35 <app-name> app/web.2: d = object.__getattribute__(self, '_local__dicts').get(getcurrent()).
May 19 13:50:35 <app-name> app/web.2: *** Error in `/app/.heroku/python/bin/python': double free or corruption (out): 0x0000000003dd6470 ***