[Bug 483594] Re: timer_create and timer_delete cause valgrind errors

Nate Eldredge 483594 at bugs.launchpad.net
Sun Feb 23 21:32:57 UTC 2020


Cannot reproduce under 19.10 amd64.

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to glibc in Ubuntu.
https://bugs.launchpad.net/bugs/483594

Title:
  timer_create and timer_delete cause valgrind errors

Status in glibc package in Ubuntu:
  Confirmed

Bug description:
  Using timer_create/timer_delete causes an untold number of valgrind
  errors in programs which use timers heavily.

  glibc 2.9-4
  Linux 2.6.28-15-generic #52-Ubuntu SMP Wed Sep 9 10:49:34 UTC 2009 i686 GNU/Linux
  Ubuntu 9.04

  Some of the errors may be attributable to this bug:
  https://bugs.launchpad.net/bugs/264868

  However, the following is the minimal program for generating valgrind
  errors using timer_create/delete and doesn't even start the timer so
  is not attributable to the above bug. The error occurs whether the
  timer is started or not.

  #include <time.h>
  #include <signal.h>
  #include <memory.h>
  #include <assert.h>

  void callback( sigval_t parameter )
  {    
  }

  int main( int argc, char** argv )
  {
      sigevent_t se;
      memset( &se, 0 , sizeof(se) ); // just to be sure all of se is initialised
      se.sigev_notify = SIGEV_THREAD;
      se.sigev_value.sival_ptr = 0; 
      se.sigev_notify_function = callback;
      se.sigev_notify_attributes = 0;

      timer_t t;
      int err = timer_create( CLOCK_MONOTONIC, &se, &t );
      assert( err != -1 );
      timer_delete( t );

      return 0;
  }

  When compiled using 'gcc -g main.c -lrt' this will produce the
  following valgrind output:

  $ valgrind --track-origins=yes --leak-check=full ./a.out 
  ==11225== Memcheck, a memory error detector.
  ==11225== Copyright (C) 2002-2008, and GNU GPL'd, by Julian Seward et al.
  ==11225== Using LibVEX rev 1884, a library for dynamic binary translation.
  ==11225== Copyright (C) 2004-2008, and GNU GPL'd, by OpenWorks LLP.
  ==11225== Using valgrind-3.4.1-Debian, a dynamic binary instrumentation framework.
  ==11225== Copyright (C) 2000-2008, and GNU GPL'd, by Julian Seward et al.
  ==11225== For more details, rerun with: -v
  ==11225== 
  ==11225== Conditional jump or move depends on uninitialised value(s)
  ==11225==    at 0x40454D4: timer_delete (in /lib/tls/i686/cmov/librt-2.9.so)
  ==11225==    by 0x8048527: main (main.c:22)
  ==11225==  Uninitialised value was created by a heap allocation
  ==11225==    at 0x4026FDE: malloc (vg_replace_malloc.c:207)
  ==11225==    by 0x404534E: timer_create (in /lib/tls/i686/cmov/librt-2.9.so)
  ==11225==    by 0x80484EF: main (main.c:20)
  ==11225== 
  ==11225== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 15 from 1)
  ==11225== malloc/free: in use at exit: 136 bytes in 1 blocks.
  ==11225== malloc/free: 2 allocs, 1 frees, 192 bytes allocated.
  ==11225== For counts of detected errors, rerun with: -v
  ==11225== searching for pointers to 1 not-freed blocks.
  ==11225== checked 84,192 bytes.
  ==11225== 
  ==11225== 
  ==11225== 136 bytes in 1 blocks are possibly lost in loss record 1 of 1
  ==11225==    at 0x4025092: calloc (vg_replace_malloc.c:397)
  ==11225==    by 0x401134B: _dl_allocate_tls (in /lib/ld-2.9.so)
  ==11225==    by 0x41B3672: pthread_create@@GLIBC_2.1 (in /lib/tls/i686/cmov/libpthread-2.9.so)
  ==11225==    by 0x4046501: (within /lib/tls/i686/cmov/librt-2.9.so)
  ==11225==    by 0x41B95CF: pthread_once (in /lib/tls/i686/cmov/libpthread-2.9.so)
  ==11225==    by 0x80484EF: main (main.c:20)
  ==11225== 
  ==11225== LEAK SUMMARY:
  ==11225==    definitely lost: 0 bytes in 0 blocks.
  ==11225==      possibly lost: 136 bytes in 1 blocks.
  ==11225==    still reachable: 0 bytes in 0 blocks.
  ==11225==         suppressed: 0 bytes in 0 blocks.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/483594/+subscriptions



More information about the foundations-bugs mailing list