title: Using malloc / free in android
body: <p>I use malloc() to allocate memory, when I am doing, I use 'free() to free memory.
  When I free it, I get 'ABORTING LIBC'. </p>
  
  <p>I print out the value of address when I alloc and free, it is 0x410f1008. 
  But when I free it, it is freeing 0x410f1000, why is that? </p>
  
  <pre><code>D/        ( 3076): build_: alloc 0x410f1008
  ...
  D/        ( 3076): build: free 0x410f1008
  F/libc    ( 3076): @@@ ABORTING: LIBC: ARGUMENT IS INVALID HEAP ADDRESS IN dlfree addr=0x410f1000
  F/libc    ( 3076): Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1), thread 3076 (test)
  I/DEBUG   ( 1647): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
  I/DEBUG   ( 1647): Build fingerprint: ''
  I/DEBUG   ( 1647): Revision: '0'
  I/DEBUG   ( 1647): pid: 3076, tid: 3076, name: test  &gt;&gt;&gt; test &lt;&lt;&lt;
  I/DEBUG   ( 1647): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr deadbaad
  I/DEBUG   ( 1647):     r0 00000055  r1 be960720  r2 00000003  r3 deadbaad
  I/DEBUG   ( 1647):     r4 400fa228  r5 410f1000  r6 be960748  r7 400ed73a
  I/DEBUG   ( 1647):     r8 410f1008  r9 ffffff82  sl 000829a0  fp 000007e0
  I/DEBUG   ( 1647):     ip 00000000  sp be960748  lr 400d9a29  pc 400bdffc  cpsr 00000030
  I/DEBUG   ( 1647):     d0  3830303166303134  d1  65696c63204d4d20
  I/DEBUG   ( 1647):     d2  0000000000000066  d3  0000000000000072
  I/DEBUG   ( 1647):     d4  0000000000000000  d5  0000000000000000
  I/DEBUG   ( 1647):     d6  0000000000000000  d7  94e7c71700000000
  I/DEBUG   ( 1647):     d8  0000000000000000  d9  0000000000000000
  I/DEBUG   ( 1647):     d10 0000000000000000  d11 0000000000000000
  I/DEBUG   ( 1647):     d12 0000000000000000  d13 0000000000000000
  I/DEBUG   ( 1647):     d14 0000000000000000  d15 0000000000000000
  I/DEBUG   ( 1647):     d16 c1dac60e3a4fdf3b  d17 3f50624dd2f1a9fc
  I/DEBUG   ( 1647):     d18 41a9f539c0000000  d19 0000000000000000
  I/DEBUG   ( 1647):     d20 0000000000000000  d21 0000000000000000
  I/DEBUG   ( 1647):     d22 0000000000000000  d23 0000000000000000
  I/DEBUG   ( 1647):     d24 0000000000000000  d25 0000000000000000
  I/DEBUG   ( 1647):     d26 0000000000000000  d27 0000000000000000
  I/DEBUG   ( 1647):     d28 0000000000000000  d29 0000000000000000
  I/DEBUG   ( 1647):     d30 0000000000000000  d31 0000000000000000
  I/DEBUG   ( 1647):     scr 00000010
  I/DEBUG   ( 1647): 
  I/DEBUG   ( 1647): backtrace:
  I/DEBUG   ( 1647):     #00  pc 0000effc  /system/lib/libc.so
  I/DEBUG   ( 1647):     #01  pc 00011da3  /system/lib/libc.so (dlfree+1458)
  I/DEBUG   ( 1647):     #02  pc 0000cf13  /system/lib/libc.so (free+10)
  I/DEBUG   ( 1647):     #03  pc 00002c25  /system/bin/ppm2jpg
  I/DEBUG   ( 1647):     #04  pc 0000316d  /system/bin/ppm2jpg
  I/DEBUG   ( 1647):     #05  pc 0001271f  /system/lib/libc.so (__libc_init+38)
  I/DEBUG   ( 1647):     #06  pc 00000b3c  /system/bin/ppm2jpg
  I/DEBUG   ( 1647): 
  I/DEBUG   ( 1647): stack:
  I/DEBUG   ( 1647):          be960708  00000001  
  I/DEBUG   ( 1647):          be96070c  400ed73a  /system/lib/libc.so
  I/DEBUG   ( 1647):          be960710  410f1008  
  I/DEBUG   ( 1647):          be960714  400d9a93  /system/lib/libc.so
  I/DEBUG   ( 1647):          be960718  00000010  
  I/DEBUG   ( 1647):          be96071c  00000007  
  I/DEBUG   ( 1647):          be960720  be96071c  [stack]
  I/DEBUG   ( 1647):          be960724  00000001  
  I/DEBUG   ( 1647):          be960728  400ed336  /system/lib/libc.so
  I/DEBUG   ( 1647):          be96072c  00000005  
  I/DEBUG   ( 1647):          be960730  be960754  [stack]
  I/DEBUG   ( 1647):          be960734  0000004f  
  I/DEBUG   ( 1647):          be960738  400fa228  
  </code></pre>