开发者

Valgrind output confusing

I am having a bit of trouble understanding the Valgrind output:

1> "Invalid write of size 4" is coming up in an auto-generated adb file,

  return (gnat_exit_status); -- this is line 314 of b~main.adb

and the gnat_exit_status is defined like this:

   gnat_exit_status : Integer;
   pragma Import (C, gnat_exit_status);

2> "Process terminating with default action of signal 11 (SIGSEGV)" Is this valgrind or my program? I get a return value of 139 from valgrind, but when running main by itself, i get 0, which is what i expect!

Full output of memcheck:

$ valgrind ./main
==2844== Memcheck, a memory error detector
==2844== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==2844== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info
==2844== Command: ./main
==2844== 
=开发者_运维问答=2844== Invalid write of size 4
==2844==    at 0x804BA2F: main (b~main.adb:314)
==2844==  Address 0xbee56294 is not stack'd, malloc'd or (recently) free'd
==2844== 
==2844== 
==2844== Process terminating with default action of signal 11 (SIGSEGV)
==2844==  Access not within mapped region at address 0xBEE56294
==2844==    at 0x804BA2F: main (b~main.adb:314)
==2844==  If you believe this happened as a result of a stack
==2844==  overflow in your program's main thread (unlikely but
==2844==  possible), you can try to increase the size of the
==2844==  main thread stack using the --main-stacksize= flag.
==2844==  The main thread stack size used in this run was 8388608.
==2844== 
==2844== HEAP SUMMARY:
==2844==     in use at exit: 0 bytes in 0 blocks
==2844==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==2844== 
==2844== All heap blocks were freed -- no leaks are possible
==2844== 
==2844== For counts of detected and suppressed errors, rerun with: -v
==2844== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 19 from 8)
Segmentation fault
$ 

Any Help Appreciated :)

NWS


I haven't used Valgrind since college, but there are a few things i can give you to point you in the right way.

First i know that how the prog is compiled makes a difference. You should use the -g flag and NOT use -O# (optimization). Additionally, I always ran Valgrind with -v so it outputs the most info (lots of info).

Check out this page: http://www.redhat.com/magazine/015jan06/features/valgrind/

bout half way down is a section titled "Before running valgrind" and "How to read the valgrind error report" will help you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