Summary: | Memcheck leak checking is not friendly to fork-exec idiom if exec fails in the presence of threads | ||
---|---|---|---|
Product: | [Developer tools] valgrind | Reporter: | Timur Iskhodzhanov <timurrrr> |
Component: | memcheck | Assignee: | Julian Seward <jseward> |
Status: | REPORTED --- | ||
Severity: | normal | CC: | bruening |
Priority: | NOR | ||
Version: | 3.7 SVN | ||
Target Milestone: | --- | ||
Platform: | Unlisted Binaries | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
Timur Iskhodzhanov
2011-09-14 14:31:39 UTC
Also, the same happens if I replace "exit(1);" with "abort();" Possible workarounds: a) at the fork time, mark all known allocations as "reachable" / "remembered" b) at the fork time & if threads are present, set a flag to skip leak checking in the child process c) add a memcheck client request to avoid leak checking and call it before exit(1) d) ignore leak checking on "abort();" Self-correction: a) at the fork time, mark all known allocations as "reachable" / "remembered" in the child process. Side effect: may miss some child-only leaks b) at the fork time & if threads are present, set a flag to skip leak checking in the child process. Maybe worth adding a "if exec is called and failed" condition c) ... before exit(nonzero) ... e) skip leak checking after exec failure I'm going to assume that in the fork child Memcheck goes and marks the stacks for now-dead threads as unaddressable and that's why its leak scan fails to find formerly-local vars in memory (which is the case for this test app compiled w/ default flags). Why not mark the bogus stacks as unaddressable for most purposes, but treat as defined (up to former-top-of-stack) for the leak scan itself? You'll still have a risk of reporting a leak that was anchored only in a register but that may be rare enough. OTOH, if a multi-threaded app forks and never execs, reporting these leaks seems the right thing, so perhaps trigger this defined-for-scan on the presence of a failed exec. |