Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / C++ error when running... [ NOW FIXED ]
- By Maverick Date 2009-05-08 00:22
Hey guys. Gosu is pretty awesome so far. It is really clean.
|Anyway, I followed the step-by-step tutorial on setting up Gosu on Windows and successfully compiled the TextInput.cpp tutorial. No problems.
Then I compiled Tutorial.cpp ( with the rocket and collecting stars ) and it compiles fine. However, it does not run fine. It says that there is a bug in the DLL or the stack over-flowed.

This is strange because TextInput gave me absolutely no problems whatsoever. Can someone help out? Thanks!
- By jlnr (dev) Date 2009-05-08 01:54
Hmm, this is a new bug :)

Can you paste the exact error message? I suspect it has to do with fmod.dll, which the TextInput example doesn't use, but I'm not sure.
- By Maverick Date 2009-05-08 03:14
Sorry to have to tell you that bad news. I hate bugs too. ( I don't think anyone really likes them anyways ).
If I ran the EXE via double-clicking it, a Microsoft error report would be shown with the following:
"A problem occurred with Tutorial.exe. If you were in the middle of something , we're sorry for the inconvenience" - blah blah blah.

I fixed this problem ( kind of ) my going to the EXE's Properties and clicking on "Compatibility"->"Run this program in compatibility for"->"Windows 95"
Then it worked. However, even after exiting, the program would still be running in the background and you would have to manually kill it.
When I run it via the MSVC++ 2009 Express IDE, an error message would come up. Then it may run the program and the program runs fine after the message.

Here's the message:

"Windows has triggered a breakpoint in Tutorial.exe.
This may be due to a corruption of the heap, which indicates a bug in Tutorial.exe or any of the DLLs it has loaded.
This may also be due to the user pressing F12 while Tutorial.exe has focus.
The output window may have more diagnostic information."

And, by the way, F12 was not pressed. :p
- By jlnr (dev) Date 2009-05-08 09:27
Oh, Express 2009 is out? :) I think you are the first one to test Gosu with that. I'll try to get a hold of it later and see if I can fix Gosu to work with VS Express 2005-2009.
- By Maverick Date 2009-05-08 11:53
I'm terribly sorry, but I meant MSVC++ 9.0 2008 Express Edition. I looked at the "9.0" on it and assumed 2009. It's 2008. My bad. :p
- By jlnr (dev) Date 2009-05-09 02:50
Does this happen in both Debug and Release configurations, and did you set both to the Multithreaded (not DLL) variants? Does the Call Stack window show any specific function names when the debugger halts the game? If not, you could add breakpoints to see if it dies before main(), in main() before the window is constructed, or during/after Window construction.

I'd ask you to share the project files but I don't have 08 installed right now. I should see if one can install several editions of MSVC, would be helpful in debugging Gosu from time to time :)
- By Maverick Date 2009-05-09 14:59
It doesn't happen at all in Debug. It works perfectly fine even if I'm executing it through the IDE or not. Only Release mode does it apparently.
The Call Stack shows absolutely nothing. And it's not during the game. The game doesn't even load and the error pops up.
And the variants are correct. :]
- By Maverick Date 2009-05-10 07:45
I feel like it has something to do with the containers. When I was starting out with C++ and learning STL vectors and what-not andI didn't do it properly, it would give me an identical message. I could be wrong.
- By Maverick Date 2009-05-10 21:14
I'm positive it has something to do with the way the animation is set up. I broke apart the examples and did lots of things and it ran fine. However, when I added the animation in, it gave the exact message that I had from the Tutorial.

I'm not sure how to fix it though. Why would it only say something during the Release and absolutely nothing during the Debug if it has something to do with the containers? Maybe there's something is missing in the regular Gosu.lib and the not debug?

