podman-container-tools/podman · error
save socket listen environments error: %m
Error message
save socket listen environments error: %m
What it means
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.
Source
Thrown at pkg/rootless/rootless_linux.c:806
if (geteuid () != 0 || getenv ("_CONTAINERS_USERNS_CONFIGURED") == NULL)
do_preexec_hooks(argv, argc);
listen_pid = getenv("LISTEN_PID");
listen_fds = getenv("LISTEN_FDS");
listen_fdnames = getenv("LISTEN_FDNAMES");
if (listen_pid != NULL && listen_fds != NULL && strtol(listen_pid, NULL, 10) == getpid())
{
// save systemd socket environment for rootless child
do_socket_activation = true;
saved_systemd_listen_pid = strdup(listen_pid);
saved_systemd_listen_fds = strdup(listen_fds);
if (listen_fdnames != NULL)
saved_systemd_listen_fdnames = strdup(listen_fdnames);
if (saved_systemd_listen_pid == NULL
|| saved_systemd_listen_fds == NULL)
{
fprintf (stderr, "save socket listen environments error: %m\n");
_exit (EXIT_FAILURE);
}
}
/* Shortcut. If we are able to join the existing namespace, do it now so we
don't need to re-exec. First try using namespace file handles, then fall back
to the pause.pid approach for older kernels. */
xdg_runtime_dir = getenv ("XDG_RUNTIME_DIR");
if (geteuid () != 0 && xdg_runtime_dir && xdg_runtime_dir[0] && can_use_shortcut (argv))
{
cleanup_free char *cwd = NULL;
cleanup_close int userns_fd = -1;
cleanup_close int mntns_fd = -1;
cleanup_close int fd = -1;
long pid;
char buf[12];
uid_t uid;
gid_t gid;View on GitHub (pinned to a2409076ef)
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
Example fix
# before # podman.service has MemoryMax=32M; API connections die with # 'save socket listen environments error: Cannot allocate memory' # after $ sudo systemctl edit podman.service [Service] MemoryMax=infinity $ sudo systemctl daemon-reload && sudo systemctl restart podman.socket
Defensive patterns
Strategy: validation
Validate before calling
# For socket-activated API usage, sanity-check limits in the unit systemctl show podman.service -p MemoryMax -p LimitAS # ensure they are unlimited or generous before enabling the socket
Prevention
- 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
When it happens
Trigger: systemd socket activation of podman.socket/podman.service combined with memory exhaustion: MemoryMax on the service, RLIMIT_AS, or host OOM at connection time.
Common situations: 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.
Related errors
- malloc: %m
- unable to print to string
- realloc buffer: %m
- cannot retrieve cmd line
- cannot read argv: %m
AI-assisted analysis of podman-container-tools/podman@a2409076ef (2026-08-15).
Data as JSON: /api/errors/42600d951782927c.
Report an issue: GitHub.