Have CloseGuard report by default
"Enabling" CloseGuards now controls capture of the initial stack trace, tracking, and routing of messages to the reporter. We now log a warning for leaked objects, even if CloseGuard is disabled. Since creation of a CloseGuard always allocates a finalizable object, we were paying most of the cost of checking anyway, but throwing away the benefit. The messages generated by default are not currently easily actionable, but do indicate a problem. And they can be made more actionable by passing a more informative "closer" string or by enabling CloseGuard stack capture. Always-on reporting is highly desirable since warnIfOpen() calls are commonly combined with close() calls in the same finalizer. Typically, this is 100% safe in the presence of dead reference elimination by the compiler only if there is an explicit close() call. Otherwise CloseGuard finalization may, with very unlikely scheduling, be invoked while another method on the object is still running. In the unlikely case this happens, we really want a record of it in the log. Make Tracker semantics consistent, instead of conditionally invoking it on open and unconditionally on close. Fix all-caps non-constants. Fix CloseGuardTest to reflect the new expectations. This was split off from go/aog/554024. Bug: 70906684 Test: Build and boot AOSP. cts-tradefed run singleCommand cts -m CtsLibcoreTestCases -t libcore.dalvik.system.CloseGuardTest cts-tradefed run singleCommand cts -m CtsLibcoreTestCases -t libcore.dalvik.system.CloseGuardSupportTest Change-Id: I8a1cfeac963cb5f51fdd27fdf1eb9c0beb309aa4
Loading
Please sign in to comment