Re: [LTP] semctl01: tolerate SEM_STAT races under parallel LTP runs

[email protected] Tue, 21 Jul 2026 02:38:10 +0000
Newsgroups it.linux.lists.ltp
Message-ID <[email protected]>
Hi Stephen,

On Mon Jul 20 19:56:47 2026, Stephen Bertram wrote:
> semctl01: tolerate SEM_STAT races under parallel LTP runs

> +static int do_sem_stat(union semun arg)
> +{
> +	int idx, rval;
> +	unsigned int retries = 5;
> +
> +	do {
> +		int info_id = 0;
> +
> +		idx = SAFE_SEMCTL(info_id, 0, IPC_INFO, (union semun)&ipc_buf);
> +		rval = semctl(idx, 0, SEM_STAT, arg);
> +		if (rval >= 0)
> +			return rval;
> +		if (errno != EIDRM && errno != EINVAL)
> +			tst_brk(TBROK | TERRNO, "semctl(SEM_STAT)");
> +	} while (--retries);

semctl() is the subject syscall of this test. The rule for subject
syscalls is: skip SAFE_* (done correctly), but wrap the call in TEST()
or a TST_EXP_* macro -- never call it bare. Something like:

    TEST(semctl(idx, 0, SEM_STAT, arg));
    if (TST_RET >= 0)
        return TST_RET;
    if (TST_ERR != EIDRM && TST_ERR != EINVAL)
        tst_brk(TBROK | TERRNO, "semctl(SEM_STAT)");

Verdict - Needs revision

---
Note:

The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp