I think the stack trace here is from pressing Ctrl-C to stop the process. I suspect it is hanging because COBS is not self-synchronizing, if the flush happens to discard the leading length byte, the next byte in the sequence becomes the length and things go off the rails.
There is definitely no need to flush the write buffer, so maybe try only flushing the read buffer by calling sp_flush(a.sp, SP_BUF_INPUT) in sample!and removing the call to flush on the write side.