* [PATCH] fix PR58602 (.gcno files not truncated at gcov_close)
@ 2013-10-03 15:01 Laurent Alfonsi
2014-01-16 12:13 ` Laurent Alfonsi
2014-02-03 8:55 ` Laurent Alfonsi
0 siblings, 2 replies; 4+ messages in thread
From: Laurent Alfonsi @ 2013-10-03 15:01 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 737 bytes --]
Hi All,
We have discovered a bug on gcno file generation registred as PR58602.
When the .gcno graph file is opened for generating the coverage graph
information, the mode used is w+ as this code is shared with updating
tools such as libgcov.
Thus, when GCC outputs .gcno files, it may leave garbage at the end of
the file if the file already exists when opening it.
This has been trackeddown from a kernel issue on lcov:
http://sourceforge.net/p/ltp/mailman/message/31141937/
This following patch fixes the function gcov_open() such that the .gcno
file is opened with truncation when gcc asks for creating a new file
(mode<0).
Regression test x86-64 are ok with this patch.
Is it ok to commit in trunk ?
Thanks
Laurent
[-- Attachment #2: pr58602.patch --]
[-- Type: text/x-patch, Size: 694 bytes --]
diff --git a/gcc/gcov-io.c b/gcc/gcov-io.c
index 5a21c1f..342877d 100644
--- a/gcc/gcov-io.c
+++ b/gcc/gcov-io.c
@@ -94,9 +94,15 @@ gcov_open (const char *name, int mode)
/* pass mode (ignored) for compatibility */
fd = open (name, O_RDONLY, S_IRUSR | S_IWUSR);
}
- else
+ else if (mode < 0)
+ {
+ /* Write mode - acquire a write-lock. */
+ s_flock.l_type = F_WRLCK;
+ fd = open (name, O_RDWR | O_CREAT | O_TRUNC, 0666);
+ }
+ else /* mode == 0 */
{
- /* Write mode - acquire a write-lock. */
+ /* Read-Write mode - acquire a write-lock. */
s_flock.l_type = F_WRLCK;
fd = open (name, O_RDWR | O_CREAT, 0666);
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] fix PR58602 (.gcno files not truncated at gcov_close)
2013-10-03 15:01 [PATCH] fix PR58602 (.gcno files not truncated at gcov_close) Laurent Alfonsi
@ 2014-01-16 12:13 ` Laurent Alfonsi
2014-02-03 8:55 ` Laurent Alfonsi
1 sibling, 0 replies; 4+ messages in thread
From: Laurent Alfonsi @ 2014-01-16 12:13 UTC (permalink / raw)
To: gcc-patches
Ping ?
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58602
As a reminder, that prevent running lcov on kernel side.
http://sourceforge.net/p/ltp/mailman/message/31141937/
Thanks
Laurent
On 10/03/13 17:01, Laurent Alfonsi wrote:
> Hi All,
>
> We have discovered a bug on gcno file generation registred as PR58602.
>
> When the .gcno graph file is opened for generating the coverage graph
> information, the mode used is w+ as this code is shared with updating
> tools such as libgcov.
> Thus, when GCC outputs .gcno files, it may leave garbage at the end of
> the file if the file already exists when opening it.
>
> This has been trackeddown from a kernel issue on lcov:
> http://sourceforge.net/p/ltp/mailman/message/31141937/
>
> This following patch fixes the function gcov_open() such that the
> .gcno file is opened with truncation when gcc asks for creating a new
> file (mode<0).
>
> Regression test x86-64 are ok with this patch.
> Is it ok to commit in trunk ?
>
> Thanks
> Laurent
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] fix PR58602 (.gcno files not truncated at gcov_close)
2013-10-03 15:01 [PATCH] fix PR58602 (.gcno files not truncated at gcov_close) Laurent Alfonsi
2014-01-16 12:13 ` Laurent Alfonsi
@ 2014-02-03 8:55 ` Laurent Alfonsi
2014-02-03 21:56 ` Jeff Law
1 sibling, 1 reply; 4+ messages in thread
From: Laurent Alfonsi @ 2014-02-03 8:55 UTC (permalink / raw)
To: gcc-patches, Jeff Law
Jeff, All,
As you suggested, I have extended my testing around this fix to prevent
race condition issues.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58602#c8
All my tests passed successfully. Is it ok for trunk ?
Thanks,
Laurent
On 10/03/13 17:01, Laurent Alfonsi wrote:
> Hi All,
>
> We have discovered a bug on gcno file generation registred as PR58602.
>
> When the .gcno graph file is opened for generating the coverage graph
> information, the mode used is w+ as this code is shared with updating
> tools such as libgcov.
> Thus, when GCC outputs .gcno files, it may leave garbage at the end of
> the file if the file already exists when opening it.
>
> This has been trackeddown from a kernel issue on lcov:
> http://sourceforge.net/p/ltp/mailman/message/31141937/
>
> This following patch fixes the function gcov_open() such that the
> .gcno file is opened with truncation when gcc asks for creating a new
> file (mode<0).
>
> Regression test x86-64 are ok with this patch.
> Is it ok to commit in trunk ?
>
> Thanks
> Laurent
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] fix PR58602 (.gcno files not truncated at gcov_close)
2014-02-03 8:55 ` Laurent Alfonsi
@ 2014-02-03 21:56 ` Jeff Law
0 siblings, 0 replies; 4+ messages in thread
From: Jeff Law @ 2014-02-03 21:56 UTC (permalink / raw)
To: Laurent Alfonsi, gcc-patches
On 02/03/14 01:55, Laurent Alfonsi wrote:
> Jeff, All,
>
> As you suggested, I have extended my testing around this fix to prevent
> race condition issues.
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58602#c8
>
> All my tests passed successfully. Is it ok for trunk ?
Yes, thanks for running those tests.
I've installed the patch on the trunk for you.
Thanks again,
Jeff
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-02-03 21:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-03 15:01 [PATCH] fix PR58602 (.gcno files not truncated at gcov_close) Laurent Alfonsi
2014-01-16 12:13 ` Laurent Alfonsi
2014-02-03 8:55 ` Laurent Alfonsi
2014-02-03 21:56 ` Jeff Law
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).