This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/3072] New: Valgrind errors on dlopen
- From: "dennis dot smit at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 16 Aug 2006 05:50:48 -0000
- Subject: [Bug libc/3072] New: Valgrind errors on dlopen
- Reply-to: sourceware-bugzilla at sourceware dot org
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.
--
Summary: Valgrind errors on dlopen
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: dennis dot smit at gmail dot com
CC: glibc-bugs at sources dot redhat dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=3072
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.