Closed Bug 1447906 Opened 7 years ago Closed 4 years ago

Garbage collection should not erase compartment's LCOV data

Categories

(Core :: JavaScript Engine, defect, P2)

59 Branch
defect

Tracking

()

RESOLVED FIXED

People

(Reporter: ptomato, Unassigned)

Details

Attachments

(1 file)

Attached file bug.cpp
See attached script to reproduce the problem. I've tried it on the 52 and 59 branches. Performing a GC after evaluating a script seems to erase the collected coverage data. The LCOV string returned from js::GetCodeCoverageSummary() is empty after a GC. Comment out the JS_GC(cx); line to get the normal behaviour.
The coverage data is only retained for as long as the script is live. The GC here will collect the script and the coverage data with it. I'm not sure if that is a problem or not. Marco, is that how this is supposed to work?
Flags: needinfo?(mcastelluccio)
> Performing a GC after evaluating a script seems to erase the collected > coverage data. The LCOV string returned from js::GetCodeCoverageSummary() is > empty after a GC. This problem should not exists with JS_CODE_COVERAGE_OUTPUT_DIR environment variable. If you enable the code coverage with the Debugger, then you should also rely on the Debugger API to extract the code coverage information. While the problem might still exists, the Debugger should still hold on the the created JSScript and prevent them from being trashed.
> If you enable the code coverage with the Debugger, then you should also rely on the Debugger API to extract the code coverage information. There's no way to get LCOV output specifically using the Debugger API, though, is there? I'd have to generate it myself (which is what I did before switching to js::GetCodeCoverageSummary(), but I'd rather not go back to that.) Maybe a good solution is to create a script and root it instead of using the JS::Evaluate() overload that takes a string directly?
(In reply to Philip Chimento [:ptomato] from comment #3) > > If you enable the code coverage with the Debugger, then you should also rely on the Debugger API to extract the code coverage information. > > There's no way to get LCOV output specifically using the Debugger API, > though, is there? I'd have to generate it myself (which is what I did before > switching to js::GetCodeCoverageSummary(), but I'd rather not go back to > that.) Indeed, the Debugger API was meant to be used by the Debugger, not as a way to produce LCov content :/ > Maybe a good solution is to create a script and root it instead of using the > JS::Evaluate() overload that takes a string directly? This should work, as the top-level script would be kept alive.
This has an interesting interaction with bug 1404784, which makes it difficult to solve. If I compile a script, keep it rooted somewhere, and execute it, then I get duplicate LCOV entries for every script due to the other bug. If I don't keep the script rooted, then I get correct LCOV entries unless it is garbage collected, then I get nothing.
Flags: needinfo?(mcastelluccio)
Priority: -- → P2

This bug seems to have been fixed sometime along the way. I can no longer reproduce it in ESR 91.

Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: