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

Bug#347793: libc6-dev: most basic pthread program produces strange messages on stderr at exit



Package: libc6-dev
Version: 2.3.5-8
Severity: normal

This minimal program, test_threads.c:

   #include <assert.h>
   #include <pthread.h>
   #include <stdio.h>
   #include <stdlib.h>

   int thread_return;

   void *
   thread_function (void *arg)
   {
     int idx;
     for ( idx = 0 ; idx < 3 ; idx++ ) {
       sleep (1);
       printf ("thread_arg: %d\n", *((int *)arg));
     }

     thread_return = 42;

     pthread_exit (&thread_return);
   }


   int
   main (void)
   {
     int thread_arg = 2;
     pthread_t thread;
  
     int return_code;

     //  pthread_attr_t thread_attrs;
     //  return_code = pthread_attr_init (&thread_attrs);
    
     return_code = pthread_create (&thread, NULL, thread_function,
                                (void *) &thread_arg);
     assert (return_code == 0);

     int **return_location;
     return_code = pthread_join (thread, (void **) return_location);
     assert (return_code == 0);

     printf ("thread_return: %d\n", **return_location);

     return 0;
   }

Compiled this way:

   gcc -Wall -D_REENTRANT test_threads.c -lpthread -o test

without any errors or warnings, produces this output when run:

   thread_arg: 2
   thread_arg: 2
   thread_arg: 2
   thread_return: 42
         1581:
         1581:     runtime linker statistics:
         1581:                final number of relocations: 139
         1581:     final number of relocations from cache: 7

with the latter four lines being on stderr.  Is there some debugging
information that didn't get turned off or something?  I guess this
might be a libc bug report?

Uncommenting the lines that set up the thread_attrs structure and
passing a pointer to it to pthread_create insteal of NULL as the
second argument yields a different weird output:

   thread_arg: 2
   thread_arg: 2
   thread_arg: 2
   thread_return: 42
      1598:     binding file /lib/tls/libpthread.so.0 to
      /lib/tls/libc.so.6: normal symbol `__cxa_finalize' [GLIBC_2.1.3]
      1598:     binding file /lib/libgcc_s.so.1 to /lib/tls/libc.so.6:
      normal symbol `__cxa_finalize' [GLIBC_2.1.3]

Thanks,
Britton

-- System Information:
Debian Release: testing/unstable
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.8-1-k7
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages libc6-dev depends on:
ii  libc6                      2.3.5-8       GNU C Library: Shared libraries an
ii  linux-kernel-headers       2.6.13+0rc3-2 Linux Kernel Headers for developme

Versions of packages libc6-dev recommends:
ii  gcc [c-compiler]             4:4.0.2-2   The GNU C compiler
ii  gcc-2.95 [c-compiler]        1:2.95.4-22 The GNU C compiler
ii  gcc-3.2 [c-compiler]         1:3.2.3-9   The GNU C compiler
ii  gcc-3.3 [c-compiler]         1:3.3.6-10  The GNU C compiler
ii  gcc-4.0 [c-compiler]         4.0.2-5     The GNU C compiler

-- no debconf information



Reply to: