bug-glibc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SIGSEGV in saveit, nss_nis/nis-service.c:72


From: Edin Zulic
Subject: SIGSEGV in saveit, nss_nis/nis-service.c:72
Date: Thu, 28 Jun 2001 15:16:00 -0700

I would appreciate your opinion on the following problem.

The multithreaded program below intermittently fails (every 5-10 runs) with
a memory fault. This seems very similar to the PR 1594. I'd appreciate if
you could confirm that the problem exists (or not!) with glibc 2.1.3, and
give the version of glibc that does not suffer from it.

Thank you very much!
Edin Zulic

--- Platform ---
- Linux 2.2.14-6.1.1smp
- gcc version 2.95.2 19991024 (release)
- GNU C Library stable release version 2.1.3, by Roland McGrath et al.

--- Build line ---
gcc -o ltb ltb.c -pthread

--- Test case ---
#include <pthread.h>
#include <stdio.h>
#include <netdb.h>

void *test_func(void *);

#define NUM_THREADS 10

int main(int argc, char **argv) {
  pthread_t thread_desc[NUM_THREADS];
  int i;

  for(i=0; i < NUM_THREADS; i++) {
    if (pthread_create(&thread_desc[i], NULL, test_func, (void *)i) != 0) {
      printf("failed to create thread %d\n", i);
      exit(1);
    }
  }

  for(i=0; i < NUM_THREADS; i++) {
    if (pthread_join(thread_desc[i], NULL) != 0) {
      printf("failed to join thread %d\n", i);
      exit(1);
    } else printf("thread %d joined\n", i);
  }
  return 0;
}

void *test_func(void *data)
{
  int tid = (int)data;

  const size_t bufsz = 8192;
  char buf[bufsz];
  struct servent ss;
  struct servent* sp = &ss;

  getservbyport_r(20480, 0, sp, buf, bufsz, &sp);
  if (sp!=0)
      printf("-----> thread: %d: %s, %d, %s\n", tid, sp->s_name, sp->s_port,
sp->s_proto);

  return NULL;
}

-- Failure ---
Program received signal SIGSEGV, Segmentation fault.
0x40126f2e in saveit (instatus=1, inkey=0xbf7fdb54 "3001/tcp", inkeylen=8, 
    inval=0xbf7fdb08 "db2v50servi     3001/tcp", ' ' <repeats 24 times>, "#
DB2 V5.0 server (Sound)", 
    invallen=73, indata=0xbedfdcdc "ȼ\a\b") at nss_nis/nis-service.c:72
72      nss_nis/nis-service.c: No such file or directory.

--- Backtrace ---
(gdb) bt
#0  0x40126f2e in saveit (instatus=1, inkey=0xbf7fdb54 "3001/tcp",
inkeylen=8, 
    inval=0xbf7fdb08 "db2v50servi     3001/tcp", ' ' <repeats 24 times>, "#
DB2 V5.0 server (Sound)", 
    invallen=73, indata=0xbedfdcdc "ȼ\a\b") at nss_nis/nis-service.c:72
#1  0x401336aa in __xdr_ypresp_all (xdrs=0x807145c, objp=0xbf7fdc48) at
ypclnt.c:648
#2  0x400fe260 in clnttcp_call (h=0x8071478, proc=8, xdr_args=0x4013240c
<xdr_ypreq_nokey>, 
    args_ptr=0xbf7fdc4c " \013\024@'address@hidden", xdr_results=0x40133584
<__xdr_ypresp_all>, 
    results_ptr=0xbf7fdc48 "\001", timeout={tv_sec = 25, tv_usec = 0}) at
clnt_tcp.c:318
#3  0x4013387e in yp_all (indomain=0x40140b20 "NIS-ROGUEWAVE.COM",
inmap=0x4012bd27 "services.byname", 
    incallback=0xbf7fdc8c) at ypclnt.c:713
#4  0x401267bf in internal_nis_getservent_r (serv=0xbf7ffd70,
buffer=0xbf7fdd50 "", buflen=8192, 
    errnop=0xbf7ffe88, data=0xbf7fdcdc) at nss_nis/nis-service.c:106
#5  0x40126e2d in _nss_nis_getservbyport_r (port=20480, protocol=0x0,
serv=0xbf7ffd70, buffer=0xbf7fdd50 "", 
    buflen=8192, errnop=0xbf7ffe88) at nss_nis/nis-service.c:376
#6  0x400f7058 in __getservbyport_r (port=20480, proto=0x0,
resbuf=0xbf7ffd70, buffer=0xbf7fdd50 "", 
    buflen=8192, result=0xbf7ffd6c) at ../nss/getXXbyYY_r.c:182
#7  0x80487d0 in test_func ()
#8  0x40021b85 in pthread_start_thread (arg=0xbf7ffe40) at manager.c:241

--- Complete output from a failed run ---
Starting program: /a/curl-e1b/export/devco/edin/ltbug/ltb4 
[New Thread 29900 (manager thread)]
[New Thread 29893 (initial thread)]
[New Thread 29901]
[New Thread 29902]
[Switching to Thread 29901]
yp_all: clnt_call: RPC: Unable to receive; errno = Bad file descriptor
[New Thread 29906]
[Switching to Thread 29902]
-----> thread: 1: www, 20480, tcp
[New Thread 29907]
[New Thread 29908]
[New Thread 29909]
-----> thread: 0: www, 20480, tcp
yp_all: clnt_call: RPC: Unable to receive; errno = Bad file descriptor
-----> thread: 2: www, 20480, tcp
yp_all: clnt_call: RPC: Unable to send; errno = Bad file descriptor
-----> thread: 3: www, 20480, tcp
-----> thread: 4: www, 20480, tcp
[New Thread 29910]
[New Thread 29912]
-----> thread: 5: www, 20480, tcp
[New Thread 29914]
[New Thread 29915]
thread 0 joined
thread 1 joined
thread 2 joined
thread 3 joined
thread 4 joined
thread 5 joined
-----> thread: 6: www, 20480, tcp
-----> thread: 7: www, 20480, tcp
thread 6 joined
thread 7 joined
-----> thread: 9: www, 20480, tcp
[Switching to Thread 29914]

Program received signal SIGSEGV, Segmentation fault.
0x40126f2e in saveit (instatus=1, inkey=0xbe7fdb88 "2503/tcp", inkeylen=8, 
    inval=0xbe7fdb54 "sqlol\t\t2503/tcp\t\t\t# Informix OnLine Server v.
5", invallen=48, 
    indata=0xbe5fdcdc "address@hidden&address@hidden@") at 
nss_nis/nis-service.c:72
72      nss_nis/nis-service.c: No such file or directory.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]