Re: bug in futex.2, FUTEX_CMP_REQUEUE
From: Carlos O'Donell <hidden>
Date: 2025-05-27 12:54:36
On 5/27/25 8:51 AM, Alejandro Colomar wrote:
Hi Carlos, On Tue, May 27, 2025 at 08:37:16AM -0400, Carlos O'Donell wrote:quoted
Since the parenthetical is not clear about val vs. val2, it can be read in two different ways.The entire paragraph is Typical values to specify for val are 0 or 1. (Specifying INT_MAX is not useful, because it would make the FU‐ TEX_CMP_REQUEUE operation equivalent to FUTEX_WAKE.) The limit value specified via val2 is typically either 1 or INT_MAX. (Specifying the argument as 0 is not useful, be‐ cause it would make the FUTEX_CMP_REQUEUE operation equiva‐ lent to FUTEX_WAIT.) There's a parenthetical after talking about val, and another one after talking about val2. I think the latter parenthetical unambiguously refers to val2. I would have written them as part of each sentence, to make it even less ambiguous, though.
Just adding "val" and "val2" to the parenthenticals removes any confusion if you are quickly skimming the text? There is still the degenerate case of val==0 and val2==INT_MAX which is equivalent to FUTEX_WAKE followed by an atomic FUTEX_WAIT since all waiters move queues and no waiter is officially woken and allowed to return to userspace? -- Cheers, Carlos.