Is there any way of debugging this?
Ideally I'd like some way of printing the current stacks of all my
goroutines to see what the program is doing.
kill -ABRT your-prog-pid
will kill the program but as a side effect give you all the
current stacks of your goroutines.
Russ
russ
I think I figured out the cause of the hang:
I think I have two goroutines that are deadlocked trying to send each
other messages. The channels they are using are not buffered, and
there's a situation where each side is trying to send more than one
message into their respective send channel before reading any more
messages from their receive channel.
And indeed it looks like a send/send deadlock, where my main goroutine
is sending to another goroutine that is sending back to the main
goroutine on a channel with multiple writers.
The fix in this case is to enlarge one of my channels to hold multiple
messages.
My design has a single channel that's used by N client goroutines to
send messages to the main goroutine. I guess in order to avoid
deadlocks, I need to size it to hold N * M messages, where N is the
number of clients, M is the total number of messages that a given
client might need to send at once.
Luckily N * M is bounded for my application. (To about 50)
D'Oh!
On Jan 25, 6:28 am, Jack Palevich <jack.palev...@gmail.com> wrote: