Menu

#182 event_gpio.c memory leak

New
None
Critical
Defect
2020-06-26
2020-06-26
No

Hi,

there are at least 2 issues in event_gpio.c

1) the creation of the thread is handled in add_event_detect. The thread is assigned to a local variable.
https://sourceforge.net/p/raspberry-gpio-python/code/ci/default/tree/source/event_gpio.c#l461
this should be global so when you cleanup the thread can be destroyed. Note that you already have the global variable declared but the creation is assigning it to the local variable.

2) when you execute a cleanup, the thread may be blocked at epoll_wait. You need to tell it to unblock so it can leave the execution, otherwise the thread stays alive causing a memory leak.
To solve that you can just cancel the thread once the list becomes null in the cleanup function.

I am attaching a file with this modifications (look for XV:)

as a side note would be good to use some sort of mutex to protect access to the global variables.

regards
X

1 Attachments

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.