• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            大龍的博客

            常用鏈接

            統(tǒng)計(jì)

            最新評(píng)論

            valgrind memcheck 錯(cuò)誤分析收藏 -------- 轉(zhuǎn)

            1.默認(rèn)使用工具memcheck

            2.輸出到XML文件:valgrind --leak-check=full --xml=yes --log-file="log.xml" myprog arg1 arg2

            3.錯(cuò)誤解釋

            3.1Illegal read / Illegal write errors

            例如:

            Invalid read of size 4
            at 0x40F6BBCC: (within /usr/lib/libpng.so.2.1.0.9)
            by 0x40F6B804: (within /usr/lib/libpng.so.2.1.0.9)
            by 0x40B07FF4: read_png_image(QImageIO *) (kernel/qpngio.cpp:326)
            by 0x40AC751B: QImageIO::read() (kernel/qimage.cpp:3621)
            Address 0xBFFFF0E0 is not stack'd, malloc'd or free'd
            這個(gè)錯(cuò)誤的發(fā)生是因?yàn)閷?duì)一些memcheck猜想不應(yīng)該訪問的內(nèi)存進(jìn)行了讀寫。
            3.2 Use of uninitialised values

            例如:

            Conditional jump or move depends on uninitialised value(s)
            at 0x402DFA94: _IO_vfprintf (_itoa.h:49)
            by 0x402E8476: _IO_printf (printf.c:36)
            by 0x8048472: main (tests/manuel1.c:8)
            這個(gè)錯(cuò)誤的發(fā)生是因?yàn)槭褂昧宋闯跏蓟臄?shù)據(jù)。一般情況下有兩種情形容易出現(xiàn)這個(gè)錯(cuò)誤:
            程序中的局部變量未初始化;
            C語言malloc的內(nèi)存未初始化;C++中new的對(duì)象其成員未被初始化。
             
            3.3 Illegal frees
            例如:
            Invalid free()
            at 0x4004FFDF: free (vg_clientmalloc.c:577)
            by 0x80484C7: main (tests/doublefree.c:10)
            Address 0x3807F7B4 is 0 bytes inside a block of size 177 free'd
            at 0x4004FFDF: free (vg_clientmalloc.c:577)
            by 0x80484C7: main (tests/doublefree.c:10)
             
            3.4 When a block is freed with an inappropriate deallocation function
            例如:
            Mismatched free() / delete / delete []
            at 0x40043249: free (vg_clientfuncs.c:171)
            by 0x4102BB4E: QGArray::~QGArray(void) (tools/qgarray.cpp:149)
            by 0x4C261C41: PptDoc::~PptDoc(void) (include/qmemarray.h:60)
            by 0x4C261F0E: PptXml::~PptXml(void) (pptxml.cc:44)
            Address 0x4BB292A8 is 0 bytes inside a block of size 64 alloc'd
            at 0x4004318C: operator new[](unsigned int) (vg_clientfuncs.c:152)
            by 0x4C21BC15: KLaola::readSBStream(int) const (klaola.cc:314)
            by 0x4C21C155: KLaola::stream(KLaola::OLENode const *) (klaola.cc:416)
            by 0x4C21788F: OLEFilter::convert(QCString const &) (olefilter.cc:272)
          1. If allocated with malloc, calloc, realloc, valloc or memalign, you must deallocate with free.

          2. If allocated with new[], you must deallocate with delete[].

          3. If allocated with new, you must deallocate with delete.

            linux系統(tǒng)對(duì)上述錯(cuò)誤可能不在意,但是移值到其他平臺(tái)時(shí)卻會(huì)有問題。

            3.5 Passing system call parameters with inadequate read/write permissions

          4. 例如:
            Syscall param write(buf) points to uninitialised byte(s)
            at 0x25A48723: __write_nocancel (in /lib/tls/libc-2.3.3.so)
            by 0x259AFAD3: __libc_start_main (in /lib/tls/libc-2.3.3.so)
            by 0x8048348: (within /auto/homes/njn25/grind/head4/a.out)
            Address 0x25AB8028 is 0 bytes inside a block of size 10 alloc'd
            at 0x259852B0: malloc (vg_replace_malloc.c:130)
            by 0x80483F1: main (a.c:5)
            Syscall param exit(error_code) contains uninitialised byte(s)
            at 0x25A21B44: __GI__exit (in /lib/tls/libc-2.3.3.so)
            by 0x8048426: main (a.c:8)
            Memcheck檢查所有的被系統(tǒng)調(diào)用的參數(shù)。
          5. It checks all the direct parameters themselves.

          6. Also, if a system call needs to read from a buffer provided by your program, Memcheck checks that the entire buffer is addressable and has valid data, ie, it is readable.

          7. Also, if the system call needs to write to a user-supplied buffer, Memcheck checks that the buffer is addressable.

            例如:

            #include <stdlib.h> #include <unistd.h> int main( void ) { char* arr = malloc(10); int* arr2 = malloc(sizeof(int)); write( 1 /* stdout */, arr, 10 ); exit(arr2[0]); }

            錯(cuò)誤信息:

            Syscall param write(buf) points to uninitialised byte(s) at 0x25A48723: __write_nocancel (in /lib/tls/libc-2.3.3.so) by 0x259AFAD3: __libc_start_main (in /lib/tls/libc-2.3.3.so) by 0x8048348: (within /auto/homes/njn25/grind/head4/a.out) Address 0x25AB8028 is 0 bytes inside a block of size 10 alloc'd at 0x259852B0: malloc (vg_replace_malloc.c:130) by 0x80483F1: main (a.c:5) Syscall param exit(error_code) contains uninitialised byte(s) at 0x25A21B44: __GI__exit (in /lib/tls/libc-2.3.3.so) by 0x8048426: main (a.c:8)

            傳遞了無效參數(shù)到系統(tǒng)函數(shù)中。

            3.6 Overlapping source and destination blocks

            C的以下庫函數(shù)拷貝數(shù)據(jù)從一塊內(nèi)存到另一塊內(nèi)存時(shí): memcpy(), strcpy(), strncpy(), strcat(), strncat(). 源和目的都不允許溢出。

            例如:

            ==27492== Source and destination overlap in memcpy(0xbffff294, 0xbffff280, 21) ==27492== at 0x40026CDC: memcpy (mc_replace_strmem.c:71) ==27492== by 0x804865A: main (overlap.c:40)

            3.7 Memory leak detection

            錯(cuò)誤信息:

            Still reachable: A pointer to the start of the block is found. This usually indicates programming sloppiness. Since the block is still pointed at, the programmer could, at least in principle, free it before program exit. Because these are very common and arguably not a problem, Memcheck won't report such blocks unless --show-reachable=yes is specified.

            Possibly lost, or "dubious": A pointer to the interior of the block is found. The pointer might originally have pointed to the start and have been moved along, or it might be entirely unrelated. Memcheck deems such a block as "dubious", because it's unclear whether or not a pointer to it still exists.

            Definitely lost, or "leaked": The worst outcome is that no pointer to the block can be found. The block is classified as "leaked

          8. posted on 2009-02-27 11:38 大龍 閱讀(2391) 評(píng)論(0)  編輯 收藏 引用


            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            久久久久久久久无码精品亚洲日韩| 国产精品99久久久久久人| 久久九九亚洲精品| 国内精品久久久久久久影视麻豆 | 色婷婷综合久久久中文字幕 | 久久亚洲精品视频| 中文字幕亚洲综合久久菠萝蜜| 丁香色欲久久久久久综合网| 国产一区二区三区久久精品| 久久精品中文无码资源站| 国产精品久久久久久影院 | 久久九九兔免费精品6| 伊人色综合久久| 亚洲精品国产成人99久久| 久久久久久无码国产精品中文字幕| 亚洲成色WWW久久网站| 色8激情欧美成人久久综合电| 久久99精品国产麻豆宅宅| 日本欧美国产精品第一页久久| 91久久精一区二区三区大全| 久久久久久久久66精品片| 久久久久这里只有精品| 久久国产精品波多野结衣AV| 色欲av伊人久久大香线蕉影院| 久久伊人五月天论坛| 7国产欧美日韩综合天堂中文久久久久| 国产精品久久新婚兰兰| 欧美国产精品久久高清| 久久青青草原综合伊人| 精品永久久福利一区二区 | 伊人久久精品无码av一区 | 精品久久久久久无码中文字幕一区| 久久久久久无码国产精品中文字幕 | 伊人久久精品影院| 欧美亚洲另类久久综合婷婷| 国产精品久久久天天影视香蕉| 青青草原综合久久| 2021精品国产综合久久| 91精品国产91久久久久福利| 久久精品夜夜夜夜夜久久| 国产精品久久久久国产A级|