LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Cannot use valgrind (https://www.linuxquestions.org/questions/programming-9/cannot-use-valgrind-518580/)

g4j31a5 01-12-2007 03:51 AM

Cannot use valgrind
 
Hi, recently my program can't be checked by valgrind. I don't know what caused it but it said that there's a segmentation fault. But when I tried running the program, it runs just fine. Is it because my bad design? Because honestly I didn't use design patterns at all. I designed my program as I see fit.

Here's a quick report from valgrind:

Quote:

==7763==
==7763== ERROR SUMMARY: 12 errors from 10 contexts (suppressed: 112 from 4)
==7763==
==7763== 1 errors in context 1 of 10:
==7763== Syscall param ioctl(arg) contains uninitialised byte(s)
==7763== at 0x1BCB4509: ioctl (in /lib/tls/libc-2.3.5.so)
==7763== by 0x1C0EFA45: (within /usr/lib/libasound.so.2.0.0)
==7763== by 0x1C0DEFE8: snd_pcm_hw_free (in /usr/lib/libasound.so.2.0.0)
==7763== by 0x1C10160C: (within /usr/lib/libasound.so.2.0.0)
==7763== by 0x1C0DEFE8: snd_pcm_hw_free (in /usr/lib/libasound.so.2.0.0)
==7763== by 0x1C0E8CA2: snd_pcm_close (in /usr/lib/libasound.so.2.0.0)
==7763== by 0x1BB74640: (within /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BB41576: SDL_AudioQuit (in /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BB40A14: SDL_QuitSubSystem (in /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BB40AA9: SDL_Quit (in /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BB40F4A: (within /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BBD08A7: (within /lib/tls/libpthread-2.3.5.so)
==7763==
==7763== 1 errors in context 2 of 10:
==7763== Syscall param ioctl(arg) contains uninitialised byte(s)
==7763== at 0x1BCB4509: ioctl (in /lib/tls/libc-2.3.5.so)
==7763== by 0x1C0EFDC5: (within /usr/lib/libasound.so.2.0.0)
==7763== by 0x1C0DEF31: snd_pcm_drop (in /usr/lib/libasound.so.2.0.0)
==7763== by 0x1C0E8C9A: snd_pcm_close (in /usr/lib/libasound.so.2.0.0)
==7763== by 0x1BB74640: (within /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BB41576: SDL_AudioQuit (in /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BB40A14: SDL_QuitSubSystem (in /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BB40AA9: SDL_Quit (in /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BB40F4A: (within /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BBD08A7: (within /lib/tls/libpthread-2.3.5.so)
==7763== by 0x80EA959: SDL_GUI::CBoxedString::CBoxedString(SDL_Surface*, short, short, short, short, unsigned char, unsigned char, unsigned char, SDL_GUI::CTTFont*, std::string, unsigned) (BoxedString.cpp:99)
==7763== by 0x80E80F4: SDL_GUI::CTextBox::changeValue(std::string) (TextBox.cpp:125)
==7763==
==7763== 1 errors in context 3 of 10:
==7763== Syscall param ioctl(arg) contains uninitialised byte(s)
==7763== at 0x1BCB4509: ioctl (in /lib/tls/libc-2.3.5.so)
==7763== by 0x1C0EFE55: (within /usr/lib/libasound.so.2.0.0)
==7763== by 0x1C0DF851: snd_pcm_drain (in /usr/lib/libasound.so.2.0.0)
==7763== by 0x1BB7462F: (within /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BB41576: SDL_AudioQuit (in /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BB40A14: SDL_QuitSubSystem (in /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BB40AA9: SDL_Quit (in /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BB40F4A: (within /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BBD08A7: (within /lib/tls/libpthread-2.3.5.so)
==7763== by 0x80EA959: SDL_GUI::CBoxedString::CBoxedString(SDL_Surface*, short, short, short, short, unsigned char, unsigned char, unsigned char, SDL_GUI::CTTFont*, std::string, unsigned) (BoxedString.cpp:99)
==7763== by 0x80E80F4: SDL_GUI::CTextBox::changeValue(std::string) (TextBox.cpp:125)
==7763== by 0x80A9EDE: CGUI_AuditHandler::initCurrentValues() (GUI_AuditHandler.cpp:350)
==7763==
==7763== 1 errors in context 4 of 10:
==7763== Invalid read of size 4
==7763== at 0x80E8C9F: SDL_GUI::CTTFStringImage::CTTFStringImage(SDL_Surface*, SDL_GUI::CTTFont*, short, short, std::string, unsigned) (TTFStringImage.cpp:54)
==7763== by 0x80EA959: SDL_GUI::CBoxedString::CBoxedString(SDL_Surface*, short, short, short, short, unsigned char, unsigned char, unsigned char, SDL_GUI::CTTFont*, std::string, unsigned) (BoxedString.cpp:99)
==7763== by 0x80E80F4: SDL_GUI::CTextBox::changeValue(std::string) (TextBox.cpp:125)
==7763== by 0x80A9EDE: CGUI_AuditHandler::initCurrentValues() (GUI_AuditHandler.cpp:350)
==7763== by 0x80AFE29: CGUI_AuditHandler::CGUI_AuditHandler(SDL_Surface*) (GUI_AuditHandler.cpp:285)
==7763== by 0x80A1D8E: CTestModeManager::CTestModeManager(CSceneManager*, SDL_Cursor*, SDL_Cursor*, CPrinterHandler*, CSoundManager*, CSettings*) (TestModeManager.cpp:45)
==7763== by 0x806E887: CMattingMain::initialize() (MattingMain.cpp:1257)
==7763== by 0x806F6B0: CMattingMain::CMattingMain(int, int, int, unsigned) (MattingMain.cpp:97)
==7763== by 0x804C688: __static_initialization_and_destruction_0(int, int) (mattinggame.cpp:52)
==7763== by 0x804C6D2: _GLOBAL__I_mThread (mattinggame.cpp:89)
==7763== by 0x80EEF75: (within /home/benang/mattinggame/debug/src/mattinggame)
==7763== by 0x804B864: (within /home/benang/mattinggame/debug/src/mattinggame)
==7763== Address 0x4 is not stack'd, malloc'd or (recently) free'd
==7763==
==7763== 1 errors in context 5 of 10:
==7763== Use of uninitialised value of size 4
==7763== at 0x80E8C9F: SDL_GUI::CTTFStringImage::CTTFStringImage(SDL_Surface*, SDL_GUI::CTTFont*, short, short, std::string, unsigned) (TTFStringImage.cpp:54)
==7763== by 0x80EA959: SDL_GUI::CBoxedString::CBoxedString(SDL_Surface*, short, short, short, short, unsigned char, unsigned char, unsigned char, SDL_GUI::CTTFont*, std::string, unsigned) (BoxedString.cpp:99)
==7763== by 0x80E80F4: SDL_GUI::CTextBox::changeValue(std::string) (TextBox.cpp:125)
==7763== by 0x80A9EDE: CGUI_AuditHandler::initCurrentValues() (GUI_AuditHandler.cpp:350)
==7763== by 0x80AFE29: CGUI_AuditHandler::CGUI_AuditHandler(SDL_Surface*) (GUI_AuditHandler.cpp:285)
==7763== by 0x80A1D8E: CTestModeManager::CTestModeManager(CSceneManager*, SDL_Cursor*, SDL_Cursor*, CPrinterHandler*, CSoundManager*, CSettings*) (TestModeManager.cpp:45)
==7763== by 0x806E887: CMattingMain::initialize() (MattingMain.cpp:1257)
==7763== by 0x806F6B0: CMattingMain::CMattingMain(int, int, int, unsigned) (MattingMain.cpp:97)
==7763== by 0x804C688: __static_initialization_and_destruction_0(int, int) (mattinggame.cpp:52)
==7763== by 0x804C6D2: _GLOBAL__I_mThread (mattinggame.cpp:89)
==7763== by 0x80EEF75: (within /home/benang/mattinggame/debug/src/mattinggame)
==7763== by 0x804B864: (within /home/benang/mattinggame/debug/src/mattinggame)
==7763==
==7763== 1 errors in context 6 of 10:
==7763== Syscall param ioctl(TCSET{S,SW,SF}) points to uninitialised byte(s)
==7763== at 0x1BCB381E: tcsetattr (in /lib/tls/libc-2.3.5.so)
==7763== by 0x809A700: CSerialHandler::settings() (SerialHandler.cpp:127)
==7763== by 0x809B01C: CSerialHandler::CSerialHandler() (SerialHandler.cpp:35)
==7763== by 0x806CEFA: CMainApp::CMainApp(int, int, int, unsigned) (MainApp.cpp:41)
==7763== by 0x806F3B0: CMattingMain::CMattingMain(int, int, int, unsigned) (MattingMain.cpp:84)
==7763== by 0x804C688: __static_initialization_and_destruction_0(int, int) (mattinggame.cpp:52)
==7763== by 0x804C6D2: _GLOBAL__I_mThread (mattinggame.cpp:89)
==7763== by 0x80EEF75: (within /home/benang/mattinggame/debug/src/mattinggame)
==7763== by 0x804B864: (within /home/benang/mattinggame/debug/src/mattinggame)
==7763== by 0x80EEEAE: __libc_csu_init (in /home/benang/mattinggame/debug/src/mattinggame)
==7763== by 0x1BC12E4C: __libc_start_main (in /lib/tls/libc-2.3.5.so)
==7763== by 0x804C4C0: ??? (start.S:119)
==7763== Address 0x52BFDC98 is on thread 1's stack
==7763==
==7763== 1 errors in context 7 of 10:
==7763== Syscall param ioctl(arg) contains uninitialised byte(s)
==7763== at 0x1BCB4509: ioctl (in /lib/tls/libc-2.3.5.so)
==7763== by 0x1C0F1756: (within /usr/lib/libasound.so.2.0.0)
==7763== by 0x1C0DF201: snd_pcm_prepare (in /usr/lib/libasound.so.2.0.0)
==7763== by 0x1C0DF2B2: snd_pcm_hw_params (in /usr/lib/libasound.so.2.0.0)
==7763== by 0x1BB74820: (within /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BB418BE: SDL_OpenAudio (in /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BA55195: Mix_OpenAudio (in /usr/lib/libSDL_mixer-1.2.so.0.2.5)
==7763== by 0x806C6DB: CMainApp::initAudio() (MainApp.cpp:98)
==7763== by 0x806C9F0: CMainApp::Init() (MainApp.cpp:79)
==7763== by 0x806CCED: CMainApp::CMainApp(int, int, int, unsigned) (MainApp.cpp:24)
==7763== by 0x806F3B0: CMattingMain::CMattingMain(int, int, int, unsigned) (MattingMain.cpp:84)
==7763== by 0x804C688: __static_initialization_and_destruction_0(int, int) (mattinggame.cpp:52)
==7763==
==7763== 1 errors in context 8 of 10:
==7763== Syscall param write(buf) points to uninitialised byte(s)
==7763== at 0x1BBCF353: __write_nocancel (in /lib/tls/libpthread-2.3.5.so)
==7763== by 0x1BFAF27D: (within /usr/X11R6/lib/libX11.so.6.2)
==7763== by 0x1BFAF5AE: _X11TransWrite (in /usr/X11R6/lib/libX11.so.6.2)
==7763== by 0x1BF92C34: (within /usr/X11R6/lib/libX11.so.6.2)
==7763== by 0x1BF92D5C: _XReply (in /usr/X11R6/lib/libX11.so.6.2)
==7763== by 0x1BF7E2A2: XInternAtom (in /usr/X11R6/lib/libX11.so.6.2)
==7763== by 0x1BB75861: (within /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BB805B9: (within /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BB7EA01: (within /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BB7EFE6: (within /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BB6E09A: SDL_VideoInit (in /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BB4094E: SDL_InitSubSystem (in /usr/lib/libSDL-1.2.so.0.11.0)
==7763== Address 0x1BE4ED9E is 14 bytes inside a block of size 16384 alloc'd
==7763== at 0x1B900B88: calloc (in /usr/lib/valgrind/vgpreload_memcheck.so)
==7763== by 0x1BF82AE3: XOpenDisplay (in /usr/X11R6/lib/libX11.so.6.2)
==7763== by 0x1BB75A8E: (within /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BB7EDC2: (within /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BB6E09A: SDL_VideoInit (in /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BB4094E: SDL_InitSubSystem (in /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BB4098B: SDL_Init (in /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x806C9B4: CMainApp::Init() (MainApp.cpp:73)
==7763== by 0x806CCED: CMainApp::CMainApp(int, int, int, unsigned) (MainApp.cpp:24)
==7763== by 0x806F3B0: CMattingMain::CMattingMain(int, int, int, unsigned) (MattingMain.cpp:84)
==7763== by 0x804C688: __static_initialization_and_destruction_0(int, int) (mattinggame.cpp:52)
==7763== by 0x804C6D2: _GLOBAL__I_mThread (mattinggame.cpp:89)
==7763==
==7763== 2 errors in context 9 of 10:
==7763== Thread 3:
==7763== Syscall param ioctl(arg) contains uninitialised byte(s)
==7763== at 0x1BCB4509: ioctl (in /lib/tls/libc-2.3.5.so)
==7763== by 0x1C0F1756: (within /usr/lib/libasound.so.2.0.0)
==7763== by 0x1C0DF201: snd_pcm_prepare (in /usr/lib/libasound.so.2.0.0)
==7763== by 0x1BB742DF: (within /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BB411A7: (within /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BB49D5F: (within /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BB93334: (within /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BBCA296: start_thread (in /lib/tls/libpthread-2.3.5.so)
==7763== by 0x1BCBC37D: clone (in /lib/tls/libc-2.3.5.so)
==7763== by 0x1C55FBAF: ???
==7763==
==7763== 2 errors in context 10 of 10:
==7763== Thread 1:
==7763== Syscall param write(buf) points to uninitialised byte(s)
==7763== at 0x1BBCF37B: (within /lib/tls/libpthread-2.3.5.so)
==7763== by 0x1BFAF27D: (within /usr/X11R6/lib/libX11.so.6.2)
==7763== by 0x1BFAF5AE: _X11TransWrite (in /usr/X11R6/lib/libX11.so.6.2)
==7763== by 0x1BF92C34: (within /usr/X11R6/lib/libX11.so.6.2)
==7763== by 0x1BF92D5C: _XReply (in /usr/X11R6/lib/libX11.so.6.2)
==7763== by 0x1BF8D784: XSync (in /usr/X11R6/lib/libX11.so.6.2)
==7763== by 0x1BB76004: (within /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BB7E32B: (within /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BB7F672: (within /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BB6E4FD: SDL_SetVideoMode (in /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x804DA93: CSurface::CSurface(int, int, int, unsigned) (Surface.cpp:38)
==7763== by 0x806CD3D: CMainApp::CMainApp(int, int, int, unsigned) (MainApp.cpp:35)
==7763== Address 0x1BE58C23 is 19 bytes inside a block of size 16384 alloc'd
==7763== at 0x1B900B88: calloc (in /usr/lib/valgrind/vgpreload_memcheck.so)
==7763== by 0x1BF82AE3: XOpenDisplay (in /usr/X11R6/lib/libX11.so.6.2)
==7763== by 0x1BB75A8E: (within /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BB7EDE5: (within /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BB6E09A: SDL_VideoInit (in /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BB4094E: SDL_InitSubSystem (in /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x1BB4098B: SDL_Init (in /usr/lib/libSDL-1.2.so.0.11.0)
==7763== by 0x806C9B4: CMainApp::Init() (MainApp.cpp:73)
==7763== by 0x806CCED: CMainApp::CMainApp(int, int, int, unsigned) (MainApp.cpp:24)
==7763== by 0x806F3B0: CMattingMain::CMattingMain(int, int, int, unsigned) (MattingMain.cpp:84)
==7763== by 0x804C688: __static_initialization_and_destruction_0(int, int) (mattinggame.cpp:52)
==7763== by 0x804C6D2: _GLOBAL__I_mThread (mattinggame.cpp:89)
--7763--
--7763-- supp: 3 index-not-intercepted-early-enough-HACK-1
--7763-- supp: 1 strlen-not-intercepted-early-enough-HACK-4
--7763-- supp: 1 strlen-not-intercepted-early-enough-HACK-3
--7763-- supp: 107 dl_relocate_object
==7763==
==7763== IN SUMMARY: 12 errors from 10 contexts (suppressed: 112 from 4)
==7763==
==7763== malloc/free: in use at exit: 657285 bytes in 9579 blocks.
==7763== malloc/free: 18319 allocs, 8740 frees, 2802140 bytes allocated.
==7763==
==7763== searching for pointers to 9579 not-freed blocks.
==7763== checked 5712256 bytes.
==7763==
==7763== LEAK SUMMARY:
==7763== definitely lost: 180 bytes in 13 blocks.
==7763== possibly lost: 33268 bytes in 1115 blocks.
==7763== still reachable: 623837 bytes in 8451 blocks.
==7763== suppressed: 0 bytes in 0 blocks.
==7763== Use --leak-check=full to see details of leaked memory.
--7763-- memcheck: sanity checks: 223 cheap, 9 expensive
--7763-- memcheck: auxmaps: 0 auxmap entries (0k, 0M) in use
--7763-- memcheck: auxmaps: 0 searches, 0 comparisons
--7763-- memcheck: secondaries: 152 issued (9728k, 9M)
--7763-- memcheck: secondaries: 160 accessible and distinguished (10240k, 10M)
--7763-- tt/tc: 58529 tt lookups requiring 130387 probes
--7763-- tt/tc: 58529 fast-cache updates, 12 flushes
--7763-- translate: new 24968 (557324 -> 8865345; ratio 159:10) [0 scs]
--7763-- translate: dumped 0 (0 -> ??)
--7763-- translate: discarded 1163 (22806 -> ??)
--7763-- scheduler: 9719743 jumps (bb entries).
--7763-- scheduler: 223/64748 major/minor sched events.
--7763-- sanity: 224 cheap, 9 expensive checks.
--7763-- exectx: 4999 lists, 4561 contexts (avg 0 per list)
--7763-- exectx: 27111 searches, 24769 full compares (913 per 1000)
--7763-- exectx: 0 cmp2, 482 cmp4, 0 cmpAll
Segmentation fault

Can anybody help me? Thanks in advance.

vladmihaisima 01-12-2007 05:24 AM

I'm no valgrind expert, but from the output it seems to me that valgrind is reporting you several errors like:

Code:

==7763== 1 errors in context 5 of 10:
==7763== Use of uninitialised value of size 4
==7763== at 0x80E8C9F: SDL_GUI::CTTFStringImage::CTTFStringImage(SDL_Surface*, SDL_GUI::CTTFont*, short, short, std::string, unsigned) (TTFStringImage.cpp:54)
==7763== by 0x80EA959: SDL_GUI::CBoxedString::CBoxedString(SDL_Surface*, short, short, short, short, unsigned char, unsigned char, unsigned char, SDL_GUI::CTTFont*, std::string, unsigned) (BoxedString.cpp:99)
==7763== by 0x80E80F4: SDL_GUI::CTextBox::changeValue(std::string) (TextBox.cpp:125)
==7763== by 0x80A9EDE: CGUI_AuditHandler::initCurrentValues() (GUI_AuditHandler.cpp:350)
==7763== by 0x80AFE29: CGUI_AuditHandler::CGUI_AuditHandler(SDL_Surface*) (GUI_AuditHandler.cpp:285)
==7763== by 0x80A1D8E: CTestModeManager::CTestModeManager(CSceneManager*, SDL_Cursor*, SDL_Cursor*, CPrinterHandler*, CSoundManager*, CSettings*) (TestModeManager.cpp:45)
==7763== by 0x806E887: CMattingMain::initialize() (MattingMain.cpp:1257)
==7763== by 0x806F6B0: CMattingMain::CMattingMain(int, int, int, unsigned) (MattingMain.cpp:97)
==7763== by 0x804C688: __static_initialization_and_destruction_0(int, int) (mattinggame.cpp:52)
==7763== by 0x804C6D2: _GLOBAL__I_mThread (mattinggame.cpp:89)
==7763== by 0x80EEF75: (within /home/benang/mattinggame/debug/src/mattinggame)
==7763== by 0x804B864: (within /home/benang/mattinggame/debug/src/mattinggame)

You should check what code do you have at the reported lines.. (for example: mattinggame.cpp:89), and see if you can fix them.


All times are GMT -5. The time now is 06:16 AM.