{"record":{"id":"3ef00e7b1c9a4163","repo":"dotnet/runtime","slug":"problem-waiting-for-createdump-waitpid-failed-r-3ef00e","errorCode":null,"errorMessage":"Problem waiting for createdump: waitpid() FAILED result %d wstatus %08x errno %s (%d)\\n","messagePattern":"Problem waiting for createdump: waitpid\\(\\) FAILED result (.+?) wstatus %08x errno (.+?) \\((.+?)\\)\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/coreclr/pal/src/thread/process.cpp","lineNumber":1617,"sourceCode":"            int count = 0;\n            while ((count = read(parent_read_pipe, errorMessageBuffer + bytesRead, cbErrorMessageBuffer - bytesRead)) > 0)\n            {\n                bytesRead += count;\n            }\n            errorMessageBuffer[bytesRead] = 0;\n            if (bytesRead > 0)\n            {\n                fputs(errorMessageBuffer, stderr);\n            }\n        }\n        close(parent_read_pipe);\n\n        // Parent waits until the child process is done\n        int wstatus = 0;\n        int result = waitpid(childpid, &wstatus, 0);\n        if (result != childpid)\n        {\n            fprintf(stderr, \"Problem waiting for createdump: waitpid() FAILED result %d wstatus %08x errno %s (%d)\\n\",\n                result, wstatus, strerror(errno), errno);\n            return false;\n        }\n        else\n        {\n#ifdef _DEBUG\n            fprintf(stderr, \"waitpid() returned successfully (wstatus %08x) WEXITSTATUS %x WTERMSIG %x\\n\", wstatus, WEXITSTATUS(wstatus), WTERMSIG(wstatus));\n#endif\n            return !WIFEXITED(wstatus) || WEXITSTATUS(wstatus) == 0;\n        }\n    }\n    return true;\n#endif // !TARGET_IOS && !TARGET_TVOS && !TARGET_WASM\n}\n\n/*++\nFunction:\n  PROCCreateCrashDump","sourceCodeStart":1599,"sourceCodeEnd":1635,"githubUrl":"https://github.com/dotnet/runtime/blob/60108ba66eb7d1d12f595480091b4ad80a24b172/src/coreclr/pal/src/thread/process.cpp#L1599-L1635","documentation":"Printed by PROCCreateCrashDump after the parent calls waitpid(childpid,&wstatus,0) to reap the forked createdump child. If waitpid does not return childpid the dump result is considered unreliable and the function returns false, reporting result, wstatus and errno. The most common cause is ECHILD, meaning the child was already reaped (for example by a concurrent SIGCHLD handler), but EINTR/EINVAL are also possible. This guards the crash-dump lifecycle so a half-finished dump is not reported as success.","triggerScenarios":"Reached whenever waitpid for the createdump child returns a value other than childpid: the child was already collected by another waitpid in a signal handler (ECHILD), the call was interrupted and the retry loop is absent, or childpid is invalid (EINVAL). It is strictly a parent-side diagnostic after the dump child has been launched.","commonSituations":"An application installs a SIGCHLD/SIGCLD handler that calls wait/waitpid and inadvertently reaps the createdump child first; nested signal handlers during a crash; pid-reuse races on very long-lived hosts; a second crash-dump triggering while the first child is still being collected.","solutions":["Avoid reaping unrelated children in custom signal handlers: have SIGCHLD handlers use waitpid(WNOHANG) only for pids they own, never a blanket wait().","Temporarily block SIGCHLD (sigprocmask) around the crash-dump path, or ensure the runtime's crash handler is the only waiter for the createdump pid.","Inspect wstatus/errno in the message: ECHILD points to a double-reap race, EINTR to a missing retry, EINVAL to pid corruption.","If dumps are unreliable in this environment, capture them out-of-process (dotnet-dump collect on a live process) instead of relying on the in-crash fork."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Avoid double-reaping the createdump child from a custom signal handler.\n// If you must handle SIGCHLD, only reap pids you own:\nstatic void SafeSigchld(int sig) {\n    int saved = errno;\n    while (true) {\n        pid_t p = waitpid((pid_t)-1, NULL, WNOHANG);\n        if (p <= 0) break;\n        // ONLY treat p if it is one of YOUR known child pids; never blanket-reap.\n    }\n    errno = saved;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never call bare wait()/waitpid(-1) in SIGCHLD handlers; use WNOHANG and reap only known pids.","Block SIGCHLD (sigprocmask) around crash-dump logic if you control the handler.","Avoid launching your own children concurrently with crash-dump generation to remove reaping races.","Collect dumps out-of-process (dotnet-dump) when in-process reaping races are unavoidable."],"tags":["coreclr","createdump","crash-dump","waitpid","signals","linux","diagnostics"],"backgroundTag":null,"analyzedSha":"60108ba66eb7d1d12f595480091b4ad80a24b172","analyzedAt":"2026-08-10T18:54:11.478Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}