Bug 483262 - Valgrind doesn't work with GDB properly
Valgrind doesn't work with GDB properly
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: gdb (Show other bugs)
All Linux
high Severity medium
: rc
: ---
Assigned To: Jan Kratochvil
: Regression
Depends On: 233746 453688
  Show dependency treegraph
Reported: 2009-01-30 11:13 EST by Jan Kratochvil
Modified: 2010-09-13 23:36 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 453688
Last Closed: 2010-09-13 23:36:08 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Jan Kratochvil 2009-01-30 11:13:06 EST
+++ This bug was initially created as a clone of Bug #453688 +++

Description of problem:
Attempting to use valgrind with --db-attach=yes on a program that triggers an
error, and then attaching gdb causes gdb to error, and is unusable. Once gdb
exits, valgrind resumes control, and the program (seems to) continue normally.

Version-Release number of selected component (if applicable):
broken: RHEL-4.6 gdb- (by valgrind-3.1.1-1.EL4.x86_64)
OK:     RHEL-4.5 gdb- (by valgrind-3.1.1-1.EL4.x86_64)

How reproducible:
Every time

Steps to Reproduce:
1. Create a program that causes valgrind to detect an error, such as an invalid
read or write. The following example is sufficient
#include <stdlib.h>

main() {
  int* arr = (int*)malloc(8);
  int j = arr[30];
  return 0;

2. Compile the example program (gcc -g3 -Wall val-db.c -o val-db)
3. Run valgrind with the following options "valgrind --db-attach=yes ./val-db"
Actual results:
GDB freaks out, and cannot debug. The following occurs on-screen:
[bash]root@x86-64-4as-6-m1.lab.bos.redhat.com:/root/jkratoch/redhat# valgrind --db-attach=yes ./val-db
==25917== Memcheck, a memory error detector.
==25917== Copyright (C) 2002-2005, and GNU GPL'd, by Julian Seward et al.
==25917== Using LibVEX rev 1575, a library for dynamic binary translation.
==25917== Copyright (C) 2004-2005, and GNU GPL'd, by OpenWorks LLP.
==25917== Using valgrind-3.1.1, a dynamic binary instrumentation framework.
==25917== Copyright (C) 2000-2005, and GNU GPL'd, by Julian Seward et al.
==25917== For more details, rerun with: -v
==25917== Invalid read of size 4
==25917==    at 0x4004C6: main (val-db.c:6)
==25917==  Address 0x4A3C0A8 is not stack'd, malloc'd or (recently) free'd
==25917== ---- Attach to debugger ? --- [Return/N/n/Y/y/C/c] ---- y
==25917== ---- Attach to debugger ? --- [Return/N/n/Y/y/C/c] ---- starting debugger
==25917== starting debugger with cmd: /usr/bin/gdb -nw /proc/25918/fd/1014 25918
GNU gdb Red Hat Linux (
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu"...Using host libthread_db library "/lib64/tls/libthread_db.so.1".

Attaching to program: /proc/25918/fd/1014, process 25918
Redelivering pending Segmentation fault.

valgrind: m_signals.c:1001 (default_action): Assertion 'VG_(is_running_thread)(tid)' failed.
==25918==    at 0x70010E08: report_and_quit (m_libcassert.c:122)

sched status:

Thread 1: status = VgTs_Runnable
==25918==    at 0x4004C6: main (val-db.c:6)

Note: see also the FAQ.txt in the source distribution.
It contains workarounds to several common problems.

If that doesn't help, please report this bug to: www.valgrind.org

In the bug report, send all the above text, the valgrind
version, and what Linux distro you are using.  Thanks.

Program process 0 exited: 1 (exited)

/root/jkratoch/redhat/25918: No such file or directory.

Expected results:
GDB attaches properly, and developer is able to debug the process.

Additional info:
Comment 1 Jan Kratochvil 2009-01-30 11:18:51 EST
Regression by the Bug 233746:
* Mon Jul 30 2007 Jan Kratochvil <jan.kratochvil@redhat.com> -
- Never lose any pending signal while attaching - resubmit them (BZ 233746).
Comment 2 RHEL Product and Program Management 2009-01-30 12:17:05 EST
This bugzilla has Keywords: Regression.  

Since no regressions are allowed between releases, 
it is also being proposed as a blocker for this release.  

Please resolve ASAP.

Note You need to log in before you can comment on or make changes to this bug.