Skip to content

Commit 62985c7

Browse files
carlonlucaygrek
authored andcommitted
Fix segfault trying to acquire/release the master lock from unregistered thread
A thread that was never registered should not call enter_blocking_section or leave_blocking_section, as it cannot hold the master lock. This can cause segfaults in some cases.
1 parent 4baae66 commit 62985c7

File tree

1 file changed

+0
-10
lines changed

1 file changed

+0
-10
lines changed

src/utils/lib/stubs_c.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -722,28 +722,18 @@ static int ml_gethostbyname(char *hostname)
722722
struct hostent h;
723723
char buffer[NETDB_BUFFER_SIZE];
724724
int h_errno;
725-
enter_blocking_section();
726725
hp = gethostbyname_r(hostname, &h, buffer, sizeof(buffer), &h_errno);
727-
leave_blocking_section();
728726
}
729727
#elif HAS_GETHOSTBYNAME_R == 6
730728
{
731729
struct hostent h;
732730
char buffer[NETDB_BUFFER_SIZE];
733731
int h_errno, rc;
734-
enter_blocking_section();
735732
rc = gethostbyname_r(hostname, &h, buffer, sizeof(buffer), &hp, &h_errno);
736-
leave_blocking_section();
737733
if (rc != 0) hp = NULL;
738734
}
739735
#else
740-
#ifdef GETHOSTBYNAME_IS_REENTRANT
741-
enter_blocking_section();
742-
#endif
743736
hp = gethostbyname(hostname);
744-
#ifdef GETHOSTBYNAME_IS_REENTRANT
745-
leave_blocking_section();
746-
#endif
747737
#endif
748738

749739
if (hp == (struct hostent *) NULL) return 0;

0 commit comments

Comments
 (0)