saprykin / plibsys

Highly portable C system library: threads and synchronization primitives, sockets (TCP, UDP, SCTP), IPv4 and IPv6, IPC, hash functions (MD5, SHA-1, SHA-2, SHA-3, GOST), binary trees (RB, AVL) and more. Native code performance.
MIT License
672 stars 74 forks source link

Possible *small* memory leak? #92

Open ghost opened 3 years ago

ghost commented 3 years ago

While testing my program for memory leaks with valgrind, i happened to stumble upon 4 bytes that plibsys allocates not being freed.... while 4 bytes doesn't hugely matter, seeing as plibsys' goal is to run on embedded systems, possibly there it could mean a bit more? Image of the valgrind output, which also states where in the library you might find the memory leak. 2020-12-27_23-16

ghost commented 3 years ago

I will try the git master version, currently using latest release version, which is 0.4 Found out what might be the reason... very quick and simple fix if the git master version also still has the issue

ghost commented 3 years ago

Fix... all i really did add was 2 extra lines at the bottom... image Also, now no memory leaks reported by valgrind... image

ghost commented 3 years ago

Seems like master still has the "bug" image like i said, doesn't hugely matter, and im just glad you even made the library! Good job for almost leak free portable library, it really does make my life easier when i want to port my applications to other operating systems.

TheRealMichaelWang commented 5 months ago

I don't really think this is a bug. There's a puthread_replace_local(or some function like that) that actually calls the destructor. I don't think calling the behavior is intended behavior for set local.