Created attachment 5165 [details] repro test case The glibc function strchr() is returning a constant nonsense value when used by gdb. The original test case: perl -e 'system "gdb -p $$"' (gdb) set print pretty on (gdb) p $patchlevel_sv = *PL_patchlevel $1 = { sv_any = 0x9199030, sv_refcnt = 1, sv_flags = 17412, sv_u = { svu_pv = 0x919fe98 "v5.12.2", svu_iv = 152698520, svu_uv = 152698520, svu_rv = 0x919fe98, svu_array = 0x919fe98, svu_hash = 0x919fe98, svu_gp = 0x919fe98 } } (gdb) p $patchlevel = $patchlevel_sv->sv_u.svu_pv $2 = 0x919fe98 "v5.12.2" (gdb) p strcmp($patchlevel, "v5.10") $3 = 3998896 (gdb) p strcmp($patchlevel, "v5.12") $4 = 3998896 An automated, minimal test is attached in gdb-strcmp-repro.tar.gz: tar xzf gdb-strcmp-repro.tar.gz cd gdb-strcmp-repro make The internet complaint at http://old.nabble.com/call-strcmp-tt28828726.html#a28828726 might also be an instance of this.
I'm using version 7.2-1ubuntu3 as provided by the Ubuntu package repository. Also fails when I build the latest CVS rev. $ gdb -v GNU gdb (GDB) 7.2-ubuntu Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i686-linux-gnu". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>.
strcmp is the IFUNC symbol.
This is fixed in FSF GDB HEAD and GDB 7.3-prerelease branch. [patch 0/7] STT_GNU_IFUNC support http://sourceware.org/ml/gdb-patches/2011-03/msg00937.html You can download a GDB snapshot before gdb-7.3 gets released these days/weeks. http://www.gnu.org/software/gdb/current/