{"record":{"id":"f2546601f1fd20d8","repo":"sgl-project/sglang","slug":"cuda-coredump-env-var-key-is-already-set-to-os","errorCode":null,"errorMessage":"CUDA coredump env var {key} is already set to '{os.environ[key]}', skipping injection of '{value}'.","messagePattern":"CUDA coredump env var (.+?) is already set to '(.+?)', skipping injection of '(.+?)'\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"python/sglang/srt/debug_utils/cuda_coredump.py","lineNumber":66,"sourceCode":"        return os.path.join(base, f\"{run_id}-{attempt}\")\n    return base\n\n\ndef _inject_env():\n    \"\"\"Inject CUDA coredump environment variables into the current process.\n    If a CUDA_* variable is already present, skip it and log a warning.\"\"\"\n    dump_dir = get_dump_dir()\n    os.makedirs(dump_dir, exist_ok=True)\n\n    env_vars = {\n        \"CUDA_ENABLE_COREDUMP_ON_EXCEPTION\": \"1\",\n        \"CUDA_COREDUMP_SHOW_PROGRESS\": \"1\",\n        \"CUDA_COREDUMP_GENERATION_FLAGS\": _CUDA_COREDUMP_FLAGS,\n        \"CUDA_COREDUMP_FILE\": f\"{dump_dir}/cuda_coredump_%h.%p.%t\",\n    }\n    for key, value in env_vars.items():\n        if key in os.environ:\n            warnings.warn(\n                f\"CUDA coredump env var {key} is already set to \"\n                f\"'{os.environ[key]}', skipping injection of '{value}'.\",\n                stacklevel=2,\n            )\n        else:\n            os.environ[key] = value\n\n\ndef cleanup_dump_dir():\n    \"\"\"Remove stale coredump files from the dump directory.\"\"\"\n    dump_dir = get_dump_dir()\n    for f in glob.glob(os.path.join(dump_dir, \"cuda_coredump_*\")):\n        os.remove(f)\n\n\ndef report():\n    \"\"\"Log any CUDA coredump files found after a test failure.\"\"\"\n    dump_dir = get_dump_dir()","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/debug_utils/cuda_coredump.py#L48-L84","documentation":"sglang's CUDA coredump helper injects CUDA_COREDUMP_* env vars to configure crash dumps. If one of these is already present in the environment, injection is skipped for that key and this warning tells you the pre-existing value wins.","triggerScenarios":"Enabling the coredump debug utility while CUDA_COREDUMP_FILE, CUDA_COREDUMP_GENERATION_FLAGS, CUDA_COREDUMP_SHOW_PROGRESS, or CUDA_COREDUMP_PIPE limits are already exported (common in CI or container images that preconfigure coredumps).","commonSituations":"Containers/base images with CUDA coredump preconfigured; a previous coredump session whose exports persisted into the shell; ops runbooks setting dump file patterns globally.","solutions":["Verify the existing value matches your intended dump location/flags","Unset the preexisting var (unset CUDA_COREDUMP_FILE ...) before enabling sglang's helper so it can inject its defaults","Keep your value and ignore the warning if the custom configuration is intentional"],"exampleFix":"# before\nCUDA_COREDUMP_FILE=/custom/core.%p python app.py\n# after\nunset CUDA_COREDUMP_FILE && python app.py  # let sglang inject defaults","handlingStrategy":"validation","validationCode":"for k in (\"CUDA_COREDUMP_FILE\", \"CUDA_COREDUMP_GENERATION_FLAGS\", \"CUDA_COREDUMP_SHOW_PROGRESS\"):\n    os.environ.pop(k, None)  # before enabling sglang coredump helper","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Start debug sessions from a clean shell","Document intended coredump config when overriding defaults"],"tags":["cuda-coredump","environment-variables","debugging","configuration"],"backgroundTag":"env-var-already-set","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}