Suppress debug output of SetThreadName exception in MSVC

1

I am using the suggested way to set the name of a thread via SetThreadName. It works, and I see the names changing in the thread view tool window. However, I frequently get an exception message printed out to the debug output window. Since I have several threads, I may get several of these messages, but sometimes I get none. An example message:

First-chance exception at 0x75419558 (KernelBase.dll) in MyProgram.exe : 0x406D1388 (parameters: 0x00001000, 0x00E1EB70, 0x00000A40, 0x00000000).

Although the exception gets handled/ignored as it should by the __except block, and everything continues without a problem, it concerns me. Is there an explanation why this happens, and only happens intermittently? Is there some other way to do this to avoid the message, or is there some way to suppress the output of the exception message to the debug output?

Note: this seems to happen in all versions of Visual Studio - I have tested VC2010-2015RC.

c++
multithreading
exception
visual-studio-2013
visual-studio-debugging

1 Answer

0

What is a first chance exception?

When you have the debugger attached, any exceptions that are thrown are given to the debugger first. That is why it is displaying the exception even though you handle the exception with the __except(EXCEPTION_EXECUTE_HANDLER) clause. The debugger gets the first chance to handle it. In this case it seems to just print that it received it and then pass it along normally.

To disable these messages, you can right click on the output menu and uncheck Exception Messages.

answered on Stack Overflow Jun 3, 2015 by lcs

User contributions licensed under CC BY-SA 3.0