[Bug 57731] Re: Futex hang when exiting using the window close button

Rogers Veber labelsarl at free.fr
Fri Mar 2 09:49:17 UTC 2007


Hi,
I am experiencing same trouble on a self made program.
I made a tool used to unfreeze process (and watch periodically) : survfutex
I send you the source in attachment. You can try it on the frozen process to check that it works (normaly it would). It is using the ptrace(2) syscall to attach the frozen proc (use -p pid as argument), to get the syscall number (check it is sys_futex), to get the address of WAIT, and poke a 0 at it. If you add -s millisec option survfutex will check periodically.
That is for the reparing ... Now, there are informations I collected that could help preventing.
On my program (the one that sometime freezes), the trouble occurs within a signal handler of SIGCLD (death of child process). In this handler, I call a wait(2), log the death using fprintf(3) and then free(3) a struct (element of a list of running son).
I have two technics to prevent the freeze :
First one:
  - I block the SIGCLD (using sigprocmask(2)),
  - periodically check if there is a pending SIGCLD,
  - if so  manage the death ouside a signal handler and remove the pending condition.
Second one:
 - the signal handler call the wait(2), then move the struct of son from a list of alive sons
  to a list of dead sons.
 - Outside of the signal handler, manage the death of the son (fprintf and free).
The survfutex can be compiled with cc survfutex.c -o survfutex
One must use the -u option to unblock a frozen process.
Please, let me know if it work with your trouble and feel free to communicate the survfutex.c and informations to anyone that encounter the same trouble.

Cheers
-Rogers


** Attachment added: "Unfreezer of sys_futex(2) blocked programs."
   http://librarian.launchpad.net/6596971/survfutex.c

-- 
Futex hang when exiting using the window close button
https://launchpad.net/bugs/57731




More information about the desktop-bugs mailing list