{"record":{"id":"42600d951782927c","repo":"podman-container-tools/podman","slug":"save-socket-listen-environments-error-m","errorCode":null,"errorMessage":"save socket listen environments error: %m\n","messagePattern":"save socket listen environments error: %m\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/rootless/rootless_linux.c","lineNumber":806,"sourceCode":"  if (geteuid () != 0 || getenv (\"_CONTAINERS_USERNS_CONFIGURED\") == NULL)\n    do_preexec_hooks(argv, argc);\n\n  listen_pid = getenv(\"LISTEN_PID\");\n  listen_fds = getenv(\"LISTEN_FDS\");\n  listen_fdnames = getenv(\"LISTEN_FDNAMES\");\n\n  if (listen_pid != NULL && listen_fds != NULL && strtol(listen_pid, NULL, 10) == getpid())\n    {\n      // save systemd socket environment for rootless child\n      do_socket_activation = true;\n      saved_systemd_listen_pid = strdup(listen_pid);\n      saved_systemd_listen_fds = strdup(listen_fds);\n      if (listen_fdnames != NULL)\n        saved_systemd_listen_fdnames = strdup(listen_fdnames);\n      if (saved_systemd_listen_pid == NULL\n          || saved_systemd_listen_fds == NULL)\n        {\n          fprintf (stderr, \"save socket listen environments error: %m\\n\");\n          _exit (EXIT_FAILURE);\n        }\n    }\n\n  /* Shortcut.  If we are able to join the existing namespace, do it now so we\n     don't need to re-exec.  First try using namespace file handles, then fall back\n     to the pause.pid approach for older kernels.  */\n  xdg_runtime_dir = getenv (\"XDG_RUNTIME_DIR\");\n  if (geteuid () != 0 && xdg_runtime_dir && xdg_runtime_dir[0] && can_use_shortcut (argv))\n    {\n      cleanup_free char *cwd = NULL;\n      cleanup_close int userns_fd = -1;\n      cleanup_close int mntns_fd = -1;\n      cleanup_close int fd = -1;\n      long pid;\n      char buf[12];\n      uid_t uid;\n      gid_t gid;","sourceCodeStart":788,"sourceCodeEnd":824,"githubUrl":"https://github.com/podman-container-tools/podman/blob/a2409076ef2fef60ad9ac046375dedc7d9410ef4/pkg/rootless/rootless_linux.c#L788-L824","documentation":"When podman is socket-activated (LISTEN_PID equals getpid() and LISTEN_FDS is set), the C preamble strdups LISTEN_PID, LISTEN_FDS and LISTEN_FDNAMES into saved globals so the socket environment survives the later re-exec into the user namespace (pkg/rootless/rootless_linux.c:799-808). This message means one of the strdup calls returned NULL (ENOMEM) and the process _exits immediately.","triggerScenarios":"systemd socket activation of podman.socket/podman.service combined with memory exhaustion: MemoryMax on the service, RLIMIT_AS, or host OOM at connection time.","commonSituations":"A tight MemoryMax= or memory cgroup limit on the podman systemd units; memory pressure on hosts running the podman API socket for many concurrent connections; virtually nothing else triggers strdup failure for these short strings.","solutions":["Raise or remove the memory limit on the socket-activated units: 'systemctl edit podman.service' and set/increase MemoryMax","Check for OOM events around the failure: 'journalctl -u podman.socket -u podman.service -k'","Retry after relieving memory pressure - the condition is transient","If limits are generous and it persists, report upstream with systemd unit overrides attached"],"exampleFix":"# before\n# podman.service has MemoryMax=32M; API connections die with\n# 'save socket listen environments error: Cannot allocate memory'\n\n# after\n$ sudo systemctl edit podman.service\n[Service]\nMemoryMax=infinity\n$ sudo systemctl daemon-reload && sudo systemctl restart podman.socket\n","handlingStrategy":"validation","validationCode":"# For socket-activated API usage, sanity-check limits in the unit\nsystemctl show podman.service -p MemoryMax -p LimitAS\n# ensure they are unlimited or generous before enabling the socket\n","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not set low MemoryMax on podman.socket/podman.service units","Monitor memory on API hosts serving many concurrent socket connections","Retry failed socket-activated commands after memory pressure passes - strdup failures are transient"],"tags":["socket-activation","systemd","memory","rootless","c"],"backgroundTag":null,"analyzedSha":"a2409076ef2fef60ad9ac046375dedc7d9410ef4","analyzedAt":"2026-08-15T15:57:05.625Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}