When pthread_join is called, we use uk_thread_wait to wait for the
thread to exit. However, this will also release the thread and the
metadata for the pthread in the glue code. pthread_join then calls
pthread_detach, which attempts another wait, accessing the freed
thread.
The commit changes the pte_osThreadHandle to point to the
metadata in the glue code instead of the thread itself and prevents
the metadata from being released on exit of the uk thread. This way,
pthread_detach can detect that the thread has already been released.
Metadata is freed in pte_osThreadDelete (would have caused a double
free before the patch).
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@kit.edu> Reviewed-by: Vlad-Andrei <vlad_andrei.badoiu@upb.ro> Approved-by: Simon Kuenzer <simon@unikraft.org> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #2