Download

Open VS Debugger instead of Crash Reporter

Hi,

I am wondering if there is a way to have a crash open the visual studio debugger instead of the unreal engine crash reporter. Sending tons of my game’s null ptr exceptions to epic does not seem to help. I never got contacted because of a bugfix for my code :smiley:

Of course this should only be the case for the development version, for the release version I would follow the instructions on how to use the crash reporter to send the report to my own site.

Any ideas on how to have the visual studio debugger launched instead of the crash reporter? It would be cool to have a button inside the Crash Report “Open in Debugger”. So I could send potential UE crashes to epic and open my own problems in the debugger right away…

Background info:
Visual Studio 2013
UE Source Build
Unreal Engine Version 4.10.4
Windows 10 x64

Thanks!

Hey gagga,

May not be a good answer, but on the occasions I’ve ran into the crash reporter I can restart the engine afterwards starting the editor through VS (debugging/launching it) automatically breaks on the exception (if reproducable). I think by the time the crash reporter comes up, the engine has already exited, maybe not though.

If you have the VS debugger attached to your project when it’s running (by an F5 launch or whatever), the debugger will catch the exception before it gets to the Epic crash reporter.

Well, for me this is not the case. I have the following scenario:

  • I open my project via clicking on the uproject file
  • I launch the game by pressing “play in new editor window”, 1 client, with dedicated server
  • I attach Visual Studio to the process (seems to be all in one process: client, editor and dedicated server…)
  • I press a key in the game that triggers an access violation

=> crash reporter opens
=> Visual Studio runs into a break point a few seconds later, somewhere in code to shutdown the engine, that has nothing to do with the actual crash

What am I doing wrong then? Are there some settings that have to be changed?

furthermore:

  • I can set breakpoints, in both client AND server code and they get hit → so debugging basically works and it seems I am attached to the correct process…
  • I can also see the content of variables etc.
  • I am using the engine version from github, not the binary distributed version.

gagga, skip the first dash in your list there and instead start the project by pressing the play (debug) button in visual studio like you would debug anything else.

Keep in mind you’ll need your project open in visual studio and if you stop debugging (pressing the stop button in visual studio) you’ll lose any unsaved changes to the project.

Also another pitfall of this method is ( well at least for me ) that when you later launch the project outside of visual studio ( as you have been doing so up to this point ) it won’t launch with the same dlls/ code from your most recent visual studio launch and instead rely on executables existing with the “Compile” Button at the top of unreal. This is problematic if you created any assets during visual studio containing types that didnt exist before or were heavily modified.

Hi PatGlynn

Thanks for your hint, but starting Editor through “start debugging” in visal studio yields exactly the same: crash reporter opens, not the debugger…

Does anyone have an idea?

Just my two cents.

  • close UE
  • in VS: clean project
  • in VS: build project (not rebuild, supossed to matter)
  • in UE: Refresh Visual Studio Project
  • have another try

gagga, make sure your configuration in VS is set to DebugGame Editor. To the left of the play/ start debugging button you’ll see Win64 or whatever platform, then to the left of that you want to select DebugGame Editor.

Actually PatGlynn’s first post seems to be the clue, don’t know why it hasn’t worked for me before.

This works for me:

  • choose either “Development Editor” or “GameDebug Editor” configuration
  • build (rebuild was not necessary)
  • start debugging in visual studio (make sure the editor is started by visual studio)

if the first thing you see is a window “choose project” then set the option “always load this project on startup” and close the editor after it has been opened. Because the actual project will get loaded in a second process that has NOT been started by visual studio - and that seems to make the difference. If the process started by VS immediately opens the project, then it triggers the debugger instead of the crash reporter on page faults.

However it does not work if you choose “attach to process” on a manually started editor.

Maybe there is a command line parameter that disables UE’s SEH handlers, I will check that out at some point. So probably it can also be disabled completely so that the “attach to process” also works…

Thats strange that it asks you to select a project gagga. One thing I will mention is that I do have UnrealVS plugin for VS installed and perhaps thats the difference?

About the strange thing asking for a uproject: Well, which uproject files should unreal open, if you launch it via the debugger? The engine is a central project, that is NOT unique to your game, so if there is more than one project, the engine could not possibly know which project you want to run - that is why it asks. However you can set the default project, so future startups will actually know.

Furthermore I have looked into the code responsible for debugging - UE uses the WIN32 function “IsDebuggerPresent” to check during startup if a debugger is present. Only in this case it disables the use of SEH. There seems to be no command line switch to disable SEH, however there is a macro PLATFORM_SEH_EXCEPTIONS_DISABLED to disable SEH completely, which is not what I want in my case. I would like to start UE on my machine without SEH, so it also asks for a debugger in case of exception, and with SEH in case it gets started on a designer’s machine, so it uses the crash reporter there.

locations in code:
LaunchWindows.cpp, look for line (184 in my case):
if( FPlatformMisc::IsDebuggerPresent() && !GAlwaysReportCrash )
Here GuardedMain is called instead of GuardedMainWrapper. The later contains the SEH handler that catches the page fault and calls the crash reporter.

If you start UE without the editor compiled in, then the crash reporter will not be enabled by default and must be enabled by using the “crashreports” command line switch. However there seems to be no possibility to disable it when you use a development configuration with the editor.

a very quick solution to get my functionality (windows only):

Open LaunchWindows.cpp, look for the line

if( FPlatformMisc::IsDebuggerPresent() && !GAlwaysReportCrash )

change it to

if( (FPlatformMisc::IsDebuggerPresent() && !GAlwaysReportCrash) || FParse::Param(CmdLine, TEXT("nocrashreports")))

now create a batch file where your uproject file is. Content:

<path-to-your-engine-folder>\Engine\Binaries\Win64\UE4Editor.exe -nocrashreports <path-to-your-uproject-file>

Now use the batch file to start the editor. When it crashes there is no crash reporter but windows asks you to attach a debugger.

Sorry for necro’ing this thread, but it was very relevant to me, so probably still relevant to others as well!

Basically, this was it as gagga Mentioned:

  • If the editor is NOT set to “always load this project on startup”, starting the debugger from Visual Studio will start a “chooser” version of the editor. Once your project is selected, it shuts down the VS-debugged instance and proceeds to spawn another non-debugged by VS instance with your project.

You can see this in VS’s output, as soon as you choose the project in the selector all kinds of shutdown code gets called, and you are disconnected at that point.

It’s weird, but makes sense at the same time. This should probably be documented somewhere :confused: but hopefully this is helpful to someone else!

This might happen if UE4 instead of the game project is set as the startup project in Visual Studio. In the Solution Explorer, right click the Game project and click “Set as Startup Project”. Then your project should launch immediately when clikcing “Local Windows Debugger” instead of the project selector.

If VS is connected correctly then the crash reporter should not run on crashes (unless you want to, you can add -crashreports as a launch param to force it).

By the way, you can make non-shipping builds wait just before crashing or asserting for a programmer to remotely attach to the process and see what’s going on.

  • Via config, in DefaultEngine.ini: [Engine.ErrorHandling] bPromptForRemoteDebugging=True or [Engine.ErrorHandling] bPromptForRemoteDebugOnEnsure=True.
  • Via command line: -PromptRemoteDebug or -PromptRemoteDebugEnsure.