aseprite / laf

A C++ library to create desktop applications
https://aseprite.github.io/laf/
MIT License
276 stars 60 forks source link

Don't use pthread_detach() after pthread_join() #49

Closed winterheart closed 1 year ago

winterheart commented 1 year ago

After pthread_join() all allocated to thread resources are freed, so pthread_detach() after pthread_join() will results in undefined behavior with SIGSERV on some libc implementations (like MUSL). According to pthread_detach(3), "Either pthread_join(3) or pthread_detach() should be called for each thread that an application creates".

I agree that my contributions are licensed under the MIT License. You can find a copy of this license at https://opensource.org/licenses/MIT

dacap commented 1 year ago

Thanks @winterheart, I'll take a look to this next week to merge it. There are plans to completely replace base::thread with std::thread in a near future (base::thread were pre-C++11 times).

dacap commented 1 year ago

@winterheart thanks for your PR here, anyway we have just removed base::thread and use std::thread instead, which was something planned from a long time ago. I guess that will be the best option to fix any issue in the old base::thread impl.