retitle 879045 xracer: hangs when program exit thanks Hi,
I've fix the bug. Please see the attached patch. The program hangs in the busy loop in xracer-0.96.9/src/sound.c:135 while (pid >= 0) #ifdef HAVE_SCHED_YIELD sched_yield () #endif ; pid does changed to -1 by receiving a signal. But the optimizer optimized that variable and makes the loop always true. Thus the patch is to volatile the pid variable. Please see testO3.c as an example in this mail. Compile it with -O0 and -O3 will show the different behaviour. That is the reason of this bug. Yours, Paul -- PaulLiu (劉穎駿) E-mail: Ying-Chun Liu (PaulLiu) <paul...@debian.org>
Description: Fix hanging when program exits. The program hangs at exit(). It is because the sound process doesn't exit its busy loop. Basically it is because the variable which controls the busy loop is optimized by the compiler. Thus we need to volatile that variable. Bug-Debian: http://bugs.debian.org/879045 Author: Ying-Chun Liu (PaulLiu) <paul...@debian.org> Last-Update: 2017-10-19 Index: xracer-0.96.9.1/xracer-0.96.9/src/sound.c =================================================================== --- xracer-0.96.9.1.orig/xracer-0.96.9/src/sound.c +++ xracer-0.96.9.1/xracer-0.96.9/src/sound.c @@ -72,7 +72,7 @@ /* If there is a sound process running, this contains the process * ID, else it contains -1. */ -static int pid = -1; +static volatile int pid = -1; /* Address of shared memory. */ static struct xrSoundSharedMemory *shm = 0;
#include <stdio.h> #include <unistd.h> #include <signal.h> static int flag = -1; void loop() { printf ("Loop started\n"); while (flag == -1) ; printf ("Loop exited\n"); } void handler(int x) { printf ("Signal received\n"); flag = 0; } int main() { printf ("Program PID = %d\n", getpid()); printf ("Please send a SIGUSR1 to stop this program.\n"); signal(SIGUSR1, handler); loop(); return 0; }
signature.asc
Description: OpenPGP digital signature