Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken logger initialization in 2.24.1 #3143

Open
kelunik opened this issue Oct 30, 2024 · 2 comments
Open

Broken logger initialization in 2.24.1 #3143

kelunik opened this issue Oct 30, 2024 · 2 comments
Labels
waiting-for-user More information is needed from the user

Comments

@kelunik
Copy link

kelunik commented Oct 30, 2024

Description

LoggerContext / LoggerRegistry don't play well together in using weak references, which can result in a null logger if the GC kicks in at a bad timing.

Configuration

Version: 2.24.1

Operating system: Linux / macOS

JDK: 21.0.4

Logs

java.lang.NullPointerException

Cannot invoke "org.apache.logging.log4j.spi.ExtendedLogger.logIfEnabled(String, org.apache.logging.log4j.Level, org.apache.logging.log4j.Marker, String)" because "this.logger" is null

at org.apache.logging.slf4j.Log4jLogger.warn(Log4jLogger.java:233)
at <internal company code>

Reproduction

Optimizing transformations of a program can be designed that reduce the number of objects that are reachable to be less than those which would naively be considered reachable. For example, a Java compiler or code generator may choose to set a variable or parameter that will no longer be used to null to cause the storage for such an object to be potentially reclaimable sooner.

https://docs.oracle.com/javase/specs/jls/se21/html/jls-12.html#jls-12.6.1

Fix

#2936 should fix this, but is currently unreleased.

Reference.reachabilityFence would also fix this, but is JDK 9+ only.

See also: https://shipilev.net/jvm/anatomy-quarks/8-local-var-reachability/

@kelunik
Copy link
Author

kelunik commented Oct 30, 2024

@ppkarwasz
Copy link
Contributor

@kelunik,

Thank you for the report.

The LoggerRegistry implementation was changed in 2.25.0-SNAPSHOT. Can you check if that fixes your issue?
Our snapshots are located in the https://repository.apache.org/snapshots/ Maven repository (see also our download page).

@ppkarwasz ppkarwasz added waiting-for-user More information is needed from the user and removed waiting-for-maintainer labels Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting-for-user More information is needed from the user
Projects
None yet
Development

No branches or pull requests

2 participants