Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential memory-leak in tinySAK (tsk_thread.c) #10

Closed
GoogleCodeExporter opened this issue Mar 14, 2016 · 3 comments
Closed

Potential memory-leak in tinySAK (tsk_thread.c) #10

GoogleCodeExporter opened this issue Mar 14, 2016 · 3 comments

Comments

@GoogleCodeExporter
Copy link

There is a potential memory in the "tsk_thread_create" function.

The first parameter is a pointer on a memory zone that will store the newly 
started thread handle. On Unix platform (with pthread), the pointed zone is 
allocated on the heap, but the deallocation only occurs if the 
"tsk_thread_join" is called.

Is it possible to add a note that specifies that the pointed zone needs to be 
freed by the caller in order to avoid memory leaks, either by calling 
"tsk_thread_join" or by freeing it ?

Original issue reported on code.google.com by laurent.etiemble@gmail.com on 22 Jun 2010 at 1:07

@GoogleCodeExporter
Copy link
Author

The same applies to Windows platform. If "tsk_thread_join" is not called, the 
thread HANDLE is never deallocated (See MSDN 
http://msdn.microsoft.com/en-us/library/ms682453.aspx):

The thread object remains in the system until the thread has terminated and all 
handles to it have been closed through a call to CloseHandle.

Original comment by laurent.etiemble@gmail.com on 22 Jun 2010 at 1:25

@GoogleCodeExporter
Copy link
Author

By convention, void** parameters are used to return values. As the returned 
value is a pointer this means that the caller is responsible for the newly 
allocated memory. If you don't wish to use "tsk_thread_join()", then you could 
simply use CloseHandle() or free() in the thread's id.
To avoid zombie threads, it's highly recommended to call tsk_thread_join().

Original comment by boss...@yahoo.fr on 28 Jun 2010 at 1:19

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

Original comment by boss...@yahoo.fr on 21 Aug 2010 at 10:17

  • Changed state: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant