Launchpad has imported 2 comments from the remote bug at
http://sourceware.org/bugzilla/show_bug.cgi?id=3072.

If you reply to an imported comment from within Launchpad, your comment
will be sent to the remote bug automatically. Read more about
Launchpad's inter-bugtracker facilities at
https://help.launchpad.net/InterBugTracking.

------------------------------------------------------------------------
On 2006-08-16T05:50:46+00:00 Dennis-smit wrote:

While developing my application I kept having off by 4 reads on dlopen when
using valgrind.

I wrote the following test case:

#include <dlfcn.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

#define LIBTHINGY       "/usr/lib/libvisual-0.4/actor/actor_oinksie.so"

int main()
{
        void *handle;

        char *olee = malloc (strlen (LIBTHINGY) + 4);
        strcpy (olee, LIBTHINGY);

        printf ("STEP one\n");
        handle = dlopen (olee, RTLD_LAZY);
        dlclose (handle);
        printf ("STEP two\n");

        char *alabama = strdup (LIBTHINGY);
        handle = dlopen (alabama, RTLD_LAZY);
        dlclose (handle);
        printf ("STEP three\n");
        handle = dlopen (LIBTHINGY, RTLD_LAZY);
        dlclose (handle);
}


When compiled and ran through valgrind the version using strdup
gives an read off by 4 error, when I reduce the + 4 in the malloc statement
to something lower, I also get the same behavior.


 valgrind ./dloddness
==21672== Memcheck, a memory error detector.
==21672== Copyright (C) 2002-2005, and GNU GPL'd, by Julian Seward et al.
==21672== Using LibVEX rev 1471, a library for dynamic binary translation.
==21672== Copyright (C) 2004-2005, and GNU GPL'd, by OpenWorks LLP.
==21672== Using valgrind-3.1.0-Debian, a dynamic binary instrumentation 
framework.
==21672== Copyright (C) 2000-2005, and GNU GPL'd, by Julian Seward et al.
==21672== For more details, rerun with: -v
==21672==
STEP one
==21672== Conditional jump or move depends on uninitialised value(s)
==21672==    at 0x4010C93: (within /lib/ld-2.3.6.so)
==21672==    by 0x400624D: (within /lib/ld-2.3.6.so)
==21672==    by 0x4135C75: (within /lib/tls/i686/cmov/libc-2.3.6.so)
==21672==    by 0x400B105: (within /lib/ld-2.3.6.so)
==21672==    by 0x4136937: _dl_open (in /lib/tls/i686/cmov/libc-2.3.6.so)
==21672==    by 0x4035CB7: (within /lib/tls/i686/cmov/libdl-2.3.6.so)
==21672==    by 0x400B105: (within /lib/ld-2.3.6.so)
==21672==    by 0x40362BA: (within /lib/tls/i686/cmov/libdl-2.3.6.so)
==21672==    by 0x4035D10: dlopen (in /lib/tls/i686/cmov/libdl-2.3.6.so)
==21672==    by 0x80484D5: main (in 
/storage/libvisual-bromo2/blahblah/dloddness)
==21672==
==21672== Conditional jump or move depends on uninitialised value(s)
==21672==    at 0x4010C9E: (within /lib/ld-2.3.6.so)
==21672==    by 0x400624D: (within /lib/ld-2.3.6.so)
==21672==    by 0x4135C75: (within /lib/tls/i686/cmov/libc-2.3.6.so)
==21672==    by 0x400B105: (within /lib/ld-2.3.6.so)
==21672==    by 0x4136937: _dl_open (in /lib/tls/i686/cmov/libc-2.3.6.so)
==21672==    by 0x4035CB7: (within /lib/tls/i686/cmov/libdl-2.3.6.so)
==21672==    by 0x400B105: (within /lib/ld-2.3.6.so)
==21672==    by 0x40362BA: (within /lib/tls/i686/cmov/libdl-2.3.6.so)
==21672==    by 0x4035D10: dlopen (in /lib/tls/i686/cmov/libdl-2.3.6.so)
==21672==    by 0x80484D5: main (in 
/storage/libvisual-bromo2/blahblah/dloddness)
==21672==
==21672== Conditional jump or move depends on uninitialised value(s)
==21672==    at 0x4010CA9: (within /lib/ld-2.3.6.so)
==21672==    by 0x400624D: (within /lib/ld-2.3.6.so)
==21672==    by 0x4135C75: (within /lib/tls/i686/cmov/libc-2.3.6.so)
==21672==    by 0x400B105: (within /lib/ld-2.3.6.so)
==21672==    by 0x4136937: _dl_open (in /lib/tls/i686/cmov/libc-2.3.6.so)
==21672==    by 0x4035CB7: (within /lib/tls/i686/cmov/libdl-2.3.6.so)
==21672==    by 0x400B105: (within /lib/ld-2.3.6.so)
==21672==    by 0x40362BA: (within /lib/tls/i686/cmov/libdl-2.3.6.so)
==21672==    by 0x4035D10: dlopen (in /lib/tls/i686/cmov/libdl-2.3.6.so)
==21672==    by 0x80484D5: main (in 
/storage/libvisual-bromo2/blahblah/dloddness)
==21672==
==21672== Conditional jump or move depends on uninitialised value(s)
==21672==    at 0x400882D: (within /lib/ld-2.3.6.so)
==21672==    by 0x4135DE9: (within /lib/tls/i686/cmov/libc-2.3.6.so)
==21672==    by 0x400B105: (within /lib/ld-2.3.6.so)
==21672==    by 0x4136937: _dl_open (in /lib/tls/i686/cmov/libc-2.3.6.so)
==21672==    by 0x4035CB7: (within /lib/tls/i686/cmov/libdl-2.3.6.so)
==21672==    by 0x400B105: (within /lib/ld-2.3.6.so)
==21672==    by 0x40362BA: (within /lib/tls/i686/cmov/libdl-2.3.6.so)
==21672==    by 0x4035D10: dlopen (in /lib/tls/i686/cmov/libdl-2.3.6.so)
==21672==    by 0x80484D5: main (in 
/storage/libvisual-bromo2/blahblah/dloddness)
==21672==
==21672== Conditional jump or move depends on uninitialised value(s)
==21672==    at 0x4008852: (within /lib/ld-2.3.6.so)
==21672==    by 0x4135DE9: (within /lib/tls/i686/cmov/libc-2.3.6.so)
==21672==    by 0x400B105: (within /lib/ld-2.3.6.so)
==21672==    by 0x4136937: _dl_open (in /lib/tls/i686/cmov/libc-2.3.6.so)
==21672==    by 0x4035CB7: (within /lib/tls/i686/cmov/libdl-2.3.6.so)
==21672==    by 0x400B105: (within /lib/ld-2.3.6.so)
==21672==    by 0x40362BA: (within /lib/tls/i686/cmov/libdl-2.3.6.so)
==21672==    by 0x4035D10: dlopen (in /lib/tls/i686/cmov/libdl-2.3.6.so)
==21672==    by 0x80484D5: main (in 
/storage/libvisual-bromo2/blahblah/dloddness)
STEP two
==21672==
==21672== Invalid read of size 4
==21672==    at 0x4010C87: (within /lib/ld-2.3.6.so)
==21672==    by 0x400624D: (within /lib/ld-2.3.6.so)
==21672==    by 0x4135C75: (within /lib/tls/i686/cmov/libc-2.3.6.so)
==21672==    by 0x400B105: (within /lib/ld-2.3.6.so)
==21672==    by 0x4136937: _dl_open (in /lib/tls/i686/cmov/libc-2.3.6.so)
==21672==    by 0x4035CB7: (within /lib/tls/i686/cmov/libdl-2.3.6.so)
==21672==    by 0x400B105: (within /lib/ld-2.3.6.so)
==21672==    by 0x40362BA: (within /lib/tls/i686/cmov/libdl-2.3.6.so)
==21672==    by 0x4035D10: dlopen (in /lib/tls/i686/cmov/libdl-2.3.6.so)
==21672==    by 0x8048511: main (in 
/storage/libvisual-bromo2/blahblah/dloddness)
==21672==  Address 0x41692C4 is 44 bytes inside a block of size 46 alloc'd
==21672==    at 0x401C422: malloc (vg_replace_malloc.c:149)
==21672==    by 0x40A1FEF: strdup (in /lib/tls/i686/cmov/libc-2.3.6.so)
==21672==    by 0x80484FB: main (in 
/storage/libvisual-bromo2/blahblah/dloddness)
STEP three
==21672==
==21672== ERROR SUMMARY: 24 errors from 6 contexts (suppressed: 13 from 1)
==21672== malloc/free: in use at exit: 1,165 bytes in 8 blocks.
==21672== malloc/free: 53 allocs, 45 frees, 8,848 bytes allocated.
==21672== For counts of detected errors, rerun with: -v
==21672== searching for pointers to 8 not-freed blocks.
==21672== checked 97,552 bytes.
==21672==
==21672== LEAK SUMMARY:
==21672==    definitely lost: 95 bytes in 2 blocks.
==21672==      possibly lost: 0 bytes in 0 blocks.
==21672==    still reachable: 1,070 bytes in 6 blocks.
==21672==         suppressed: 0 bytes in 0 blocks.
==21672== Use --leak-check=full to see details of leaked memory.

Reply at: https://bugs.launchpad.net/glibc/+bug/114032/comments/0

------------------------------------------------------------------------
On 2006-08-21T16:03:09+00:00 Drepper-fsp wrote:

I see no problems in version 2.4 and higher.  Update.

Reply at: https://bugs.launchpad.net/glibc/+bug/114032/comments/1


** Changed in: glibc
   Importance: Unknown => Medium

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

Title:
  valgrind finds "Invalid read of size 4" in dlopen

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to