Message11297
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 |
|
Date |
User |
Action |
Args |
2017-04-04 23:24:51 | zyasoft | set | messageid: <1491348291.53.0.961901634648.issue2487@psf.upfronthosting.co.za> |
2017-04-04 23:24:51 | zyasoft | set | recipients:
+ zyasoft, darjus, stefan.richthofer, jamesmudd |
2017-04-04 23:24:51 | zyasoft | link | issue2487 messages |
2017-04-04 23:24:50 | zyasoft | create | |
|