Good point! Wouldn't it be a clearer change to change if ((write_index + *psize) >= read_index)
to if (*psize >= (read_index - write_index))
though? Since at that point read_index > write_index, no over/underflows will occur.
Yeah, that makes sense and is much cleaner. Updated.
Login to write a write a comment.
The bug happens because
psize
is set tonumeric_limits<size_type>::max()
so the code path in get_write_reserve has numeric overflow and won't updatepsize
.The following sequence reproduces the issue: