Thread overview
[Issue 19601] Running -profile=gc when no gc is logged leaves old misleading file contents
Jan 22, 2019
John Burton
Mar 08, 2019
Tiberiu Lepadatu
Dec 17, 2022
Iain Buclaw
January 22, 2019
https://issues.dlang.org/show_bug.cgi?id=19601

--- Comment #1 from John Burton <john.burton@jbmail.com> ---
It looks like the reason is this line :- https://github.com/dlang/druntime/blob/424640864c2aa001731467e96f637bd3e704e481/src/rt/profilegc.d#L137

where it only creates the file if there is anything to write to it.
It's not as simple as just removing the test though to "fix" as we presumably
only want to do this if the user has requested the profile was made.

--
March 08, 2019
https://issues.dlang.org/show_bug.cgi?id=19601

Tiberiu Lepadatu <tiberiulepadatu14@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tiberiulepadatu14@gmail.com

--- Comment #2 from Tiberiu Lepadatu <tiberiulepadatu14@gmail.com> ---
(In reply to John Burton from comment #1)
> It looks like the reason is this line :- https://github.com/dlang/druntime/blob/ 424640864c2aa001731467e96f637bd3e704e481/src/rt/profilegc.d#L137
> 
> where it only creates the file if there is anything to write to it.
> It's not as simple as just removing the test though to "fix" as we
> presumably only want to do this if the user has requested the profile was
> made.

So we should test if the user has requested that the profile is made and then, if there is nothing to write in the file just create the file?

--
January 18, 2022
https://issues.dlang.org/show_bug.cgi?id=19601

hsteoh@quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hsteoh@quickfur.ath.cx

--
January 18, 2022
https://issues.dlang.org/show_bug.cgi?id=19601

--- Comment #3 from hsteoh@quickfur.ath.cx ---
Ran into this today. Taken together with the other -profile=gc issues, this makes -profile=gc extremely misleading. It fails to detect GC allocations via druntime APIs, *and* fails to update profilegc.txt when no allocations happened on that run, leaving stale data in the file (or fails to create the file at all, making users wonder whether -profile=gc even had any effect).

At the very least it should create an empty file per run.

--
January 18, 2022
https://issues.dlang.org/show_bug.cgi?id=19601

--- Comment #4 from hsteoh@quickfur.ath.cx ---
Relevant code: druntime/src/rt/profilegc.d

The simplest fix I can think of is for the compiler to emit a call to some druntime function that sets a flag indicating we need to create this file (so that this doesn't trigger when *not* compiling with -profile=gc), then change the if-condition in profilegc.~this to check this flag instead of counts.length.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=19601

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--
December 13
https://issues.dlang.org/show_bug.cgi?id=19601

--- Comment #5 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/19530

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--