PyOpenAL icon indicating copy to clipboard operation
PyOpenAL copied to clipboard

Python 3.8: List does not iterate over all members when mutated during loop

Open andrewbest-tri opened this issue 2 years ago • 1 comments

https://github.com/Zuzu-Typ/PyOpenAL/blob/b49212cafe21e27c540540e99aea8a5d859b95aa/openal/init.py#L815

The above line leaves dangling references in python 3.8 which causes OpenAL to crash.

To reproduce:

for iteration in range(2):
    if not openal.oalGetInit():
            openal.oalInit()
    source1 = openal.oalOpen(path_to_a_sound)
    source2 = openal.oalOpen(path_to_a_sound) 
    source1.play()
    source2.play()
    openal.oalQuit()
    print(len(openal._buffers))  # This will have length 1.

The above code will crash on iteration 2 with INVALID_OPERATION.

andrewbest-tri avatar Mar 29 '22 19:03 andrewbest-tri

workaround for now:

for source in openal._sources:
    source.destroy()
for buffer in openal._buffers:
            buffer.destroy()

before calling quit.

andrewbest-tri avatar Mar 29 '22 20:03 andrewbest-tri