iproto: fix a crashing bug on ec2.large instance
When entire contents of the output buffer is flushed, we must reset write start and end positions. If the buffer can be recyced, they both are reset to point to the beginning of the buffer, otherwise write start is advanced to match write end. The old code would always execute *begin = *end assignment, regardless of whether it's case 1) (full reset) or 2) (advancing write start). gcc 4.8 could reorder this assignment, and put it in front of conditional iobuf_reset(). In that case, write start could point beyond write end, since iobuf_reset() resets write end to zero. A funny bug which would hit only under heavy load, only if there are -O2 optimizations, and no debug prints.
Loading
Please register or sign in to comment