Random high CPU usage with a minimal loop
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
pygame (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
I have found this issue while developing a small game. I have now tested with a minimal pygame loop and the problem can be reproduced (randomly).
After a few minutes running the python process CPU usage from the running pygame loop jumps from <10% to >=100%.
The gdb trace info when it happens:
(gdb) thread apply all bt
Thread 3 (Thread 0x7f32117a4700 (LWP 5405)):
#0 0x00007f3220572b9d in nanosleep () at ../sysdeps/
#1 0x00007f321f2a64b9 in SDL_Delay (ms=<optimised out>) at ./src/timer/
#2 0x00007f321f2a64f2 in RunTimer (unused=
#3 0x00007f321f264ae8 in SDL_RunThread (data=0x1ebb7c0) at ./src/thread/
#4 0x00007f321f2a4079 in RunThread (data=<optimised out>) at ./src/thread/
#5 0x00007f322056b182 in start_thread (arg=0x7f32117a
#6 0x00007f322029830d in clone () at ../sysdeps/
Thread 2 (Thread 0x7f320c988700 (LWP 5407)):
#0 0x00007f321eb367a0 in pa_mainloop_poll () from /usr/lib/
#1 0x00007f321eb36ece in pa_mainloop_iterate () from /usr/lib/
#2 0x00007f321f288a9b in PULSE_WaitAudio (this=0x1f25ed0) at ./src/audio/
#3 0x00007f321f25c8f0 in SDL_RunAudio (audiop=
#4 0x00007f321f264ae8 in SDL_RunThread (data=0x1f2c060) at ./src/thread/
#5 0x00007f321f2a4079 in RunThread (data=<optimised out>) at ./src/thread/
#6 0x00007f322056b182 in start_thread (arg=0x7f320c98
#7 0x00007f322029830d in clone () at ../sysdeps/
Thread 1 (Thread 0x7f3220981740 (LWP 5404)):
#0 0x00007f3220572b9d in nanosleep () at ../sysdeps/
#1 0x00007f321f2a64b9 in SDL_Delay (ms=<optimised out>) at ./src/timer/
#2 0x00007f321841d9e7 in ?? () from /usr/lib/
#3 0x000000000052c6d5 in PyEval_EvalFrameEx ()
#4 0x000000000052cf32 in PyEval_EvalFrameEx ()
#5 0x000000000052cf32 in PyEval_EvalFrameEx ()
#6 0x000000000052cf32 in PyEval_EvalFrameEx ()
#7 0x000000000055c594 in PyEval_EvalCodeEx ()
#8 0x00000000005b7392 in PyEval_EvalCode ()
#9 0x0000000000469663 in ?? ()
#10 0x00000000004699e3 in PyRun_FileExFlags ()
#11 0x0000000000469f1c in PyRun_SimpleFil
#12 0x000000000046ab81 in Py_Main ()
#13 0x00007f32201beec5 in __libc_start_main (main=0x46ac3f <main>, argc=2, argv=0x7fff35fa
#14 0x000000000057497e in _start ()
When this happens, attempting to quit the process will hang it:
(gdb) thread apply all bt
Thread 3 (Thread 0x7f32117a4700 (LWP 5405)):
#0 0x00007f3220572b9d in nanosleep () at ../sysdeps/
#1 0x00007f321f2a64b9 in SDL_Delay (ms=<optimised out>) at ./src/timer/
#2 0x00007f321f2a64f2 in RunTimer (unused=
#3 0x00007f321f264ae8 in SDL_RunThread (data=0x1ebb7c0) at ./src/thread/
#4 0x00007f321f2a4079 in RunThread (data=<optimised out>) at ./src/thread/
#5 0x00007f322056b182 in start_thread (arg=0x7f32117a
#6 0x00007f322029830d in clone () at ../sysdeps/
Thread 2 (Thread 0x7f320c988700 (LWP 5407)):
#0 0x00007f321eb245ec in pa_context_
#1 0x00007f321f288ac4 in PULSE_WaitAudio (this=0x1f25ed0) at ./src/audio/
#2 0x00007f321f25c8f0 in SDL_RunAudio (audiop=
#3 0x00007f321f264ae8 in SDL_RunThread (data=0x1f2c060) at ./src/thread/
#4 0x00007f321f2a4079 in RunThread (data=<optimised out>) at ./src/thread/
#5 0x00007f322056b182 in start_thread (arg=0x7f320c98
#6 0x00007f322029830d in clone () at ../sysdeps/
Thread 1 (Thread 0x7f3220981740 (LWP 5404)):
#0 0x00007f322056c66b in pthread_join (threadid=
#1 0x00007f321f2a419b in SDL_SYS_WaitThread (thread=
#2 0x00007f321f264cd6 in SDL_WaitThread (thread=0x1f33230, status=
#3 0x00007f321f25d07a in SDL_AudioQuit () at ./src/audio/
#4 0x00007f321f25bf95 in SDL_QuitSubSystem (flags=16) at ./src/SDL.c:190
#5 0x00007f3216fbcd55 in Mix_CloseAudio () at mixer.c:1145
#6 0x00007f3215570706 in ?? () from /usr/lib/
#7 0x00007f321f4e9f6a in ?? () from /usr/lib/
#8 0x00007f321f4e9fa9 in ?? () from /usr/lib/
#9 0x000000000052f936 in PyEval_EvalFrameEx ()
#10 0x000000000056d0aa in ?? ()
#11 0x00000000004da29f in PyEval_
#12 0x000000000042fa19 in Py_Finalize ()
#13 0x000000000046ac10 in Py_Main ()
#14 0x00007f32201beec5 in __libc_start_main (main=0x46ac3f <main>, argc=2, argv=0x7fff35fa
#15 0x000000000057497e in _start ()
The hang-on-quit behavior seems to be the issue described at:
https:/
Description: Ubuntu 14.04 LTS
Adding the script used to reproduce the problem.