{"record":{"id":"55a5d2f2ed386066","repo":"dotnet/runtime","slug":"ctf-sequence-needs-to-have-its-memory-expilicitly","errorCode":null,"errorMessage":"ctf_sequence needs to have its memory expilicitly laid out","messagePattern":"ctf_sequence needs to have its memory expilicitly laid out","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/coreclr/scripts/genLttngProvider.py","lineNumber":213,"sourceCode":"            ctf_type    = None\n            varname     = fnparam.name\n\n            if fnparam.prop:\n                #this is an explicit struct treat as a sequence\n                ctf_type = \"ctf_sequence\"\n                sizeofseq = fnparam.prop\n                field_body = \", \".join((typewName, varname, varname, \"size_t\", sizeofseq))\n\n            else:\n                ctf_type = ctfDataTypeMapping[wintypeName]\n                if ctf_type == \"ctf_string\":\n                    field_body = \", \".join((varname, varname))\n\n                elif ctf_type == \"ctf_integer\" or ctf_type == \"ctf_float\":\n                    field_body = \", \".join((typewName, varname, varname))\n\n                elif ctf_type == \"ctf_sequence\":\n                    raise Exception(\"ctf_sequence needs to have its memory expilicitly laid out\")\n\n                else:\n                    raise Exception(\"no such ctf intrinsic called: \" +  ctf_type)\n\n            field_list.append(\"        %s(%s)\" % (ctf_type, field_body))\n\n        field_list = \"\\n\".join(field_list)\n\n    return header + field_list + footer\n\ndef generateLttngHeader(providerName, allTemplates, eventNodes, runtimeFlavor):\n    lTTngHdr = []\n    for templateName in allTemplates:\n        template = allTemplates[templateName]\n        fnSig   = allTemplates[templateName].signature\n\n        lTTngHdr.append(\"\\n#define \" + templateName + \"_TRACEPOINT_ARGS \\\\\\n\")\n","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/dotnet/runtime/blob/60108ba66eb7d1d12f595480091b4ad80a24b172/src/coreclr/scripts/genLttngProvider.py#L195-L231","documentation":"Raised by generateFieldList() in genLttngProvider.py when a template parameter's winType maps to ctf_sequence in ctfDataTypeMapping but the parameter has no 'prop' (property) set. The ctf_sequence CTF macro requires explicit memory layout information (the sequence length/element-size variable), which is normally provided via the count property. Without it, the generator cannot produce valid LTTng tracepoint field code.","triggerScenarios":"Triggered when: (a) fnparam.prop is falsy (None or empty), so the code enters the else branch, (b) ctfDataTypeMapping[wintypeName] returns 'ctf_sequence', and (c) the code reaches the 'ctf_sequence' branch which immediately raises. Types that map to ctf_sequence are: win:count, win:Struct, win:GUID, and win:Binary. For win:GUID and win:Binary without a prop, this error fires because the generator expects explicit struct/sequence layout via the prop field.","commonSituations":"A template data element uses win:GUID or win:Binary without a count attribute, so FunctionParameter assigns count='win:null' and prop remains None. The manifest was previously handled by ETW (mc.exe) but the LTTng generator requires additional annotations. A type that needs sequence layout in LTTng doesn't have the necessary count/length specification in the manifest.","solutions":["Add a 'count' attribute to the <data> element in the manifest referencing the variable that holds the sequence length.","Ensure the data element has the proper struct/array annotation so fnparam.prop is set during parseTemplateNodes().","If using win:GUID, verify the code path in parseTemplateNodes sets var_Props for GUID types (it does set sizeof(GUID)/sizeof(int)).","Use a different inType that doesn't map to ctf_sequence if the data doesn't need sequence semantics."],"exampleFix":"<!-- before: GUID without count/struct layout -->\n<data name=\"MyGuid\" inType=\"win:GUID\" />\n\n<!-- after: the parseTemplateNodes code sets prop for win:GUID automatically,\n     so if this fires, the issue may be a win:Binary without count -->\n<data name=\"RawData\" inType=\"win:Binary\" count=\"DataLen\" />\n<data name=\"DataLen\" inType=\"win:UInt32\" />","handlingStrategy":"validation","validationCode":"# Types that map to ctf_sequence and need explicit prop\nSEQUENCE_TYPES_REQUIRING_PROP = {'win:GUID', 'win:Binary', 'win:Struct', 'win:count'}\n\ndef validate_template_for_lttng(template_nodes) -> list:\n    \"\"\"Check that ctf_sequence-mapped types have the necessary prop/count attribute.\"\"\"\n    from genEventing import parseTemplateNodes, getPalDataTypeMapping\n    from genLttngProvider import ctfDataTypeMapping\n\n    issues = []\n    templates = parseTemplateNodes(template_nodes)\n    for tid, template in templates.items():\n        for param_name in template.signature.paramlist:\n            fnparam = template.signature.getParam(param_name)\n            if fnparam.winType in SEQUENCE_TYPES_REQUIRING_PROP:\n                if not fnparam.prop:\n                    issues.append(\n                        f\"Template '{tid}', param '{param_name}' ({fnparam.winType}): \"\n                        f\"needs explicit count/struct layout for LTTng ctf_sequence\")\n    return issues","typeGuard":"null","tryCatchPattern":"try:\n    generateLttngHeader(providerName, allTemplates, eventNodes, runtimeFlavor)\nexcept Exception as e:\n    if 'ctf_sequence' in str(e):\n        print(f\"LTTng generation failed: {e}\")\n        print(\"Add a 'count' attribute referencing the length variable for the sequence data element.\")\n    raise","preventionTips":["Ensure all win:GUID, win:Binary, and win:Struct data elements have proper count attributes in the manifest.","Test LTTng generation separately from ETW generation to catch LTTng-specific issues early.","Document which types require explicit memory layout for LTTng vs. ETW.","Add the count/length variable as a separate <data> element before the sequence element."],"tags":["lttng","etw","manifest","eventing","coreclr","ctf"],"backgroundTag":null,"analyzedSha":"60108ba66eb7d1d12f595480091b4ad80a24b172","analyzedAt":"2026-08-10T18:54:11.478Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}