[New-bugs-announce] [issue21912] Deferred logging may use outdated references

Jonas Diemer report at bugs.python.org
Thu Jul 3 14:44:01 CEST 2014

New submission from Jonas Diemer:

I was having trouble with the logging module under Jython: I was getting seemingly sporadic wierd null pointer exceptions in the logging code. 

The problem seemed to be related to references that were passed to the logger, e.g.

logger.debug("My object: %s", myObject)

It seems that logging defers the actual string formatting (maybe only when logging to files). By the time the string is formatted, the reference to the object may no longer be valid. In my case, myObject was a reference to a Java-class that had been invalidated.

Initially, I thought this was only a Java issue. But it seems like this could be an issue with pure Python scripts as well. E.g., what happens if the object behind myObject is changed after the call to debug(), but before the actual log message is formatted?

components: Library (Lib)
messages: 222171
nosy: Jonas.Diemer
priority: normal
severity: normal
status: open
title: Deferred logging may use outdated references
type: behavior
versions: Python 2.7

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list