Ettercap/ettercap — pull request #109 by jacob-baines (2013-03-09 13:04:15+00:00)
Title: Text UI Deadlock

System: 32 bit Ubuntu 12.10
Ettercap Version: Master (64df776f700d7a8dd0738cf3beb834262e4ed72f)
Interface: Text UI
File: I don't think it matters but I was testing with https://www.wireshark.org/download/automated/captures/fuzz-2006-06-26-2594.pcap
Description:
Every now and again Ettercap falls into a deadlock state. This occurs about once every five to six runs. Valgrind puts Ettercap into a deadlock state much more reliably (~50% of the time).
The dead lock occurs after the entire file has been processed and the system is trying to shutdown. After much debugging I discovered this occurs because a thread is exiting while still holding the UI_MSG_LOCK. The lock is grabbed via ui_msg_flush which can trigger fflush in ec_text::text_msg. fflush is an implicit cancellation point, so the thread hits it and exits while still holding the lock.
Fix:
To fix this I disabled cancellation while holding the UI_MSG_LOCK. I'm not certain this is the best solution, but it has allowed me to continue with other testing.