I'm running gdb-5.0 on i686-pc-linux-gnu (Redhat 6.2) built with
./configure && make && make install. The machine happens to be a VA
Linux machine which we've upgraded with the following:

cpp-2.95.2-3
gcc-2.95.2-3
gcc-c++-2.95.2-3
libstdc++-2.95.2-3
libstdc++-compat-2.95.2-3
libstdc++-devel-2.95.2-3

After having a program exit in gdb, we will often issue a "run"
command to rerun the program. Sometimes, we'll see a message like

Warning: Cannot insert breakpoint -2:
Cannot access memory at address 0x400257e4

and gdb fails to restart the process. This only started happening in
gdb-5.0, we never saw it in 4.18. It doesn't happen everytime and it's
often hard to reproduce. Here's an example of my shell output when I
was able to reproduce it:

[eric@newelmo eric]$ cat test.cpp
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

class A
{
public:
char a[5000];
char s[5000];
char d[5000];
char f[5000];
char g[5000];
char h[5000];
char j[5000];
char k[5000];
char l[5000];
char q[5000];
char w[5000];
char e[5000];
char r[5000];
char t[5000];
char y[5000];
char u[5000];
char i[5000];
char o[5000];
char p[5000];
char z[5000];
char x[5000];
};

static A a1;
static A a2;
static A a3;
static A a4;
static A a5;
static A a6;
static A a7;
static A a8;
static A a9;
static A a10;
static A a11;
static A a12;
static A a13;

void * thread1(void *)
{
  printf("thread1\n");
}

void * thread2(void *)
{
  printf("thread2\n");
}

int main()
{
  pthread_t t1, t2;

  pthread_create(&t1, NULL, thread1, NULL);
  exit(1);
  pthread_create(&t2, NULL, thread2, NULL);

  sleep(1);
  printf("main thread\n");
  return 0;
}
[eric@newelmo eric]$ cat debug.txt
break main
run
cont
cont
cont
cont
cont
cont
cont
cont
cont
run
[eric@newelmo eric]$ g++ -o test test.cpp
/tmp/ccJ9VeQx.o: In function `main':
/tmp/ccJ9VeQx.o(.text+0x58): undefined reference to `pthread_create'
/tmp/ccJ9VeQx.o(.text+0x7a): undefined reference to `pthread_create'
collect2: ld returned 1 exit status
[eric@newelmo eric]$ g++ -o test test.cpp -lpthread
[eric@newelmo eric]$ gdb ./test < debug.txt
GNU gdb 5.0
Copyright 2000 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 "i686-pc-linux-gnu"...
(gdb) Breakpoint 1 at 0x804869a
(gdb) Starting program: /home/eric/./test 
[New Thread 1024 (runnable)]
[Switching to Thread 1024 (runnable)]

Breakpoint 1, 0x804869a in main ()
(gdb) Continuing.
[New Thread 2049 (runnable)]
[New Thread 1026 (runnable)]
thread1

Program received signal SIGTRAP, Trace/breakpoint trap.
[Switching to Thread 1026 (runnable)]
0x0 in ?? ()
(gdb) Continuing.

Program received signal SIGILL, Illegal instruction.
0x0 in ?? ()
(gdb) Continuing.

Program terminated with signal SIGILL, Illegal instruction.
The program no longer exists.
(gdb) The program is not being run.
(gdb) The program is not being run.
(gdb) The program is not being run.
(gdb) The program is not being run.
(gdb) The program is not being run.
(gdb) The program is not being run.
(gdb) Starting program: /home/eric/./test 
warning: Cannot insert breakpoint -2:
Cannot access memory at address 0x400257e4
(gdb) [eric@newelmo eric]$ 

The example is a bit contrived, but I tried to add some complexity of
multiple threads and static instances of a class which allocate large
chunks of memory. In our production system in-house, we see errors
like this pretty often.

Has anyone reported errors like this yet? We'd be willing to help in
any way for this bug to be fixed. If you'd like me to build a debug
version of gdb and give you information, let me know.

Reply via email to