Message11297

Author zyasoft
Recipients darjus, jamesmudd, stefan.richthofer, zyasoft
Date 2017-04-04.23:24:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1491348291.53.0.961901634648.issue2487@psf.upfronthosting.co.za>
In-reply-to
Content
It is in fact a bug, a classic object publication/data race to be precise. The problem is that it is possible for a Java type to be published by one thread in classToType, as held by PyType#LazyClassToTypeHolder; but for another thread to simultaneously see/lookup this type for the first time.

We used to synchronize on this map, but that caused deadlocks (the original bug here). Then we introduced polling with the bug fix (https://hg.python.org/jython/rev/f3458ef83e08), but we realized it was a hack, and linked it to this bug.

Probably the right way to fix this bug is to use a scheme actually seen in Lib/_sockets.py - use associated condition variables to mark when the publication is finished. This should be close to the current code: continue polling on the existence of __getattribute__, but wait for the specific publication. So we can start with a ConcurrentMap<Class<?>, Condition>, publish it from one thread the specific condition variable using #putIfAbsent, and cv wait for it in https://github.com/jythontools/jython/blob/master/src/org/python/core/Deriveds.java#L51
History
Date User Action Args
2017-04-04 23:24:51zyasoftsetmessageid: <1491348291.53.0.961901634648.issue2487@psf.upfronthosting.co.za>
2017-04-04 23:24:51zyasoftsetrecipients: + zyasoft, darjus, stefan.richthofer, jamesmudd
2017-04-04 23:24:51zyasoftlinkissue2487 messages
2017-04-04 23:24:50zyasoftcreate