« How to move an Impulse account to another machine without knowing your password or email address | Main | Fishing for clues for "my best bug ever" »

My best bug ever

This is obscure, but who said programming is always easy. Maybe more on this later, if I know whats going on. This is the disassembled code for -value:
0x35204c8a  <+0000>  push   %ebp
0x35204c8b  <+0001>  mov    %esp,%ebp
0x35204c8d  <+0003>  sub    $0x8,%esp
0x35204c90  <+0006>  mov    0x8(%ebp),%eax
0x35204c93  <+0009>  mov    0xc(%eax),%eax
0x35204c96  <+0012>  leave  
0x35204c97  <+0013>  ret 
and this is -key:
0x35204ea6  <+0000>  push   %ebp
0x35204ea7  <+0001>  mov    %esp,%ebp
0x35204ea9  <+0003>  sub    $0x8,%esp
0x35204eac  <+0006>  mov    0x8(%ebp),%eax
0x35204eaf  <+0009>  mov    0x8(%eax),%eax
0x35204eb2  <+0012>  leave  
0x35204eb3  <+0013>  ret    
I hightlighted the only difference in the assembly code between the two functions.

Stepping through the code, with the same object

There are breakpoints on 0x35204c90 and 0x35204eac -value works as expected but -key doesn't
(gdb) stepi
(gdb) p/x $eax
$16 = 0x30de9f0
(gdb) x/4 $eax
0x30de9f0: 0x35231f20 0x925c93a8 0x04a053c0 0x00d7dfa0
(gdb) x/x $eip
0x35204c93 <-[xxx value]+9>:	0xc90c408b
(gdb) stepi
(gdb) p/x $eax
$17 = 0xd7dfa0
(gdb) c
Continuing.
(gdb) stepi
(gdb) p/x $eax
$18 = 0x30de9f0
(gdb) x/4x 0x30de9f0
0x30de9f0: 0x35231f20 0x925c93a8 0x04a053c0 0x00d7dfa0
(gdb) x/x $eip
0x35204eaf <-[xxx key]+9>:	0xc908408b
(gdb) stepi
(gdb) p/x $eax
$19 = 0x20454c4c
(gdb) set $eip = 0x35204eaf
(gdb) set $eax = 0x30de9f0
(gdb) stepi
(gdb) p/x $eax
$20 = 0x20454c4c
(gdb) set $eip = 0x35204c93
(gdb) set $eax = 0x30de9f0
(gdb) stepi
(gdb) p/x $eax
$21 = 0xd7dfa0
(gdb) 
(gdb) x/4x 0x30de9f0
0x30de9f0: 0x35231f20 0x925c93a8 0x04a053c0 0x00d7dfa0
There is nothing ommitted, there is no other thread of mine running. 0xc908408b in Visual Studio is also mov eax,dword ptr [eax+8].

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About

This page contains a single entry from the blog posted on December 17, 2009 5:38 PM.

The previous post in this blog was How to move an Impulse account to another machine without knowing your password or email address.

The next post in this blog is Fishing for clues for "my best bug ever".

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 4.25