New submission from Adria Garriga:
I create several objects in the main thread, and then spawn several threads
that "take ownership" of one object each. Within that thread, the objects'
attributes' values are not consistent. The bug only happens sometimes.
from threading import Thread
import pdb
n_threads = 8
def f(self):
self.obj[0] = 0
t = 0
while True:
if t != self.obj[0]:
pdb.set_trace() # should not happen
t += 1
self.obj[0] += 1
for _ in range(n_threads):
t = Thread(target=lambda: f(t))
t.obj = [0]
t.start()
Tested in Python 2.7.11 under Ubuntu 16.04 LTS and OS X. The bug does not
happen in Python 3.5 or Python 3.6 .
Attached is a very similar program that exhibits the same issue, but which may
be clearer and can sometimes be killed with Ctrl-C.
--
components: Library (Lib)
files: test.py
messages: 269988
nosy: Adria Garriga
priority: normal
severity: normal
status: open
title: Erroneous memory behaviour for objects created in another thread
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file43663/test.py
___
Python tracker
<http://bugs.python.org/issue27468>
___
___
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com