{"record":{"id":"966c7cf8b542928a","repo":"dotnet/runtime","slug":"failed-to-initialize-icu-data","errorCode":null,"errorMessage":"Failed to initialize ICU data","messagePattern":"Failed to initialize ICU data","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"src/native/libs/Common/JavaScript/host/assets.ts","lineNumber":194,"sourceCode":"    _ems_.HEAPU32[outSize as any >>> 2] = 0;\n    _ems_.HEAPU32[((outSize as any) + 4) >>> 2] = 0;\n    return false;\n}\n\nexport function loadIcuData(bytes: Uint8Array) {\n    const sp = _ems_.stackSave();\n    try {\n        const ptrPtr = _ems_.stackAlloc(sizeOfPtr);\n        if (_ems_._posix_memalign(ptrPtr as any, 16, bytes.length)) {\n            throw new Error(\"posix_memalign failed for ICU data\");\n        }\n\n        const ptr = _ems_.HEAPU32[ptrPtr as any >>> 2];\n        _ems_.HEAPU8.set(bytes, ptr >>> 0);\n\n        const result = _ems_._wasm_load_icu_data(ptr as unknown as VoidPtr);\n        if (!result) {\n            throw new Error(\"Failed to initialize ICU data\");\n        }\n    } finally {\n        _ems_.stackRestore(sp);\n    }\n}\n\nexport function installVfsFile(bytes: Uint8Array, asset: VfsAsset) {\n    const virtualName: string = typeof (asset.virtualPath) === \"string\"\n        ? asset.virtualPath\n        : asset.name;\n    const lastSlash = virtualName.lastIndexOf(\"/\");\n    let parentDirectory = (lastSlash > 0)\n        ? virtualName.substring(0, lastSlash)\n        : browserVirtualAppBase;\n    let fileName = (lastSlash > 0)\n        ? virtualName.substring(lastSlash + 1)\n        : virtualName;\n    if (fileName.startsWith(\"/\")) {","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/dotnet/runtime/blob/60108ba66eb7d1d12f595480091b4ad80a24b172/src/native/libs/Common/JavaScript/host/assets.ts#L176-L212","documentation":"Thrown by loadIcuData() (src/native/libs/Common/JavaScript/host/assets.ts:181) after the aligned buffer is allocated and copied. The buffer is handed to _wasm_load_icu_data; if that native function returns a falsy value the ICU engine rejected the data (parse failure, version mismatch, or wrong endianness), and the runtime cannot provide globalization.","triggerScenarios":"The ICU bytes are allocated and copied into the heap, then _wasm_load_icu_data(ptr) is called. A zero/false return triggers the error at line 193.","commonSituations":"ICU data file from a different ICU major version than the runtime's native ICU; truncated or corrupted icudt download (e.g. a 200 HTML error page saved as the asset); integrity check disabled so a bad file was accepted.","solutions":["Re-publish so the ICU shard matches the runtime's ICU version (do not mix SDK/runtime ICU artifacts).","Verify the downloaded ICU asset is the real binary (check Content-Type and that it is not an HTML error page).","Keep integrity hashes enabled so a corrupted ICU file is rejected before it reaches the loader."],"exampleFix":"// before: integrity disabled, CDN served an HTML 404 page as icudt.dat\n// config: { disableIntegrityCheck: true }\n\n// after: keep integrity on and serve the correct binary\n// config: { /* integrity enabled (default) */ }","handlingStrategy":"try-catch","validationCode":"async function verifyIcuBytes(url: string): Promise<boolean> {\n  const r = await fetch(url);\n  const ct = r.headers.get('Content-Type') || '';\n  return r.ok && ct !== 'text/html'; // not an error page\n}","typeGuard":null,"tryCatchPattern":"try {\n  await dotnetBrowserHostExports.loadIcuData(bytes);\n} catch (err) {\n  if (/Failed to initialize ICU data/.test(String((err as Error).message))) {\n    // ICU data version mismatch or corruption: redeploy matching ICU shard\n  }\n  throw err;\n}","preventionTips":["Ship the ICU shard that matches the runtime's native ICU version.","Keep integrity hashes enabled so corrupted ICU downloads are rejected.","Verify the downloaded ICU asset is binary, not an HTML error page."],"tags":["icu","globalization","data-corruption","native"],"backgroundTag":null,"analyzedSha":"60108ba66eb7d1d12f595480091b4ad80a24b172","analyzedAt":"2026-08-10T18:54:11.478Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}