Bug 703919
Summary: | gcov crashes if program alters its own environment | ||
---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Eric Blake <eblake> |
Component: | gcc | Assignee: | Jakub Jelinek <jakub> |
Status: | CLOSED NOTABUG | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
Severity: | unspecified | Docs Contact: | |
Priority: | unspecified | ||
Version: | 14 | CC: | jakub |
Target Milestone: | --- | Keywords: | Reopened |
Target Release: | --- | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | Bug Fix | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2011-05-17 15:41:09 UTC | Type: | --- |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Eric Blake
2011-05-11 16:40:34 UTC
This is clearly a bug in the testcase you are using, it is normal that there are various atexit handlers and disallowing getenv in all of them is a bug. I agree that the code that originally exposed this problem was due to a bug in the program for preventing getenv() from working in an atexit handler, and that buggy program in libvirt has since been fixed to lengthen the lifetime of the new value assigned to environ. However, I disagree with your assessment that this does not represent a real bug in gcov code - suppose I change the example in some other manner, without causing getenv() to fail in an atexit handler, but instead by changing the environment so that successive profile calls read different env var contents and corrupt the state expected by gcov. That is, I think gcov is putting itself at risk by allowing user changes to environ to affect gcov's behavior; gcov would be safer by reading the environment once, up front, and using those cached values at all other points in the program where gcov is currently querying the environment again. libgcov is calling getenv solely during the atexit handler, unless you fork, thus it works just fine if the app changes the env vars, as long as getenv can be called. |