【发布时间】:2016-11-15 03:46:02
【问题描述】:
我正在尝试调试一段汇编程序(x86 64-bit),根据gdb的信息,使用以下指令时它会崩溃:
xorpd 0x1770(%rip),%xmm12 # 0x40337c <S_0x403230>
但是,在我看来,内存0x40337c 完全正常:
(gdb) x /10x 0x40337c
0x40337c <S_0x403230>: 0x00000000 0x80000000 0x00000000 0x00000000
0x40338c <S_0x403240>: 0xf149f2ca 0x00000000 0x746e7973 0x203a7861
0x40339c <S_0x403248+8>: 0x206d626c 0x6d69743c
另一件连线的事情是,这段代码每次在我在命令行中运行时都会崩溃,在gdb 中也是如此。但是,当我在valgrind 中调试它时,它不会崩溃!
☁ src [master] ⚡ valgrind ./a.out 20 reference.dat 0 1 100_100_130_cf_a.of
==18329== Memcheck, a memory error detector
==18329== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==18329== Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info
==18329== Command: ./a.out 20 reference.dat 0 1 100_100_130_cf_a.of
==18329==
MAIN_printInfo:
grid size : 100 x 100 x 130 = 1.30 * 10^6 Cells
nTimeSteps : 20
result file : reference.dat
action : nothing
simulation type: channel flow
obstacle file : 100_100_130_cf_a.of
LBM_showGridStatistics:
nObstacleCells: 498440 nAccelCells: 0 nFluidCells: 801560
minRho: 1.0000 maxRho: 1.0000 mass: 1.300000e+06
minU: 0.000000e+00 maxU: 0.000000e+00
LBM_showGridStatistics:
nObstacleCells: 498440 nAccelCells: 0 nFluidCells: 801560
minRho: 1.0000 maxRho: 1.0431 mass: 1.300963e+06
minU: 0.000000e+00 maxU: 1.272361e-02
==18329==
==18329== HEAP SUMMARY:
==18329== in use at exit: 0 bytes in 0 blocks
==18329== total heap usage: 4 allocs, 4 frees, 428,801,136 bytes allocated
==18329==
==18329== All heap blocks were freed -- no leaks are possible
==18329==
==18329== For counts of detected and suppressed errors, rerun with: -v
==18329== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
我在here 上传了二进制代码供您参考,如果您有兴趣。汇编程序实际上是由二进制重写器生成的,我曾经能够生成无错误的代码。所以我相信这可能不是一个难以调试的指针取消引用问题,应该很容易修复。但是,我真的不知道哪里出了问题,在 gdb 调试中似乎完全正常(x/10x 0x40337 )
这是我的问题,
鉴于调试信息 (
x/10x 0x40337c),哪里可能出错?为什么二进制代码不会在
valgrind中崩溃?
【问题讨论】:
标签: assembly x86 gdb 64-bit valgrind