Integrated: 8340923: The class LogSelection copies uninitialized memory

Johan Sjölen jsjolen at openjdk.org
Thu Sep 26 08:50:46 UTC 2024


On Wed, 25 Sep 2024 13:43:47 GMT, Johan Sjölen <jsjolen at openjdk.org> wrote:

> 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`.

This pull request has now been integrated.

Changeset: 10da2c21
Author:    Johan Sjölen <jsjolen at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/10da2c21a19affe93a3f5d67a70db5d9cd37181c
Stats:     2 lines in 1 file changed: 0 ins; 0 del; 2 mod

8340923: The class LogSelection copies uninitialized memory

Reviewed-by: mbaesken, jwaters, stefank

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

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


More information about the hotspot-runtime-dev mailing list