可访问指针在 gdb 中变得不可访问

问题描述 投票:0回答:0

我能够访问 GDB 中的内存地址,但是有时同一位置变得不可访问。请看一下 gdb 中指针 *gptr 的打印。我觉得很奇怪,不知道为什么。谁能向我解释这怎么可能?这个值是否依赖于时间?

/home/ubuntu#gdb -p  `pidof e2`
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
Attaching to process 1424839
[New LWP 1424840]
[New LWP 1424841]
[New LWP 1424842]
[New LWP 1424843]
[New LWP 1424844]
[New LWP 1424887]
[New LWP 1424888]
[New LWP 1424889]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

warning: Target and debugger are in different PID namespaces; thread lists and other data are likely unreliable.  Connect to gdbserver inside the container.
__pthread_clockjoin_ex (threadid=139701780469504, thread_return=0x0, clockid=<optimized out>, abstime=<optimized out>, block=<optimized out>) at pthread_join_common.c:145
145 pthread_join_common.c: No such file or directory.
(gdb) n

Thread 5 "e2" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7f0edbfff700 (LWP 1424843)]
SIwait (gptr=0x56073ee70060) at /home/ubuntu/shardul/nearrt-ric-plt/rmr/src/rmr/si/src/si95/siwait.c:123
123                                     if( (cbptr = gptr->cbtab[SI_CB_DISC].cbrtn) != NULL ) {
(gdb) p *gptr            ------------> value is accessible here
$1 = {magicnum = 219, tplist = 0x7f0ec4001b40, readfds = {__fds_bits = {0 <repeats 16 times>}}, writefds = {__fds_bits = {0, 0, 0, 0, 0, 0, 0, 281474976710656, 0, 0, 0, 0, 0, 0, 0, 0}}, execpfds = {__fds_bits = {
      0 <repeats 16 times>}}, rbuf = 0x0, cbtab = 0x0, fdcount = 0, flags = 0, tcp_flags = 0, rbuflen = 0, sierr = 0, tp_map = 0x0}
(gdb) p gptr->cbtab[SI_CB_DISC]
No symbol "SI_CB_DISC" in current context.
(gdb) p  SI_CB_DISC
No symbol "SI_CB_DISC" in current context.
(gdb) p  *gptr          --------------> value became inaccessible here. Why?
Cannot access memory at address 0x56073ee70060
c++ c gdb
© www.soinside.com 2019 - 2024. All rights reserved.