What is a First-Chance Exception? (Threading)

Hey guys,

I’ve been testing out multi-threading with a real simple FRunnable object that loops to 10000 and prints out the int each time via UE_LOG. I noticed that when the thread is created, in WindowsRunnableThread.h’s ‘SetThreadName’, I get a first-chance exception every time (line 68). Plenty of other threads do this too - rendering, heartbeat, etc, so I’m not too worried.

It does make me wonder though - what does this mean, and why do I get this message when creating an FRunnableThread with an FRunnable passed to it?

Thanks!

If you don’t know what exceptions are, do read up on them. The jist of it is that it is an error raising mechanism that lets your code issue an “exception” without it necessarily being fatal. Somewhere down the line, someone calling your code can watch for raised exceptions and choose to gracefully handle them so that the program doesn’t crash. Since the error is handled, you don’t need to debug it so it is essentially ignored by the debugger, but it still gets logged as a first-chance exception. You can safely ignore these.

This blog post explains it in a bit more detail if you’re curious.

Hey ,

I’m familiar with the concept of exceptions. I’m just wondering why a lot of UE4’s own threads throw these exceptions, and mine as well.

First-chance exceptions are nothing to worry about and a perfectly normal part of execution. Lots of system calls end up issuing and handling them on Windows, as you’ve noticed for SetThreadName.