如何理解 Gdb 中显示的奇怪内存地址?

How to understand a strange memory address shown in Gdb?

我正在使用 gdb 调试内存问题。 Gdb 给出了这个错误信息:

runtime error: member access within misaligned address 0x0000006d20f4 for type 'struct deque', which requires 8 byte alignment
0x0000006d20f4: note: pointer points here
  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
              ^ 

问题:地址显示如何

 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00

对应“0x0000006d20f4”?

正如您在消息本身中看到的那样,内存地址是 0x0000006d20f4,您突出显示的值是该内存位置的内容。

嗯....指针指向的地址是四的倍数,但不是八的倍数,所以在我看来,指针指向所示块的开头:

runtime error: member access within misaligned address 0x0000006d20f4 for type 'struct deque', which requires 8 byte alignment
0x0000006d20f4: note: pointer points here
  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
  ^  this is actually where the pointer is pointing.
              ^ this is actually address 0x0000006d20f8, which should be correctly  8byte aligned.  Probably where the pointer should be pointing.

是否可以检查 struct deque 定义,并确定您没有错并且不需要八字节对齐?您是否将 32 位架构定义与 64 位架构系统混淆了?请 post 代码,而不是你对可能发生的事情的想法。你认为你是对的,所以很难从你的想法中看出你的错误在哪里。您从哪里获得存储 struct deque 对象的内存?