Bug 506795

Summary: Better report which clone flags are problematic
Product: [Developer tools] valgrind Reporter: Mark Wielaard <mark>
Component: generalAssignee: Julian Seward <jseward>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Better report which clone flag are problematic

Description Mark Wielaard 2025-07-09 11:02:32 UTC
Currently when calling clone with some unsupported flags you get:

==3508066== Unsupported clone() flags: 0x100111
==3508066== 
==3508066== The only supported clone() uses are:
==3508066==  - via a threads library (LinuxThreads or NPTL)
==3508066==  - via the implementation of fork or vfork
==3508066== 
==3508066== Valgrind detected that your program requires
==3508066== the following unimplemented functionality:
==3508066==    Valgrind does not support general clone().
==3508066== This may be because the functionality is hard to implement,
==3508066== or because no reasonable program would behave this way,
==3508066== or because nobody has yet needed it.  In any case, let us know at
==3508066== www.valgrind.org and/or try to work around the problem, if you can.
==3508066== 
==3508066== Valgrind has to exit now.  Sorry.  Bye!

This doesn't immediately make clear which clone flags are problematic.
In practice it is only a problem for some combination(s) of CLONE_VM CLONE_FS CLONE_FILES and CLONE_VFORK.
It would be good if the error messages decoded the clone flags and said precisely what the problematic flag was.
Comment 1 Mark Wielaard 2025-07-09 12:33:04 UTC
Created attachment 183086 [details]
Better report which clone flag are problematic

With this patch valgrind now reports:

==3404273== Unsupported clone() flags: 0x100111
==3404273== 
==3404273== The only supported clone() uses are:
==3404273==  - via a threads library (VM, FS and FILES flags set)
==3404273==  - via the implementation of vfork (VFORK or VFORK and VM flags set)
==3404273==  - via plain fork (no VM, FS, FILES, VFORK flags set)
==3404273==  clone call had CLONE_VM flags set
==3404273== 
==3404273== Valgrind detected that your program requires
==3404273== the following unimplemented functionality:
==3404273==    Valgrind does not support general clone().
==3404273== This may be because the functionality is hard to implement,
==3404273== or because no reasonable program would behave this way,
==3404273== or because nobody has yet needed it.  In any case, let us know at
==3404273== www.valgrind.org and/or try to work around the problem, if you can.
==3404273== 
==3404273== Valgrind has to exit now.  Sorry.  Bye!
Comment 2 Mark Wielaard 2025-07-10 12:24:02 UTC
commit 1f39c9582bc6ca4470b202c6b61d477ec3abfce7
Author: Mark Wielaard <mark@klomp.org>
Date:   Wed Jul 9 13:04:51 2025 +0200

    Better report which clone flag are problematic
    
    Be explict about which combination of CLONE_VM, CLONE_FS, CLONE_FILES
    and CLONE_VFORK flags are supported and which combination isn't.
    
    https://bugs.kde.org/show_bug.cgi?id=506795