GEOSContextHandle leak probably due to thread local storage destructing order

22 views
Skip to first unread message

Yong Li

unread,
Oct 18, 2018, 9:08:10 PM10/18/18
to Django users
I have seen consistent GEOSContextHandle leak when a thread using GEOS exits. The source code is in django/contrib/gis/geos.

I can get rid of the leak by clearing all attributes of io.thread_context before exiting that thread.

It seems to me that the root cause is the destructors of thread local objects in io.thread_context call GEOS functions, so they need the GEOSContextHandle. If threadsafe.thread_context has been cleared by Python engine, they will create another one.

Assume Python clears threading.local objects in this order:

1. thread_safe.thread_context
2. io.thread_context

When doing the second step above, it creates another GEOScontextHandle and saves to thread_safe.thread_context.handle. And this is never cleared again.

This is just my thought. Should a Django ticket be created for this?


Best regards,
Yong Li

Tim Graham

unread,
Oct 19, 2018, 7:51:06 PM10/19/18
to Django users
Yes, if you can demonstrate that Django is at fault, you may create a ticket.

If you're unsure, you might have better luck on the https://groups.google.com/forum/#!forum/geodjango mailing list.

Yong Li

unread,
Oct 23, 2018, 10:56:00 AM10/23/18
to Django users
Thanks. FYI, I created a ticket: https://code.djangoproject.com/ticket/29878
Reply all
Reply to author
Forward
0 new messages