[issue27468] Erroneous memory behaviour for objects created in another thread

2016-07-08 Thread Adria Garriga

Changes by Adria Garriga :


Removed 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



[issue27468] Erroneous memory behaviour for objects created in another thread

2016-07-08 Thread Adria Garriga

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



[issue27468] Erroneous memory behaviour for objects created in another thread

2016-07-08 Thread Adria Garriga

Adria Garriga added the comment:

Yes, that seems to be it. Storing info in the Thread object is just for the 
sake of keeping the example short, but the error is the same you pointed out.

Thank you very much and I hope I didn't waste too much of your time!

--
status: open -> closed

___
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