Closed GoogleCodeExporter closed 9 years ago
I'm getting a crash in gl/base.py that I'm guessing is a race condition caused
by the garbage collector. VertexBufferObject.__del__ calls
Context.delete_buffer, which puts an id in a list. Context.set_current
attempts to free some resources and uses:
buffers = (gl.GLuint * len(buffers))(*buffers)
What I'm guessing is happening is that the garbage collector is running between
the call to len(buffers) and the *buffers, resulting in different lengths of
the list. I instrumented the method with the attached patch and got the
following:
doomed buffers race condition!
105 buffers now: [3L, 2L, 1L, 9L, 8L, 7L, 15L, 14L, 13L, 21L, 20L, 19L, 33L,
32L, 31L, 42L, 41L, 40L, 48L, 47L, 46L, 57L, 56L, 55L, 6L, 5L, 4L, 12L, 11L,
10L, 18L, 17L, 16L, 30L, 29L, 28L, 36L, 35L, 34L, 45L, 44L, 43L, 54L, 53L, 52L,
60L, 59L, 58L, 63L, 62L, 61L, 69L, 68L, 67L, 75L, 74L, 73L, 84L, 83L, 82L, 90L,
89L, 88L, 96L, 95L, 94L, 102L, 101L, 100L, 108L, 107L, 106L, 114L, 113L, 112L,
120L, 119L, 118L, 72L, 71L, 70L, 78L, 77L, 76L, 87L, 86L, 85L, 93L, 92L, 91L,
99L, 98L, 97L, 105L, 104L, 103L, 111L, 110L, 109L, 117L, 116L, 115L, 123L,
122L, 121L]
78 buffers before: [3L, 2L, 1L, 9L, 8L, 7L, 15L, 14L, 13L, 21L, 20L, 19L, 33L,
32L, 31L, 42L, 41L, 40L, 48L, 47L, 46L, 57L, 56L, 55L, 6L, 5L, 4L, 12L, 11L,
10L, 18L, 17L, 16L, 30L, 29L, 28L, 36L, 35L, 34L, 45L, 44L, 43L, 54L, 53L, 52L,
60L, 59L, 58L, 63L, 62L, 61L, 69L, 68L, 67L, 75L, 74L, 73L, 84L, 83L, 82L, 90L,
89L, 88L, 96L, 95L, 94L, 102L, 101L, 100L, 108L, 107L, 106L, 114L, 113L, 112L,
120L, 119L, 118L]
Original comment by rob.mcmu...@gmail.com
on 29 Mar 2012 at 1:49
Attachments:
I imagine the same problem affects the _doomed_textures list as well. The
enclosed patch seems to work for me, given that list slicing is an atomic
operation
(http://effbot.org/pyfaq/what-kinds-of-global-value-mutation-are-thread-safe.htm
) and therefore the garbage collector running during the removal of the deleted
buffers won't lose any data.
Original comment by rob.mcmu...@gmail.com
on 29 Mar 2012 at 1:55
Attachments:
Thanks for your patch, applied as rev. 909138f671fb
Original comment by andreas....@gmail.com
on 14 Apr 2012 at 11:48
The problem still persists in version 1.1.4. The affected sources however are
not in base.py but in pyglet/gl/__init__.py. Applying exactly the same patch to
this file fixes the problem.
Original comment by mherrman...@gmail.com
on 10 Jan 2014 at 6:40
Original issue reported on code.google.com by
rob.mcmu...@gmail.com
on 29 Mar 2012 at 1:46