{"record":{"id":"c347aec7cf30d0fd","repo":"dotnet/runtime","slug":"no-clrinstanceid-field-of-type-win-uint16-for-e","errorCode":null,"errorMessage":"{}:No ClrInstanceID field of type win:UInt16 for event symbol {}","messagePattern":"(.+?):No ClrInstanceID field of type win:UInt16 for event symbol (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/coreclr/scripts/genEtwProvider.py","lineNumber":123,"sourceCode":"        templateNodes         = providerNode.getElementsByTagName('template')\n        eventProvider         = providerNode.getAttribute('name')\n        allTemplates          = parseTemplateNodes(templateNodes)\n\n        for eventNode in eventNodes:\n            taskName         = eventNode.getAttribute('task')\n            eventSymbol      = eventNode.getAttribute('symbol')\n            eventTemplate    = eventNode.getAttribute('template')\n            eventValue       = int(eventNode.getAttribute('value'))\n            clrInstanceBit   = getStackWalkBit(eventProvider, taskName, eventSymbol, exclusionInfo.noclrinstance)\n            sLookupFieldName = \"ClrInstanceID\"\n            sLookupFieldType = \"win:UInt16\"\n\n            if clrInstanceBit and allTemplates.get(eventTemplate):\n                # check for the event template and look for a field named ClrInstanceId of type win:UInt16\n                fnParam = allTemplates[eventTemplate].getFnParam(sLookupFieldName)\n\n                if not(fnParam and fnParam.winType == sLookupFieldType):\n                    raise Exception(exclusion_filename + \":No \" + sLookupFieldName + \" field of type \" + sLookupFieldType + \" for event symbol \" +  eventSymbol)\n\n            # If some versions of an event are on the nostack/stack lists,\n            # and some versions are not on either the nostack or stack list,\n            # then developer likely forgot to specify one of the versions\n\n            eventStackBitFromNoStackList       = getStackWalkBit(eventProvider, taskName, eventSymbol, exclusionInfo.nostack)\n            eventStackBitFromExplicitStackList = getStackWalkBit(eventProvider, taskName, eventSymbol, exclusionInfo.explicitstack)\n            sStackSpecificityError = exclusion_filename + \": Error processing event :\" + eventSymbol + \"(ID\" + str(eventValue) + \"): This file must contain either ALL versions of this event or NO versions of this event. Currently some, but not all, versions of this event are present\\n\"\n\n            if not stackSupportSpecified.get(eventValue):\n                 # Haven't checked this event before.  Remember whether a preference is stated\n                if ( not eventStackBitFromNoStackList) or ( not eventStackBitFromExplicitStackList):\n                    stackSupportSpecified[eventValue] = True\n                else:\n                    stackSupportSpecified[eventValue] = False\n            else:\n                # We've checked this event before.\n                if stackSupportSpecified[eventValue]:","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/dotnet/runtime/blob/60108ba66eb7d1d12f595480091b4ad80a24b172/src/coreclr/scripts/genEtwProvider.py#L105-L141","documentation":"Raised by checkConsistency() in genEtwProvider.py during manifest validation. For events that have stack-walk enabled (clrInstanceBit is True) and have a template, the script checks that the template contains a field named 'ClrInstanceID' of type 'win:UInt16'. If this field is missing or has the wrong type, the exception fires with the event symbol name.","triggerScenarios":"Triggered when: (a) the event is not in the exclusion list's noclrinstance set (so clrInstanceBit is True), (b) the event has a template that exists in allTemplates, and (c) allTemplates[eventTemplate].getFnParam('ClrInstanceID') returns None or its winType is not 'win:UInt16'. This is a manifest correctness check ensuring every stack-walking event carries the ClrInstanceID correlation field.","commonSituations":"A developer adds a new ETW event to ClrEtwAll.man with a template that enables stack collection but forgets to include the ClrInstanceID field. An existing event's template is modified and the ClrInstanceID field is accidentally removed or its type changed. The event symbol is added to the noclrinstance exclusion list but the list file path is wrong, so the exclusion isn't applied.","solutions":["Add a '<data name=\"ClrInstanceID\" inType=\"win:UInt16\" />' field to the event's template in the .man manifest file.","If the event should not carry a ClrInstanceID, add its provider:task:symbol to the noclrinstance section of the exclusion list file (--exc argument).","Verify the exclusion list file path is correct and the parseExclusionList function is reading it properly.","Check for typos in the event symbol name in the exclusion list."],"exampleFix":"<!-- before: template missing ClrInstanceID -->\n<template tid=\"t:MyEvent\">\n  <data name=\"Count\" inType=\"win:UInt32\" />\n</template>\n\n<!-- after: add ClrInstanceID field -->\n<template tid=\"t:MyEvent\">\n  <data name=\"Count\" inType=\"win:UInt32\" />\n  <data name=\"ClrInstanceID\" inType=\"win:UInt16\" />\n</template>","handlingStrategy":"validation","validationCode":"def validate_clr_instance_id(manifest_path: str, exclusion_path: str) -> bool:\n    \"\"\"Pre-check that all stack-walking events have ClrInstanceID in their template.\"\"\"\n    import xml.dom.minidom as DOM\n    from genEventing import parseTemplateNodes\n    from utilities import parseExclusionList\n\n    tree = DOM.parse(manifest_path)\n    exclusion_info = parseExclusionList(exclusion_path)\n\n    for provider_node in tree.getElementsByTagName('provider'):\n        event_provider = provider_node.getAttribute('name')\n        templates = parseTemplateNodes(provider_node.getElementsByTagName('template'))\n        for event_node in provider_node.getElementsByTagName('event'):\n            task = event_node.getAttribute('task')\n            symbol = event_node.getAttribute('symbol')\n            template = event_node.getAttribute('template')\n            # Check if event needs ClrInstanceID (not in noclrinstance list)\n            needs_clr_instance = True\n            for entry in exclusion_info.noclrinstance:\n                tokens = entry.split(':')\n                if (tokens[0] in (event_provider, '*') and\n                    tokens[1] in (task, '*') and\n                    tokens[2] in (symbol, '*')):\n                    needs_clr_instance = False\n                    break\n            if needs_clr_instance and template in templates:\n                param = templates[template].getFnParam('ClrInstanceID')\n                if not (param and param.winType == 'win:UInt16'):\n                    print(f\"MISSING ClrInstanceID for event {symbol}\")\n                    return False\n    return True","typeGuard":"null","tryCatchPattern":"try:\n    checkConsistency(manifest, exclusion_filename)\nexcept Exception as e:\n    if 'ClrInstanceID' in str(e):\n        print(f\"Manifest validation failed: {e}\")\n        print(\"Add ClrInstanceID field to the template or add event to noclrinstance list.\")\n    raise","preventionTips":["Always add ClrInstanceID (win:UInt16) to templates used by stack-walking events.","Keep the exclusion list file in sync with manifest changes.","Run genEtwProvider.py locally before pushing manifest changes.","Use consistent event naming so exclusion list entries match correctly.","Document which events intentionally skip ClrInstanceID."],"tags":["etw","manifest","eventing","coreclr","validation"],"backgroundTag":null,"analyzedSha":"60108ba66eb7d1d12f595480091b4ad80a24b172","analyzedAt":"2026-08-10T18:54:11.478Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}