{"record":{"id":"ae303f00d8265fdb","repo":"dotnet/runtime","slug":"execv-s-failed-s-n","errorCode":null,"errorMessage":"execv(%s) failed: %s\\n","messagePattern":"execv\\((.+?)\\) failed: (.+?)\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/coreclr/tools/superpmi/superpmi/parallelsuperpmi.cpp","lineNumber":233,"sourceCode":"            fprintf(stderr, \"dup2(stdout) failed: %s\\n\", strerror(errno));\n            _exit(1);\n        }\n        if (dup2(hStdError, STDERR_FILENO) == -1)\n        {\n            fprintf(stderr, \"dup2(stderr) failed: %s\\n\", strerror(errno));\n            _exit(1);\n        }\n\n        // Close the original fds now that they are duplicated to STDOUT/STDERR.\n        // The O_CLOEXEC on the parent's open() handles the sibling worker fds.\n        if (hStdOutput != STDOUT_FILENO)\n            close(hStdOutput);\n        if (hStdError != STDERR_FILENO)\n            close(hStdError);\n\n        execv(argv[0], argv);\n        // If execv returns, it failed.\n        fprintf(stderr, \"execv(%s) failed: %s\\n\", argv[0], strerror(errno));\n        _exit(1);\n    }\n\n    // Parent process: free argv and return.\n    for (int i = 0; i < argc; i++)\n        delete[] argv[i];\n    delete[] argv;\n    return true;\n}\n\n#endif // TARGET_UNIX\n\nvoid ReadMCLToArray(char* mclFilename, int** arr, int* count)\n{\n    *count     = 0;\n    *arr       = nullptr;\n    char* buff = nullptr;\n","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/dotnet/runtime/blob/60108ba66eb7d1d12f595480091b4ad80a24b172/src/coreclr/tools/superpmi/superpmi/parallelsuperpmi.cpp#L215-L251","documentation":"After the forked ParallelSuperPMI child has redirected stdout/stderr it calls execv(argv[0],argv) to become a superpmi worker. execv only returns on failure; if it does, the child prints the target path and strerror(errno) and _exit(1). The parent's StartProcess already returned true (fork succeeded) so the failure surfaces as a worker that dies immediately.","triggerScenarios":"argv[0] does not exist (ENOENT), is not executable or permissions deny (EACCES), wrong ELF/arch (ENOEXEC), path too long (ENAMETOOLONG), or the binary is a directory. The parsed command line's first token is the worker executable.","commonSituations":"Running parallelsuperpmi without the worker (superpmi/mcs) on PATH or with a relative path resolved against the wrong cwd; a build that produced the orchestrator but not the worker; cross-arch copy; stale SuperPMIShimPath / worker path; executable bit lost during packaging.","solutions":["Pass an absolute path to the worker executable as argv[0], or ensure it is on PATH for the spawned shell.","Confirm the worker file exists and is executable (chmod +x; ls -l) and matches the host arch (file <worker>).","Rebuild SuperPMI so both orchestrator and worker binaries are present in artifacts/bin.","Run parallelsuperpmi with the same cwd/PATH used at build time, or set -executablePath to the artifacts bin dir."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Validate the worker executable is runnable before forking.\n#include <unistd.h>\n#include <sys/stat.h>\nstatic bool WorkerExecutable(const char* path) {\n    struct stat st;\n    if (stat(path, &st) != 0) return false;       // ENOENT\n    if (!S_ISREG(st.st_mode)) return false;       // not a regular file\n    if (access(path, X_OK) != 0) return false;    // not executable\n    return true;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass an absolute path as argv[0] for the worker executable.","stat()+access(X_OK) the worker before launching parallelsuperpmi.","Ensure the worker arch matches the host (file <worker>).","Run from the artifacts/bin directory or set the executable-path flag."],"tags":["superpmi","parallelsuperpmi","execv","fork","enoent","unix"],"backgroundTag":null,"analyzedSha":"60108ba66eb7d1d12f595480091b4ad80a24b172","analyzedAt":"2026-08-10T18:54:11.478Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}