2013-02-11 101 views
1

我的老師說我的程序中有內存泄漏,所以我用valgrind來檢查它。我得到以下錯誤:在valgrind中檢查到內存泄漏

==24060== Invalid read of size 8 
==24060== at 0x4EB4B4C: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5E253: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5D328: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5CE85: setlocale (in /lib64/libc-2.16.so) 
==24060== by 0x401751: ??? (in /usr/bin/test) 
==24060== by 0x4E52804: (below main) (in /lib64/libc-2.16.so) 
==24060== Address 0x51dc040 is 0 bytes inside a block of size 5 alloc'd 
==24060== at 0x4C2AD7B: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) 
==24060== by 0x4E63D43: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5E23D: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5D328: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5CE85: setlocale (in /lib64/libc-2.16.so) 
==24060== by 0x401751: ??? (in /usr/bin/test) 
==24060== by 0x4E52804: (below main) (in /lib64/libc-2.16.so) 
==24060== 
==24060== Invalid read of size 8 
==24060== at 0x4EB4B54: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5E253: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5D328: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5CE85: setlocale (in /lib64/libc-2.16.so) 
==24060== by 0x401751: ??? (in /usr/bin/test) 
==24060== by 0x4E52804: (below main) (in /lib64/libc-2.16.so) 
==24060== Address 0x51dc048 is 3 bytes after a block of size 5 alloc'd 
==24060== at 0x4C2AD7B: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) 
==24060== by 0x4E63D43: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5E23D: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5D328: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5CE85: setlocale (in /lib64/libc-2.16.so) 
==24060== by 0x401751: ??? (in /usr/bin/test) 
==24060== by 0x4E52804: (below main) (in /lib64/libc-2.16.so) 
==24060== 
==24060== Invalid read of size 8 
==24060== at 0x4EB4931: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5E266: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5D328: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5CE85: setlocale (in /lib64/libc-2.16.so) 
==24060== by 0x401751: ??? (in /usr/bin/test) 
==24060== by 0x4E52804: (below main) (in /lib64/libc-2.16.so) 
==24060== Address 0x51dc040 is 0 bytes inside a block of size 5 alloc'd 
==24060== at 0x4C2AD7B: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) 
==24060== by 0x4E63D43: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5E23D: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5D328: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5CE85: setlocale (in /lib64/libc-2.16.so) 
==24060== by 0x401751: ??? (in /usr/bin/test) 
==24060== by 0x4E52804: (below main) (in /lib64/libc-2.16.so) 
==24060== 
==24060== Conditional jump or move depends on uninitialised value(s) 
==24060== at 0x4EB493F: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5DF87: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5D328: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5CE85: setlocale (in /lib64/libc-2.16.so) 
==24060== by 0x401751: ??? (in /usr/bin/test) 
==24060== by 0x4E52804: (below main) (in /lib64/libc-2.16.so) 
==24060== 
==24060== Conditional jump or move depends on uninitialised value(s) 
==24060== at 0x4E5DF8D: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5D328: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5CE85: setlocale (in /lib64/libc-2.16.so) 
==24060== by 0x401751: ??? (in /usr/bin/test) 
==24060== by 0x4E52804: (below main) (in /lib64/libc-2.16.so) 
==24060== 
==24060== Conditional jump or move depends on uninitialised value(s) 
==24060== at 0x4E5DFAF: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5D328: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5CE85: setlocale (in /lib64/libc-2.16.so) 
==24060== by 0x401751: ??? (in /usr/bin/test) 
==24060== by 0x4E52804: (below main) (in /lib64/libc-2.16.so) 
==24060== 
==24060== Use of uninitialised value of size 8 
==24060== at 0x4E5E033: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5D328: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5CE85: setlocale (in /lib64/libc-2.16.so) 
==24060== by 0x401751: ??? (in /usr/bin/test) 
==24060== by 0x4E52804: (below main) (in /lib64/libc-2.16.so) 
==24060== 
==24060== Use of uninitialised value of size 8 
==24060== at 0x4E5E041: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5D328: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5CE85: setlocale (in /lib64/libc-2.16.so) 
==24060== by 0x401751: ??? (in /usr/bin/test) 
==24060== by 0x4E52804: (below main) (in /lib64/libc-2.16.so) 
==24060== 
==24060== Conditional jump or move depends on uninitialised value(s) 
==24060== at 0x4E5E047: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5D328: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5CE85: setlocale (in /lib64/libc-2.16.so) 
==24060== by 0x401751: ??? (in /usr/bin/test) 
==24060== by 0x4E52804: (below main) (in /lib64/libc-2.16.so) 
==24060== 
==24060== Conditional jump or move depends on uninitialised value(s) 
==24060== at 0x4EB2E42: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5E06C: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5D328: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5CE85: setlocale (in /lib64/libc-2.16.so) 
==24060== by 0x401751: ??? (in /usr/bin/test) 
==24060== by 0x4E52804: (below main) (in /lib64/libc-2.16.so) 
==24060== 
==24060== Use of uninitialised value of size 8 
==24060== at 0x4EB4214: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5E06C: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5D328: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5CE85: setlocale (in /lib64/libc-2.16.so) 
==24060== by 0x401751: ??? (in /usr/bin/test) 
==24060== by 0x4E52804: (below main) (in /lib64/libc-2.16.so) 
==24060== 
==24060== Use of uninitialised value of size 8 
==24060== at 0x4EB4218: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5E06C: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5D328: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5CE85: setlocale (in /lib64/libc-2.16.so) 
==24060== by 0x401751: ??? (in /usr/bin/test) 
==24060== by 0x4E52804: (below main) (in /lib64/libc-2.16.so) 
==24060== 
==24060== Invalid read of size 8 
==24060== at 0x4EB2E1E: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5CECD: setlocale (in /lib64/libc-2.16.so) 
==24060== by 0x401751: ??? (in /usr/bin/test) 
==24060== by 0x4E52804: (below main) (in /lib64/libc-2.16.so) 
==24060== Address 0x51dc158 is 8 bytes inside a block of size 12 alloc'd 
==24060== at 0x4C2AD7B: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) 
==24060== by 0x4EB4591: strdup (in /lib64/libc-2.16.so) 
==24060== by 0x4E5E129: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5D328: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5CE85: setlocale (in /lib64/libc-2.16.so) 
==24060== by 0x401751: ??? (in /usr/bin/test) 
==24060== by 0x4E52804: (below main) (in /lib64/libc-2.16.so) 
==24060== 
==24060== Invalid read of size 8 
==24060== at 0x4EB4931: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4EB4585: strdup (in /lib64/libc-2.16.so) 
==24060== by 0x4E5CEE4: setlocale (in /lib64/libc-2.16.so) 
==24060== by 0x401751: ??? (in /usr/bin/test) 
==24060== by 0x4E52804: (below main) (in /lib64/libc-2.16.so) 
==24060== Address 0x51dc158 is 8 bytes inside a block of size 12 alloc'd 
==24060== at 0x4C2AD7B: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) 
==24060== by 0x4EB4591: strdup (in /lib64/libc-2.16.so) 
==24060== by 0x4E5E129: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5D328: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5CE85: setlocale (in /lib64/libc-2.16.so) 
==24060== by 0x401751: ??? (in /usr/bin/test) 
==24060== by 0x4E52804: (below main) (in /lib64/libc-2.16.so) 
==24060== 
==24060== Invalid read of size 8 
==24060== at 0x4EB2E23: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5DEFA: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5D328: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5CE85: setlocale (in /lib64/libc-2.16.so) 
==24060== by 0x401751: ??? (in /usr/bin/test) 
==24060== by 0x4E52804: (below main) (in /lib64/libc-2.16.so) 
==24060== Address 0x51dc158 is 8 bytes inside a block of size 12 alloc'd 
==24060== at 0x4C2AD7B: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) 
==24060== by 0x4EB4591: strdup (in /lib64/libc-2.16.so) 
==24060== by 0x4E5E129: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5D328: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5CE85: setlocale (in /lib64/libc-2.16.so) 
==24060== by 0x401751: ??? (in /usr/bin/test) 
==24060== by 0x4E52804: (below main) (in /lib64/libc-2.16.so) 
==24060== 
==24060== Invalid read of size 8 
==24060== at 0x4EB4931: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5C9D2: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5D0B2: setlocale (in /lib64/libc-2.16.so) 
==24060== by 0x401751: ??? (in /usr/bin/test) 
==24060== by 0x4E52804: (below main) (in /lib64/libc-2.16.so) 
==24060== Address 0x51dd568 is 8 bytes inside a block of size 12 alloc'd 
==24060== at 0x4C2AD7B: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) 
==24060== by 0x4EB4591: strdup (in /lib64/libc-2.16.so) 
==24060== by 0x4E5CEE4: setlocale (in /lib64/libc-2.16.so) 
==24060== by 0x401751: ??? (in /usr/bin/test) 
==24060== by 0x4E52804: (below main) (in /lib64/libc-2.16.so) 
==24060== 
==24060== Invalid read of size 8 
==24060== at 0x4EB2E1E: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5CA0F: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5D0B2: setlocale (in /lib64/libc-2.16.so) 
==24060== by 0x401751: ??? (in /usr/bin/test) 
==24060== by 0x4E52804: (below main) (in /lib64/libc-2.16.so) 
==24060== Address 0x51dd518 is 8 bytes inside a block of size 12 alloc'd 
==24060== at 0x4C2AD7B: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) 
==24060== by 0x4EB4591: strdup (in /lib64/libc-2.16.so) 
==24060== by 0x4E5CEE4: setlocale (in /lib64/libc-2.16.so) 
==24060== by 0x401751: ??? (in /usr/bin/test) 
==24060== by 0x4E52804: (below main) (in /lib64/libc-2.16.so) 
==24060== 
==24060== Invalid read of size 8 
==24060== at 0x4EB2E23: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5CA0F: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5D0B2: setlocale (in /lib64/libc-2.16.so) 
==24060== by 0x401751: ??? (in /usr/bin/test) 
==24060== by 0x4E52804: (below main) (in /lib64/libc-2.16.so) 
==24060== Address 0x51dd568 is 8 bytes inside a block of size 12 alloc'd 
==24060== at 0x4C2AD7B: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) 
==24060== by 0x4EB4591: strdup (in /lib64/libc-2.16.so) 
==24060== by 0x4E5CEE4: setlocale (in /lib64/libc-2.16.so) 
==24060== by 0x401751: ??? (in /usr/bin/test) 
==24060== by 0x4E52804: (below main) (in /lib64/libc-2.16.so) 
==24060== 
==24060== Invalid read of size 8 
==24060== at 0x4EB2E1E: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5CA83: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5D0B2: setlocale (in /lib64/libc-2.16.so) 
==24060== by 0x401751: ??? (in /usr/bin/test) 
==24060== by 0x4E52804: (below main) (in /lib64/libc-2.16.so) 
==24060== Address 0x51dd568 is 8 bytes inside a block of size 12 alloc'd 
==24060== at 0x4C2AD7B: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) 
==24060== by 0x4EB4591: strdup (in /lib64/libc-2.16.so) 
==24060== by 0x4E5CEE4: setlocale (in /lib64/libc-2.16.so) 
==24060== by 0x401751: ??? (in /usr/bin/test) 
==24060== by 0x4E52804: (below main) (in /lib64/libc-2.16.so) 
==24060== 
==24060== Invalid read of size 8 
==24060== at 0x4EB2E1E: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5CA9D: ??? (in /lib64/libc-2.16.so) 
==24060== by 0x4E5D0B2: setlocale (in /lib64/libc-2.16.so) 
==24060== by 0x401751: ??? (in /usr/bin/test) 
==24060== by 0x4E52804: (below main) (in /lib64/libc-2.16.so) 
==24060== Address 0x51dd568 is 8 bytes inside a block of size 12 alloc'd 
==24060== at 0x4C2AD7B: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) 
==24060== by 0x4EB4591: strdup (in /lib64/libc-2.16.so) 
==24060== by 0x4E5CEE4: setlocale (in /lib64/libc-2.16.so) 
==24060== by 0x401751: ??? (in /usr/bin/test) 
==24060== by 0x4E52804: (below main) (in /lib64/libc-2.16.so) 
==24060== 

任何人都可以幫助我理解這個錯誤是什麼意思?

+0

我發現,其實有沒有內存泄漏,但是我想要擺脫這些其他錯誤。 – 2013-02-12 10:26:59

+0

用'-g'編譯 – cnicutar 2013-02-12 10:43:17

+0

我用-g標誌編譯,但沒有幫助。也許問題是我在項目中有一個頭文件? – 2013-02-12 11:11:23

回答

1

爲什麼valgrind輸出不顯示行數?我不知道在哪裏尋找這個錯誤。 我編譯了一個程序,旗-g和使用的valgrind與語法如下: 的valgrind --tool = MEMCHECK --track-起源= YES -q測試

+0

您是否創建了新帳戶,以便您可以回答自己的問題? – 2013-02-12 11:57:01

+0

這是一個錯誤,對不起。 :) – 2013-02-12 12:12:22