{"record":{"id":"f27c070453f1295e","repo":"openjdk/jdk","slug":"utf-error-s-d-s-n","errorCode":null,"errorMessage":"UTF ERROR [\\\"%s\\\":%d]: %s\\n","messagePattern":"UTF ERROR \\[\\\\\"(.+?)\\\\\":(.+?)\\]: (.+?)\\\\n","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/java.instrument/unix/native/libinstrument/EncodingSupport_md.c","lineNumber":51,"sourceCode":"\n/* Routines to convert back and forth between Platform Encoding and UTF-8 */\n\n/* Error and assert macros */\n#define UTF_ERROR(m) utfError(__FILE__, __LINE__,  m)\n#define UTF_ASSERT(x) ( (x)==0 ? UTF_ERROR(\"ASSERT ERROR \" #x) : (void)0 )\n#define UTF_DEBUG(x)\n\n/* Global variables */\nstatic iconv_t iconvToPlatform          = (iconv_t)-1;\nstatic iconv_t iconvFromPlatform        = (iconv_t)-1;\n\n/*\n * Error handler\n */\nstatic void\nutfError(char *file, int line, char *message)\n{\n    (void)fprintf(stderr, \"UTF ERROR [\\\"%s\\\":%d]: %s\\n\", file, line, message);\n    abort();\n}\n\n/*\n * Initialize all utf processing.\n */\nstatic void\nutfInitialize(void)\n{\n    const char* codeset;\n\n#ifndef MACOSX\n    /* Set the locale from the environment */\n    (void)setlocale(LC_ALL, \"\");\n\n    /* Get the codeset name */\n    codeset = (char*)nl_langinfo(CODESET);\n    if ( codeset == NULL || codeset[0] == 0 ) {","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/openjdk/jdk/blob/88dfb74bbeefcf2b0aa11835183bcd949998fc8f/src/java.instrument/unix/native/libinstrument/EncodingSupport_md.c#L33-L69","documentation":"Fatal error handler in the Unix encoding support for libinstrument: an iconv-based UTF-8/platform-encoding conversion failed (bad descriptor, incomplete byte sequence, or iconv_open failure for the platform codeset). The handler prints the file/line and message, then calls abort(), immediately terminating the JVM with SIGABRT.","triggerScenarios":"utf8ToPlatform/platformToUtf8 conversions failing: agent jar paths or class names containing byte sequences invalid in the platform locale; iconv_open unable to load the platform codeset (missing locale data, e.g. minimal container images); iconv descriptor closed/invalid after initialization failure.","commonSituations":"Running instrumented JVMs in slim Docker images without glibc locale data (POSIX/C locale with non-ASCII paths); agent jar paths with unusual Unicode; Alpine/musl-based images with incomplete iconv support.","solutions":["Set a full locale in the container: ENV LANG=C.UTF-8 (and install the locale package)","Keep agent jar paths pure ASCII to avoid platform-encoding conversion entirely","Use a base image that ships complete glibc/iconv data (e.g. full debian/ubuntu JDK images rather than stripped ones)","Check the printed file/line to see which conversion direction failed and validate that string's encoding"],"exampleFix":"# before (Dockerfile)\nFROM distroless-base\nENV LANG=C\n# after\nFROM ubuntu:24.04\nENV LANG=C.UTF-8 LC_ALL=C.UTF-8","handlingStrategy":"validation","validationCode":"// fail fast if the platform charset cannot round-trip agent paths\nCharset.defaultCharset();\nbyte[] b = agentPath.getBytes(StandardCharsets.UTF_8);\nif (!new String(b, StandardCharsets.UTF_8).equals(agentPath))\n    throw new IllegalStateException(\"agent path not round-trippable in UTF-8\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set LANG=C.UTF-8 in container images running instrumented JVMs","Use base images with complete glibc/iconv locale data","Keep agent jar paths ASCII-only to sidestep platform encoding entirely"],"tags":["java-instrument","iconv","encoding","locale","abort","containers"],"backgroundTag":null,"analyzedSha":"88dfb74bbeefcf2b0aa11835183bcd949998fc8f","analyzedAt":"2026-08-14T11:45:09.665Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}