RFR: 8340923: The class LogSelection copies uninitialized memory [v3]

Johan Sjölen jsjolen at openjdk.org
Wed Sep 25 16:55:10 UTC 2024


> The class LogSelection's custom constructor does not initialize the whole _tags array but is lacking a custom copy constructor and assignment operator. This means that any copy will copy uninitialized memory, which is undefined behavior. UBSAN has seen this happen, as reported by Matthias Baesken.
> 
> For some surrounding context: Unified Logging uses a statically defined array size (`LogTag::MaxTag`) but uses the `LogTag::__NO_TAG` to signify the end of the array. Think "NULL-terminated string but log tags".
> 
> We fill the whole array to avoid this issue. Specifically, we filll the remainder of the array with `LogTag::__NO_TAG`.

Johan Sjölen has updated the pull request incrementally with one additional commit since the last revision:

  Simplify

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/21185/files
  - new: https://git.openjdk.org/jdk/pull/21185/files/321231f4..a39a4626

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

  Stats: 6 lines in 1 file changed: 0 ins; 4 del; 2 mod
  Patch: https://git.openjdk.org/jdk/pull/21185.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/21185/head:pull/21185

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


More information about the hotspot-runtime-dev mailing list