Game crashes when compiling to Windows

Bombini

  • Posts: 1398
hi guys,

i compile my game only once in a while to desktop Windows because it takes so long.
I always test on Flash which worked in the last three years (Flash and Windows version if tested on Flash).
i have following issue:
  • I can compile it and navigate through the menus
  • The game crashes when i press any button related to the player character
  • The version works fine on Flash


(ignore the green glitch)

This is a bit of a nightmare because i dont know how to identify the problem.
The game runs forever if i dont touch the controls but i really dont know what to change.
Do you see something in the logs?

Thanks!

Justin

  • *
  • Posts: 4645
Logs will probably be worthless for a desktop crash. Here's a guide that should help.

============================================

When a game exported for Windows crashes, it often leaves no information. In order to see the cause of a crash, it's helpful to run the game inside an IDE with debugging information. Here's how to do it in Visual Studio on Windows.

[In Stencyl]

- Go to Game > Settings > Advanced > Haxe Flags
  - Add the following flag: -D HXCPP_DEBUG_LINK

Including the above flag will generate some extra files when you compile. Enabling or disabling the flag will cause a full recompile, so I usually keep the flag enabled.

- Compile for desktop with the HXCPP_DEBUG_LINK flag enabled.

[Visual Studio]

Visual Studio, or Visual C++, is installed by Stencyl when you build a windows game. If you've never used it before, you'll need to register for a free account. Find this program and open it, then proceed to the following steps.

- File > Open Project... > [stencyl workspace]/games-generated/[mygame]/Export/windows/cpp/bin/[mygame].exe

- Start (button with green arrow)

If the game encounters an error while running, instead of immediately closing, it will show a dialog box in Visual Studio.
Tell it to "break execution", and it should open a code file and select the line that it stopped running at.
Pertinent info to provide would be:
- the name of the code file it opened.
- copy the line it stopped on.
- if you see a function like HX_STACK_LINE(xx) near it, let us know what number is in it.
- The content of the "Call Stack" pane.

It would probably mention the type of error as well in the dialog that pops up, but I don't have a compiled broken game on-hand to test with and see exactly what info it provides.


>>>> If your app crashes immediately from Stencyl, but not in visual studio

https://technet.microsoft.com/en-gb/sysinternals/dd996900.aspx
Grab that download, ProcDump

Save and extract it
Open a command window in the extracted folder
And run the following command
procdump -e 1 -ma -w "Stencyl Project Name"

-e 1 immediately crashes on first chance exceptions
-ma is a full dump instead of a minidump
-w waits for the process to be created

Then, when you test the game from within Stencyl and it crashes, it should automatically create a full dump of the program's memory (this can be a huge file)
It'll put the dump in the procdump folder
Then you open Visual C++
File > Open File > open the .dmp file it generated
And then press the "Debug with Native Only" button
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

Bombini

  • Posts: 1398
Thanks Justin!
New logs with flag are attached.

Visual studio:
message:
Unhandled exception at 0x01142b0f in SpacePirate377.exe: 0xC0000005: Access violation reading location 0x00000000.

line:
01142B0F  mov         eax,dword ptr [ecx] 

Any idea what that says?
I can also send you the game file if it helps.
Cheers!

Justin

  • *
  • Posts: 4645
When you press break, try to find the "call stack" pane. It might not be the selected tab, but here's where it is in Visual Studio Express 2010.

Then you can click on the different items in the call stack (starting at the top) until you get to ones with more intelligible code. Then it should be easy to see where it comes from in the Haxe source. Remember, look out for lines like HX_STACK_LINE(xxx).

For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

Bombini

  • Posts: 1398
Hm...i browsed through every entry in the call stack.
No code just line with hex and numbers.

I have to admit that i get realy nervous right now...
Problem: It will take a long time if i take out code in the game to identify whats wrong and then i still wouldnt know how to fix it because it runs in flash when i compile it.

Any more advice?

« Last Edit: September 15, 2016, 02:18:06 pm by Bombini »

Justin

  • *
  • Posts: 4645
It looks like it hasn't loaded any of the debug information for your game. Did you put "-D HXCPP_DEBUG_LINK" in your advanced haxe settings for the game?
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

Bombini

  • Posts: 1398
As you told me yes

iii

  • *
  • Posts: 194
Maybe can try implementing Crashdumper from Lars.
https://github.com/larsiusprime/crashdumper

Haven't tried it myself, cause never had any crash before.
Might be useful?

Justin

  • *
  • Posts: 4645
That might work. I'm not sure why the debug info isn't loading in vc++ for you, but if the error is one that can be caught in crashdumper, it should be easier to debug than looking at the c++ source anyway. The main reason I tend not to recommend crashdumper is because all of the extra debugging flags it enables in the game seem to take a heavy toll on performance.

Oh, and I didn't notice your offer to send me the game. If you send it over, I wouldn't mind looking into this.
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

Bombini

  • Posts: 1398
I installed Visual Studio 2015 plus the latest Stencyl version and could get the debug to work.
But there are tons of "HX_STACK_LINE(xx)" functions.
The one which seems to be the issue is i think:
Code: [Select]
HX_STACK_LINE(2358)
Float tmp51 = _g->_HighlightContracts->getY(null()); HX_STACK_VAR(tmp51,"tmp51");
HX_STACK_LINE(2358)

I investigated this actor (HighlightContracts) but could not find a problem. But the game runs when i deactivate the behaviour where its in.

Btw: Every "Pause/Unpause" block turns red when i touch my code and fires an error when compiling with the newest Stencyl version.

I also sent you the game via PM in case you could take a look.
Which would be wonderful and you would make my life better.
Bombini

« Last Edit: September 16, 2016, 04:56:41 am by Bombini »

Justin

  • *
  • Posts: 4645
Code: [Select]
HX_STACK_LINE(2358)
Float tmp51 = _g->_HighlightContracts->getY(null()); HX_STACK_VAR(tmp51,"tmp51");
HX_STACK_LINE(2358)

This is where the code broke, and it's in C++, so it's a good start. In addition to the HX_STACK_LINE notation, you should see that the opened tab was called "Design_236_236_ScoreKeeper.cpp". This is based on the name you gave the behavior when you first created it, so hopefully you know which behavior it is based on that name. In this case, it's not too difficult because the new name is "Score Keeper and Interface". (I know that you know which behavior this was, but this is how you'd do it if you couldn't tell from the name of the attribute.)

So I opened the behavior and pressed ctrl+j to open the code preview. Then I went to the line numbers I saw in HX_STACK_LINE. At line 2358, you have "if((_HighlightContracts.getY() == 131))". This corresponds to the C++ code that the error occurred at. Hopefully you can understand more or less which part of the behavior it came from by reading the Haxe code. In this case, it's the "Contracts Logic" event underneath the big comment that says "movement".

To fix the error, I noticed the parallels between "shop open/shop logic" and "contract open/contract logic" and I noticed that you didn't check "If <ShowContracts>" in contract logic. By adding a game attribute check there, just like you have in "shop logic", the error went away.
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

Justin

  • *
  • Posts: 4645
Also, I fixed the issue with pause blocks being marked as errors in the latest build. Thanks for mentioning it.
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

Bombini

  • Posts: 1398
Thanks so much Justin!
I was confused because it worked on Flash but i am very relieved (also that it was my fault).
You saved the day also allowing me to find bugs in the future easier.
Thanks!
Great support!

Justin

  • *
  • Posts: 4645
Actually, for me it crashed on Flash as well. I'm not sure why it didn't crash for you.
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

Justin

  • *
  • Posts: 4645
This thread has useful information so I'm moving it from Help Desk to Ask a Question.
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)