Skip to content

Commit

Permalink
Avoiding SEGFAULT calling pthread_join on a thread with id 0 (#656)
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusNi authored Mar 19, 2024
1 parent 35205d8 commit 515007e
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/platform/MpiServer.c
Original file line number Diff line number Diff line change
Expand Up @@ -634,20 +634,11 @@ void MpiInitialize(void)

void MpiShutdown(void)
{
int status = 0;

g_serverActive = false;

if (0 == (status = pthread_cancel(g_mpiServerWorker)))
{
if (0 != (status = pthread_join(g_mpiServerWorker, NULL)))
{
OsConfigLogError(GetPlatformLog(), "MpiShutdown: pthread_join failed with %d", status);
}
}
else
if (g_mpiServerWorker > 0)
{
OsConfigLogError(GetPlatformLog(), "MpiShutdown: pthread_cancel failed with %d", status);
pthread_join(g_mpiServerWorker, NULL);
}

UnloadModules();
Expand Down

0 comments on commit 515007e

Please sign in to comment.