{"record":{"id":"b8bd0ae2faa129a2","repo":"podman-container-tools/podman","slug":"malloc-m","errorCode":null,"errorMessage":"malloc: %m\n","messagePattern":"malloc: %m\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/rootless/rootless_linux.c","lineNumber":384,"sourceCode":"static void\nexec_binary (const char *path, char **argv, int argc)\n{\n  int r, status = 0;\n  pid_t pid;\n\n  pid = fork ();\n  if (pid < 0)\n    {\n      fprintf (stderr, \"fork: %m\\n\");\n      exit (EXIT_FAILURE);\n    }\n  if (pid == 0)\n    {\n      size_t i;\n      char **newargv = malloc ((argc + 2) * sizeof(char *));\n      if (!newargv)\n        {\n          fprintf (stderr, \"malloc: %m\\n\");\n          exit (EXIT_FAILURE);\n        }\n      newargv[0] = (char*) path;\n      for (i = 0; i < argc; i++)\n        newargv[i+1] = argv[i];\n\n      newargv[i+1] = NULL;\n      errno = 0;\n      execv (path, newargv);\n      /* If the file was deleted in the meanwhile, return success.  */\n      if (errno == ENOENT)\n        exit (EXIT_SUCCESS);\n      exit (EXIT_FAILURE);\n    }\n\n  r = TEMP_FAILURE_RETRY (waitpid (pid, &status, 0));\n  if (r < 0)\n    {","sourceCodeStart":366,"sourceCodeEnd":402,"githubUrl":"https://github.com/podman-container-tools/podman/blob/a2409076ef2fef60ad9ac046375dedc7d9410ef4/pkg/rootless/rootless_linux.c#L366-L402","documentation":"Before the Go runtime starts, podman's C preamble runs preexec hooks: exec_binary() forks and the child mallocs an argv vector of (argc + 2) char* pointers to execv() the hook (pkg/rootless/rootless_linux.c:381). This message means that malloc failed (ENOMEM) and the child exits with EXIT_FAILURE, which the parent propagates as the podman exit status. It is an out-of-memory condition in the forked hook child.","triggerScenarios":"Any podman invocation while the indicator file /etc/containers/podman_preexec_hooks.txt exists and one of the hook dirs (LIBEXECPODMAN/pre-exec-hooks, /etc/containers/pre-exec-hooks, or $PODMAN_PREEXEC_HOOKS_DIR) contains at least one entry, combined with memory exhaustion: RLIMIT_AS / 'ulimit -v' cap reached, cgroup MemoryMax hit, or host OOM pressure.","commonSituations":"Restrictive 'ulimit -v' inherited from a shell profile or systemd unit; a low MemoryMax on the user slice running rootless podman; very long podman command lines (large argc inflates the allocation); heavily loaded CI runners.","solutions":["Check and raise memory limits: run 'ulimit -v' and set it to unlimited (or the hard limit); inspect 'systemctl show user-$(id -u) -p MemoryMax' and the cgroup memory.max for the session","Check for OOM kills and free memory: 'dmesg | grep -i oom' / 'journalctl -k', then re-run the command","Confirm the hooks path is involved by temporarily removing /etc/containers/podman_preexec_hooks.txt (or the failing hook) and re-running","If it reproduces with sane limits, collect 'strace -f -e trace=malloc%' or a memory-limit report and open an upstream issue"],"exampleFix":"# before\n$ ulimit -v 65536\n$ podman run alpine ls\nmalloc: Cannot allocate memory\n\n# after\n$ ulimit -v unlimited\n$ podman run alpine ls\n","handlingStrategy":"validation","validationCode":"# Pre-flight before running podman with preexec hooks enabled\nif [ -e /etc/containers/podman_preexec_hooks.txt ]; then\n  # hooks will run; make sure address-space limits are not restrictive\n  soft=$(ulimit -Sv); hard=$(ulimit -Hv)\n  [ \"$hard\" = unlimited ] || [ \"$soft\" -lt \"$hard\" ] && ulimit -v \"$hard\" 2>/dev/null\nfi\npodman \"$@\"\n","typeGuard":null,"tryCatchPattern":"if ! podman \"$@\"; then\n  rc=$?\n  # 'malloc:' from the C helper is fatal; inspect limits before retrying once\n  ulimit -v; free -m\n  exit \"$rc\"\nfi","preventionTips":["Never set restrictive ulimit -v / RLIMIT_AS on shells, systemd units, or CI images that will run podman","Keep pre-exec-hooks directories small and reviewed","Monitor cgroup memory limits for rootless sessions running under systemd"],"tags":["memory","preexec-hooks","rootless","c","oom"],"backgroundTag":null,"analyzedSha":"a2409076ef2fef60ad9ac046375dedc7d9410ef4","analyzedAt":"2026-08-15T15:57:05.625Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}