This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: GDB step command crashed on non-stop mode


Hello,

I am using GDB non-stop mode to debug a multi-thread application. But it always crashed when I use "step" command. I have tried version 7.4/7.5.1/7.6, there result are same. The issue does not exist if we don't use non-stop mode.
I have written a small program to test, easy to reproduce each time. The code as below:

// test.cc 
#include <string>
using namespace std;
void fun(string &str1, string &str2)
{
    str1 += str2;
}

int main(void)
{
   string str1 = "abc";
   string str2 = "def";
   fun(str1,str2);
   
   return 0;
}


Compile:
g++ -g test.cc -o test


The procedure for reproduce as below:
vm10-0-0-1:/root-# gdb ./test
GNU gdb (GDB) 7.6
Copyright (C) 2013 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 "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /root/test...done.
(gdb) set target-async 1
(gdb) set non-stop on
(gdb) break fun                             
Breakpoint 1 at 0x4007b4: file test.cc, line 5.
(gdb) run 
Starting program: /root/test 

Breakpoint 1, fun (str1=..., str2=...) at test.cc:5
5           str1 += str2;
(gdb) step
6       }
(gdb) step

Program received signal SIGSEGV, Segmentation fault.
fun (str1=<error reading variable: Cannot access memory at address 0xfffffffffffffff8>, str1@entry=<error reading variable: Cannot access memory at address 0x8>, 
    str2=<error reading variable: Cannot access memory at address 0xfffffffffffffff0>, str2@entry=<error reading variable: Cannot access memory at address 0x8>) at test.cc:6
6       }
(gdb)


Does anyone know the root cause?

Thanks in advance,
Weisi


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]