#281 libuuid leaks file descriptors for clock.txt

open
nobody
None
5
2012-11-28
2011-04-05
Anonymous
No

libuuid's get_clock() function uses GCC's built-in __thread modifier to declare a thread-local static variable containing an fd, and another containing a FILE*. Unfortunately AFAIK there's no support for a destructor call when a thread dies. As a result a program using libuuid and referring to the clock will leak one FD per thread and so eventually die.

Possible solutions:
1. Use pthreads' TLS implementation, which supports a destructor callback.
2. Push the requirement to the user: store this FD per user-created context and require that they see to destroying contexts.
2a. Do that somewhat half-assedly: support a thread-death callback that will clean up thread-local storage and require that user threads that have touched libuuid should make that callback.
3. Open it once, since you're already using file-locking to mostly-serialise operations on the file.

Discussion

  • txwX7r <a href="http://qrfhjnziwasn.com/">qrfhjnziwasn</a>, [url=http://blocfqjoudda.com/]blocfqjoudda[/url], [link=http://uuflkgrltwlv.com/]uuflkgrltwlv[/link], http://dduiqeudppdn.com/