RFR: JDK-8298445: Add LeakSanitizer support in HotSpot [v3]

Justin King jcking at openjdk.org
Thu Feb 2 15:52:01 UTC 2023


> Adds initial LSan (LeakSanitizer) support to Hotspot. This setup has been used to identify multiple leaks so far. It can run most of the test suite except those that rely on testing compressed oops or compressed class pointers. It is especially useful when combined with ASan, as LSan can use poisoning information to determine what memory to scan or not to scan, making leak detection more accurate and faster.
> 
> **Suppressing:**
> Currently the suppression list is only used to suppress JLI leaks that are known, the rest are done in code. Suppressing needs to identify the source of thet leak. Due to Hotspot's code organization, we would need to suppress `os::malloc` and friends, which would suppress everything. Suppressing in code has the added benefit of being explicit and surviving refactors if methods change.
> 
> **Caveats:**
> - `UseCompressedOops` and `UseCompressedClassPointers` are forced to false when LSan is enabled. This is necessary to ensure all pointers to memory which could possible container pointers to malloc memory are property aligned, which is an LSan requirement.
> - By default ASan enables LSan, however we explicitly disable it unless `--enable-lsan` is given. This is due to the other caveats. It is useful to be able to use ASan without LSan. Using LSan by itself is less likely to be useful and will probably not work, but its still possible currently.
> - There are a series of tests that are upset due to the above flags being forced false, as they rely on the arguments being supported. In the future ideally these tests would be skipped nicely when LSan is enabled.

Justin King has updated the pull request incrementally with two additional commits since the last revision:

 - Fix grammatical error
   
   Signed-off-by: Justin King <jcking at google.com>
 - Update based on review and remove restriction on compressed oops and class pointers
   
   Signed-off-by: Justin King <jcking at google.com>

-------------

Changes:
  - all: https://git.openjdk.org/jdk/pull/12229/files
  - new: https://git.openjdk.org/jdk/pull/12229/files/4559ef4c..93af227a

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=12229&range=02
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=12229&range=01-02

  Stats: 32 lines in 4 files changed: 16 ins; 14 del; 2 mod
  Patch: https://git.openjdk.org/jdk/pull/12229.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/12229/head:pull/12229

PR: https://git.openjdk.org/jdk/pull/12229



More information about the build-dev mailing list