I am trying to debug a piece of assembly program (x86 64-bit
), and according to the gdb
info, it crashes when using the following instruction:
xorpd 0x1770(%rip),%xmm12 # 0x40337c <S_0x403230>
However, it seems to me that memory 0x40337c
is perfectly normal:
(gdb) x /10x 0x40337c
0x40337c <S_0x403230>: 0x00000000 0x80000000 0x00000000 0x00000000
0x40338c <S_0x403240>: 0xf149f2ca 0x00000000 0x746e7973 0x203a7861
0x40339c <S_0x403248+8>: 0x206d626c 0x6d69743c
Another wired thing is that, this piece of code crashes everytime when I run it in the command line, as well as inside gdb
. However, when I debug it in the valgrind
, it would not crash !
☁ 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)
I uploaded the binary code at here for your reference if you are interest. The assembly program is actually produced by a binary rewritter, and I used to be able to produce bug-free code. So I believe this may not be a hard-to-debug pointer dereference issue, should be something very easy to fix.. However, I really have no idea where goes wrong, and it seems perfectly normal in the gdb debugging (x/10x 0x40337
)
So here is my question,
given the debug info (
x/10x 0x40337c
), where could possibly go wrong?Why the binary code would not crash in
valgrind
?