julius icon indicating copy to clipboard operation
julius copied to clipboard

Suggestions to avoid communication deadlocks

Open ryancaicse opened this issue 3 years ago • 1 comments

Hi, developers, it seems there are multiple sites using wait conditions in the wrong ways, which could lead to deadlocks.

Normally, the wait is checked via a condition to ensure the notify that hasn't been executed. For example, https://github.com/julius-speech/julius/blob/4182bf024872cf4ff4388475359d74695dd5ee16/msvc/Library_PortAudio/src/src/hostapi/jack/pa_jack.c#L1025-L1032

https://github.com/julius-speech/julius/blob/4182bf024872cf4ff4388475359d74695dd5ee16/msvc/Library_PortAudio/src/src/hostapi/jack/pa_jack.c#L670-L673

However, there are multiple sites, which miss checking such conditions. The deadlock could happen when the signal reaches in advance so that the waiting site could lead to a wait forever with no signal notifying anymore.

https://github.com/julius-speech/julius/blob/4182bf024872cf4ff4388475359d74695dd5ee16/msvc/Library_PortAudio/src/src/hostapi/jack/pa_jack.c#L1625-L1641

https://github.com/julius-speech/julius/blob/4182bf024872cf4ff4388475359d74695dd5ee16/msvc/Library_PortAudio/src/src/hostapi/jack/pa_jack.c#L1660-L1668

https://github.com/julius-speech/julius/blob/4182bf024872cf4ff4388475359d74695dd5ee16/libsent/src/adin/pa/hostapi/jack/pa_jack.c#L1621-L1637

https://github.com/julius-speech/julius/blob/4182bf024872cf4ff4388475359d74695dd5ee16/libsent/src/adin/pa/hostapi/jack/pa_jack.c#L1656-L1664

ryancaicse avatar Nov 19 '21 13:11 ryancaicse

Or, I just missed some things important? Looking forward to furthering discussion.

ryancaicse avatar Nov 19 '21 13:11 ryancaicse