Hello
I'm getting an error when I run my program.
This is what valgrind tells me:
Quote:
==3326== Syscall param modify_ldt(ptr) points to uninitialised byte(s)
==3326== at 0x1CDB83F2: _nv000001gl (in /usr/lib/libnvidia-tls.so.1.0.7174)
==3326== Address 0x52BFE3D4 is on thread 1's stack
==3326==
==3326== Invalid read of size 4
==3326== at 0x1C245946: std:stream::sentry::sentry(std:stream&) (in /usr/lib/libstdc++.so.5.0.6)
==3326== by 0x1C245C54: std::basic_ostream<char, std::char_traits<char> >& std:perator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*) (in /usr/lib/libstdc++.so.5.0.6)
==3326== by 0x80541A8: logfile::comment(char const*) (basic_string.h:717)
==3326== by 0x80571E7: Sound::Init() (Sound.cpp:170)
==3326== by 0x8056ADF: Sound::Sound() (Sound.cpp:25)
==3326== by 0x80564E8: __static_initialization_and_destruction_0(int, int) (MouseEvent.cpp:24)
==3326== by 0x8056541: _GLOBAL__I_MyTestSound (MouseEvent.cpp:24)
==3326== by 0x8066184: (within /home/hylke/combatofdeath/combatofdeath)
==3326== by 0x804E338: _init (in /home/hylke/combatofdeath/combatofdeath)
==3326== by 0x80660BA: __libc_csu_init (in /home/hylke/combatofdeath/combatofdeath)
==3326== by 0x1C2CF44D: __libc_start_main (in /lib/libc-2.3.4.so)
==3326== by 0x804F840: ??? (start.S:119)
==3326== Address 0xFFFFFFF4 is not stack'd, malloc'd or (recently) free'd
==3326==
==3326== Process terminating with default action of signal 11 (SIGSEGV)
==3326== GPF (Pointer out of bounds?)
==3326== at 0x1C245946: std:stream::sentry::sentry(std:stream&) (in /usr/lib/libstdc++.so.5.0.6)
==3326== by 0x1C245C54: std::basic_ostream<char, std::char_traits<char> >& std:perator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*) (in /usr/lib/libstdc++.so.5.0.6)
==3326== by 0x80541A8: logfile::comment(char const*) (basic_string.h:717)
==3326== by 0x80571E7: Sound::Init() (Sound.cpp:170)
==3326== by 0x8056ADF: Sound::Sound() (Sound.cpp:25)
==3326== by 0x80564E8: __static_initialization_and_destruction_0(int, int) (MouseEvent.cpp:24)
==3326== by 0x8056541: _GLOBAL__I_MyTestSound (MouseEvent.cpp:24)
==3326== by 0x8066184: (within /home/hylke/combatofdeath/combatofdeath)
==3326== by 0x804E338: _init (in /home/hylke/combatofdeath/combatofdeath)
==3326== by 0x80660BA: __libc_csu_init (in /home/hylke/combatofdeath/combatofdeath)
==3326== by 0x1C2CF44D: __libc_start_main (in /lib/libc-2.3.4.so)
==3326== by 0x804F840: ??? (start.S:119)
==3326==
==3326== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 77 from 2)
==3326== malloc/free: in use at exit: 632281 bytes in 428 blocks.
==3326== malloc/free: 428 allocs, 0 frees, 632281 bytes allocated.
==3326== For counts of detected errors, rerun with: -v
==3326== searching for pointers to 428 not-freed blocks.
==3326== checked 2217172 bytes.
==3326==
==3326== LEAK SUMMARY:
==3326== definitely lost: 0 bytes in 0 blocks.
==3326== possibly lost: 0 bytes in 0 blocks.
==3326== still reachable: 632281 bytes in 428 blocks.
==3326== suppressed: 0 bytes in 0 blocks.
==3326== Reachable blocks (those to which a pointer was found) are not shown.
|
This is how my function logfile::comment looks like:
Code:
void logfile::comment(const char* logItem)
{
string writeItem = "## ";
writeItem = "## ";
writeItem.append(logItem);
writeItem.append(" ##\n");
CoDfile << writeItem.c_str();
}
And this is the call from Sound::Init
Code:
CoDlog.comment("Sound initialisation");
Because I thought the above code will not generate a segmentation fault and by viewing the line:
Quote:
Address 0xFFFFFFF4 is not stack'd, malloc'd or (recently) free'd
|
From my valgrind output I thought it might be CoDlog that is causing the segmentation fault.
CoDlog is defined in extern_vars.h as this:
Code:
extern logfile CoDlog;
After that it's redefined in ErrorCheck.cpp(extern_vars.h is included in ErrorCheck, And ErrorCheck.h is included by ErrorCheck.cpp) like this:
My class Sound includes ErrorCheck.h in Sound.h.
But I can't put
in Sound.cpp because it's already redefined in ErrorCheck.cpp.
So i'm thinking that is causing the problem.
Could that be correct or is it absolutly nonsense?
Thanx Hylke