Bug 508778

Summary: syscall-wrapper waitid warns about infop=null
Product: [Developer tools] valgrind Reporter: Matthias Schwarzott <zzam>
Component: memcheckAssignee: Paul Floyd <pjfloyd>
Status: RESOLVED FIXED    
Severity: normal CC: mark, pjfloyd
Priority: NOR    
Version First Reported In: 3.25 GIT   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: syscall-wrapper waitid handles infop=null correctly
syscall-wrapper waitid handles infop=null correctly (V2)

Description Matthias Schwarzott 2025-08-26 19:28:10 UTC
Created attachment 184480 [details]
syscall-wrapper waitid handles infop=null correctly

The syscall wrapper for waitid on linux warns about infop being null.
This differs to the linux-kernel.

it is e.g. used by Qt:
https://github.com/qt/qtbase/blob/e17798560b107b7abd5f2cf472d942e8ac4213ff/src/3rdparty/forkfd/forkfd_linux.c#L128

reports can be found in multiple locations
e.g. https://lists.lyx.org/pipermail/lyx-devel/2024-June/012624.html

The attached patch is based on top of the one from https://bugs.kde.org/show_bug.cgi?id=508777
Comment 1 Mark Wielaard 2025-08-28 10:30:49 UTC
I was sceptical this was correct. But it is really a (non-portable) linux kernel extension for waitid:

       According  to  POSIX.1-2008, an application calling waitid() must ensure
       that infop points to a siginfo_t structure (i.e., that it is a  non-null
       pointer).   On  Linux,  if infop is NULL, waitid() succeeds, and returns
       the process ID of the waited-for child.  Applications should avoid rely‐
       ing on this inconsistent, nonstandard, and unnecessary feature.

Thanks for the testcase.
Comment 2 Matthias Schwarzott 2025-08-28 20:33:56 UTC
Created attachment 184537 [details]
syscall-wrapper waitid handles infop=null correctly (V2)

Updated the patch to be applied after https://bugs.kde.org/show_bug.cgi?id=508777 and https://bugs.kde.org/show_bug.cgi?id=508869
Comment 3 Paul Floyd 2025-08-29 19:32:48 UTC
commit 405fb0daaf329068a5219ef4c0e645cea872cf75 (HEAD -> master, origin/master, origin/HEAD)
Author: Matthias Schwarzott <zzam@gentoo.org>
Date:   Sat Aug 23 13:37:46 2025 +0200

    Bug 508778 - syscall-wrapper waitid warns about infop=null
    
    This is used by e.g. Qt:
    https://github.com/qt/qtbase/blob/e17798560b107b7abd5f2cf472d942e8ac4213ff/src/3rdparty/forkfd/forkfd_linux.c#L128