Bug 122730

Summary: Problem with reentrant getservbyname_r() calls in threaded programs
Product: Red Hat Enterprise Linux 3 Reporter: Nils Philippsen <nphilipp>
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 3.0CC: fabrizio.muscarella, marcel.schriber
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: 2.3.2-95.27 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-09-25 21:28:02 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Test program
none
Different test program which shows the problem on FC2 as well none

Description Nils Philippsen 2004-05-07 15:24:15 UTC
Description of problem:

Threaded program crashes with multiple concurrent getservbyname_r()
calls on NIS boxes.

Version-Release number of selected component (if applicable):

glibc-2.3.2-95.6

How reproducible:

Easy

Steps to Reproduce:
1. Build test program (will attach shortly)
2. Execute test program
  
Actual results:

Program crashes

Expected results:

Threads each call getservbyname_r() consecutively for a number of
times, then after 30 seconds the program exits.

Additional info:

I could only reproduce this on RHEL3 when bound to a NIS domain,
RHEL2.1 and FC2 don't show this behaviour.

Comment 1 Nils Philippsen 2004-05-07 15:27:17 UTC
Created attachment 100080 [details]
Test program

Test program, compile with:

gcc -o main main.c -lpthread

run with:

./main

The program opens a number of threads which each consecutively call
getservbyname_r() for a nonexisting service "gurus" (just an example) a number
of times (200 in the attached test program).

Comment 2 Jakub Jelinek 2004-05-07 21:06:36 UTC
Are you able to reproduce this with glibc-2.3.2-95.20
(U2 glibc)?
There have been a bunch of fixes in exactly this part of the NIS
client code.

Comment 3 Nils Philippsen 2004-05-10 14:31:46 UTC
Yes, I got the SIGSEGV with 2.3.2-95.20 as well.

Comment 4 Jakub Jelinek 2004-05-25 13:03:34 UTC
http://sources.redhat.com/ml/libc-hacker/2004-05/msg00038.html
Wonder why you haven't seen it on FC2, wasn't it UP and a bit of sheer
luck?

Comment 5 Nils Philippsen 2004-07-29 09:23:34 UTC
Created attachment 102278 [details]
Different test program which shows the problem on FC2 as well

Another test program which shows the problem on FC2 as well, courtesy of
Fabrizio Muscarella, refined by me. Simply untar and make. Builds
nis_tst_getservbyname_r and nis_tst_getaddrinfo which use getservbyname_r() or
getaddrinfo() respectively.

Comment 6 Jakub Jelinek 2004-07-29 18:14:15 UTC
Can you reproduce it with glibc-2.3.3-31 or later though (rawhide/FC3t1)?

Comment 7 Ulrich Drepper 2004-08-26 06:38:01 UTC
Ping!?  I cannot reproduce any problem with glibc-2.3.3-45.i686.

The program prints
Oops... (Servname not supported for ai_socktype)


Comment 8 Nils Philippsen 2004-08-26 06:55:31 UTC
Oops indeed, will check when I have access to an FC3 box later in the day.

Comment 9 Fabrizio Muscarella 2004-08-26 08:30:35 UTC
Hi,

the output 'Oops...' is printed only by the second test program if you
compile it without USE_GETSERVBYNAME_R (bacause i forgot to check the
return value of getservbyname_r , mmmmm ;-( ). In this case will be
interesting to known if getservbyname_r is working too. 


Comment 10 Ulrich Drepper 2004-09-25 21:28:02 UTC
I see no failures with a current glibc version in neither versions of
the program in the second patch.  I mark the bug as fixed.  If you
still see failures, please reopen with appropriate instructions to
reproduce.