Whatever it is, I know it has to do with the containers ( boost and stl for the animation )
- By jlnr (dev) Date 2009-05-11 00:36
OK, have you put breakpoints in the Window constructor and stepped through them? If control doesn't even get there, I think it's something way more low-level than STL containers and boost (which I found to be very reliable) :)
- By Maverick Date 2009-05-11 01:37
"int main(int argc, char* argv[])
{
"

It points to the bracket.
This is what the call stack shows:
">  GOSU_TEST_ONE_FINDTHEBUG.exe!main(int argc=137820628, char * * argv=0x00000000)  Line 185  C++
"

argc results in this:
"    argc  137820628  int
"

and argv results in this
"-    argv  0x00000000  char * *
      CXX0030: Error: expression cannot be evaluated 
"
- By jlnr (dev) Date 2009-05-11 13:20
And if you do a "step over" it already crashes? What happens if you put a harmless line like puts("foo"); after the bracket?
- By Maverick Date 2009-05-11 23:53
It skips the puts("foo") and the bracket and it stops at this:
"MyWindow win;"

Then it stopped at the bracket after the myWindow constructor. Then it stopped at win.show();
- By jlnr (dev) Date 2009-05-12 00:51
OK, does that mean it didn't call either of the Window's callbacks, that is draw() and update() did you put breakpoints in there? show() will internally call both of them after doing some setup—still trying to narrow down the places in which this can happen.
- By Maverick Date 2009-05-12 20:37
It skips the update and draw functions. So that seems fine.

Can you post a link to a full VC project so I can try it from there just to make sure it's not the actual engine maybe just the way I set it up?
- By Maverick Date 2009-05-13 02:39
I think I may have narrowed it down. The call stack ( at the bottom ) mentioned a line at 163 where I create my character class. Inside of the character class, there is an animation. I commented anything to do with animation and it ran ( though... with no animation ). So I created a test object to see if it was the actual animations or the library itself.

Doing this is just fine:
std::vector< boost::shared_ptr< Gosu::Image > > test;

But doing this gives the whole error problem:
std::vector< boost::shared_ptr< Gosu::Image > > test;
Gosu::imagesFromTiledBitmap ( graphics, Gosu::sharedResourcePrefix() + L"media/RonWalkAnim.png", 110, 236, false, test );

So I think it has something to do with "test" or the function in Gosu.
- By Maverick Date 2009-05-14 21:39
I have more information that may help us:
"GOSU_TEST_ONE.exe': Loaded 'C:\Documents and Settings\BPeppers\Desktop\gosu-windows-cpp-0.7.13\examples\GOSU_TEST_ONE\Release\GOSU_TEST_ONE.exe', Symbols loaded.
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\dinput8.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\secur32.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\user32.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\opengl32.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\glu32.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\ddraw.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\dciman32.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\winmm.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\Documents and Settings\BPeppers\Desktop\gosu-windows-cpp-0.7.13\examples\GOSU_TEST_ONE\Release\fmod.dll', Binary was not built with debug information.
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\msacm32.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\ole32.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\wsock32.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\ws2_32.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\ws2help.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\shell32.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\shlwapi.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\imm32.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.5512_x-ww_35d4ce83\comctl32.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\comctl32.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\Program Files\RK Launcher\RKLauncher.dll', Binary was not built with debug information.
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\msctf.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\version.dll'
'GOSU_TEST_ONE.exe': Unloaded 'C:\WINDOWS\system32\version.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\msctfime.ime'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\nvoglnt.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\mcd32.dll'
'GOSU_TEST_ONE.exe': Unloaded 'C:\WINDOWS\system32\mcd32.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\hid.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\setupapi.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\wintrust.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\crypt32.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\msasn1.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\imagehlp.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\ntmarta.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\samlib.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\wldap32.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\wdmaud.drv'
'GOSU_TEST_ONE.exe': Unloaded 'C:\WINDOWS\system32\wdmaud.drv'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\wdmaud.drv'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\msacm32.drv'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\midimap.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\dsound.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\version.dll'
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\ksuser.dll'
HEAP[GOSU_TEST_ONE.exe]: Invalid Address specified to RtlFreeHeap( 00E20000, 02690498 )
Windows has triggered a breakpoint in GOSU_TEST_ONE.exe.

This may be due to a corruption of the heap, which indicates a bug in GOSU_TEST_ONE.exe or any of the DLLs it has loaded.

This may also be due to the user pressing F12 while GOSU_TEST_ONE.exe has focus.

The output window may have more diagnostic information.
First-chance exception at 0x7c96f749 in GOSU_TEST_ONE.exe: 0xC0000005: Access violation reading location 0x7c527428.
'GOSU_TEST_ONE.exe': Loaded 'C:\WINDOWS\system32\oleaut32.dll'
The thread 'Win32 Thread' (0xee0) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0xf04) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0xcf8) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x368) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0xda4) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x8e0) has exited with code 0 (0x0).
The program '[3768] GOSU_TEST_ONE.exe: Native' has exited with code 0 (0x0).
"

Not a clue what it means for me, but hopefully that helps you. :/
- By jlnr (dev) Date 2009-05-14 23:29
I can't look into it in detail right now, but it somehow looks as if there was a problem with linking the C++ standard library (RtlFreeMemory). So when anything gets freed internally, the game probably crashes.

This does _not_ have anything to do with boost or the STL :) So maybe I did break MSVC08 compatibility somehow...? Anyone using MSVC08 successfully with the precompiled Gosu?
- By jlnr (dev) Date 2009-05-23 19:20
Just uploaded both .lib files built with VC08 for you:

http://www.raschke.de/julian/temp/gosu-wincpp-vc08.zip

Let me know if this changes anything.
- By Maverick Date 2009-05-24 03:42
"error LNK2001: unresolved external symbol "public: __thiscall Gosu::Font::Font(class Gosu::Graphics &,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const &,unsigned int)" (??0Font@Gosu@@QAE@AAVGraphics@1@ABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@I@Z)"

I got punk'd by Gosu. :p
- By jlnr (dev) Date 2009-05-24 10:30
You also need the very latest headers from 0.7.13.3 to go along with it. This constructor's signature was different in <0.7.13.3.
- By Maverick Date 2009-05-24 16:07
Ah didn't see a new release was out...

...

Yes! It's all working fine now. :D
What was the problem out of curiosity?
Thanks. Now I can get to my games with Gosu.
- By jlnr (dev) Date 2009-05-24 17:47
Ah ok.

So the problem is apparently that libraries built with MSVC05 (what I release) are not 100% binary compatible with those built in MSVC08 (which I built & uploaded for you). This is of course horrible, because it means I either have to drop support for MSVC05 or include both sets of libraries in the .ZIP archive. Prepare for a huge download when MSVC10 is out... ;)

On the upside, I can have both versions of MSVC installed side by side, and I hope I can automate building Gosu with both via the msbuild shell tool. I'll see.
- By Maverick Date 2009-05-24 23:20
That sucks. It would be Microsoft to do something like that though.
Up Topic Gosu / Gosu Exchange / C++ error when running... [ NOW FIXED ]

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill