1

Valgrindの出力を理解するのに少し問題があります。

1>「サイズ4の無効な書き込み」が自動生成されたadbファイルに表示されます。

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

gnat_exit_statusは次のように定義されます。

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

2>「シグナル11(SIGSEGV)のデフォルトアクションでプロセスが終了します」これはvalgrindですか、それとも私のプログラムですか?valgrindから139の戻り値を取得しますが、mainを単独で実行すると、0が取得されます。これは、私が期待していることです。

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
$ 

感謝するどんな助けでも:)

NWS

4

1 に答える 1

2

私は大学時代からValgrindを使用していませんが、正しい方法であなたを指すために私があなたに与えることができるいくつかのことがあります。

まず、progのコンパイル方法が違いを生むことを知っています。-gフラグを使用し、-O#(最適化)は使用しないでください。さらに、私は常に-vを指定してValgrindを実行したため、最も多くの情報(多くの情報)が出力されます。

このページをチェックしてください:http: //www.redhat.com/magazine/015jan06/features/valgrind/

途中で「valgrindを実行する前に」というタイトルのセクションがあり、「valgrindエラーレポートの読み方」が役に立ちます。

于 2011-06-08T18:49:29.860 に答える