Visual Studio 2015 on Win 10 SetThreadName does not work RRS feed

  • Question

  • Since upgrading to Windows 10 from Windows 7 I have noticed that the SetThreadName function does not work.

    The name field displays "ucrtbased.dll thread" instead of the thread name given.

    Anyone else notice this problem.


    Monday, August 8, 2016 9:52 PM

All replies

  • Are you referring to this?

    With kind regards

    Tuesday, August 9, 2016 11:03 AM
  • Basically the same. 


    Tuesday, August 9, 2016 1:03 PM
  • According to this, seems to me being more a matter of the debugger than the OS:


    With kind regards

    Tuesday, August 9, 2016 3:17 PM
  • Windows 10.0.14393 Build 14393. Attaching windbg to VS. Something like this may show exception 0x406d1388 bubbles up in VS-debugger (VS 14.0.25425.01 Update 3) as expected
    0:054> bp ntdll!NtWaitForDebugEvent " r @$t1=poi(esp+10); g @$ra; .if (poi(@$t1)==6) {.printf \"Exception %p\\n\", poi(@$t1+c); } .else {gc} "
    0:054> g
    *** ERROR: Symbol file could not be found.  Defaulted to export symbols for C:\WINDOWS\System32\KERNELBASE.dll - 
    (19ec.2394): CLR exception - code e0434352 (first chance)
    (19ec.2394): CLR exception - code e0434352 (first chance)
    (19ec.2394): CLR exception - code e0434352 (first chance)
    Exception 406d1388
    eax=00000000 ebx=00000000 ecx=74ab0000 edx=225bfd6c esi=225bfda0 edi=225bfd08
    eip=75df4f3d esp=225bfd00 ebp=225bfd7c iopl=0         nv up ei pl nz na po nc
    cs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00200202
    75df4f3d 3d01010000      cmp     eax,101h

    But then, FAIK, it is up to the VS-debugger to set thread-name.

    No warranty

    With kind regards

    Wednesday, August 10, 2016 10:30 AM
  • Tank you for the information. After spending most of the day trying to resolve this issue I can verify that it is a race condition.  Setting break points in the code can make the difference on working or not.

    A fix was reported in December 2015.  Waiting to be released. Does anyone have any idea if the fix has been released. Update 2 & 3 has been released since then. We are running vs 2015 Update 1. I spent most of the Christmas holidays trying to recover from the original 2015 release which broke my ATMIL development software and caused blue screens.  That was due to a bad .net release required for 2015.

    I am a little gun shy to install other version of Visual Studio.  I almost had to wipe my machine and start over.  There are reports that Update 3 caused some problems. Everyone here is running Update1 no one wants to go forward and risk breaking things again.


    Wednesday, August 10, 2016 1:03 PM
  • No official statement known to me. It appears, the code of ThreadNaming.cpp (with #define START_SUSPENDED in ThreadNaming.zip attachment of above mentioned connect-report) works in Windows 10 Anniversary and VS Upgrade 3 for me (though not that thoroughly tested).
    But looks like for newest windbg (eg 10.0.14321.1024 AMD64) best results are achieved, if SetThreadname is called with threadID -1 by the thread, which has to be named, otherwise it fails, as far as I can see.

    And yes, I fully understand your reluctance regarding upgrade.
    E.g. I never experienced MS-Symbol-Server in such a bad shape for major release with missing mfc (fixed meanwhile), c-runtime symbols, not to mention ntdll, kernel32 leaving vital windbg cmds just useless...:

    Especially for I fear, there is no (easy) way back.

    With kind regards
    Thursday, August 11, 2016 7:29 AM
  • My rule is to capture a complete image of my system before doing Visual Studio installs or updates.

    Takes a lot time but just one bad install can take weeks to recover from otherwise.


    Thursday, August 11, 2016 2:33 PM