Bug 498317 - FdBadUse is not a valid CoreError type in a suppression even though it's generated by --gen-suppressions=yes
Summary: FdBadUse is not a valid CoreError type in a suppression even though it's gene...
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: 3.24 GIT
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: Paul Floyd
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-01-06 14:00 UTC by Frantisek Sumsal
Modified: 2025-01-12 22:50 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Frantisek Sumsal 2025-01-06 14:00:40 UTC
SUMMARY
I noticed a strange inconsistency while trying to temporarily work around a local issue. The application in question throws a "Warning: invalid file descriptor X in syscall fcntl()" warning when run under Valgrind which I wanted to temporarily suppress, but the suppression generated with the help of --gen-suppressions=yes doesn't work.

STEPS TO REPRODUCE
# cat >foo.c <<EOF
#include <fcntl.h>

int main(void) {
        fcntl(-1, F_GETFD);
        return 0;
}
# gcc -o foo foo.c
# valgrind --track-fds=yes --gen-suppressions=yes ./foo
# cat >foo.supp <<EOF
{
   foo
   CoreError:FdBadUse
   fun:__fcntl64_nocancel_adjusted
   fun:fcntl
   fun:main
}
EOF
# valgrind --track-fds=yes --suppressions=foo.supp ./foo

OBSERVED RESULT
# valgrind --track-fds=yes --gen-suppressions=yes ./foo
...
==2083== Memcheck, a memory error detector
==2083== Copyright (C) 2002-2024, and GNU GPL'd, by Julian Seward et al.
==2083== Using Valgrind-3.24.0 and LibVEX; rerun with -h for copyright info
==2083== Command: ./foo
==2083== 
==2083== File descriptor -1 Invalid file descriptor
==2083==    at 0x494DF07: __fcntl64_nocancel_adjusted (fcntl_nocancel.c:63)
==2083==    by 0x4948FF4: fcntl (fcntl64.c:51)
==2083==    by 0x40113D: main (in /root/foo)
==2083== 
==2083== ---- Print suppression ? --- [Return/N/n/Y/y/C/c] ---- y
{
   <insert_a_suppression_name_here>
   CoreError:FdBadUse
   fun:__fcntl64_nocancel_adjusted
   fun:fcntl
   fun:main
}
==2083== 
==2083== FILE DESCRIPTORS: 3 open (3 std) at exit.
==2083== 
==2083== HEAP SUMMARY:
==2083==     in use at exit: 0 bytes in 0 blocks
==2083==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==2083== 
==2083== All heap blocks were freed -- no leaks are possible
==2083== 
==2083== For lists of detected and suppressed errors, rerun with: -s
==2083== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

# valgrind --track-fds=yes --suppressions=foo.supp ./foo
==2086== Memcheck, a memory error detector
==2086== Copyright (C) 2002-2024, and GNU GPL'd, by Julian Seward et al.
==2086== Using Valgrind-3.24.0 and LibVEX; rerun with -h for copyright info
==2086== Command: ./foo
==2086== 
==2086== FATAL: in suppressions file "foo.supp" near line 3:
==2086==    unknown core suppression type
==2086== exiting now.

EXPECTED RESULT
The suppression rule should be accepted by Valgrind.

SOFTWARE/OS VERSIONS
Fedora Rawhide with valgrind-3.24.0-2.fc42.x86_64
Comment 1 Paul Floyd 2025-01-06 20:40:50 UTC
Reproduced. I'll try to push a fix tomorrow (2025-01-07).
Comment 2 Paul Floyd 2025-01-07 08:01:55 UTC
I'll add a Linux version of the test tonight - the suppression file needs to be different.

commit 47bdc4a6f3de8e2071561d349fdd5f830388c489 (HEAD -> master, origin/users/paulf/try-bug498317, origin/master, origin/HEAD, bug498317)
Author: Paul Floyd <pjfloyd@wanadoo.fr>
Date:   Tue Jan 7 08:05:20 2025 +0100

    Bug 498317 - FdBadUse is not a valid CoreError type in a suppression even though it's generated by --gen-suppressions=yes
Comment 3 Mark Wielaard 2025-01-12 22:50:09 UTC
Also added to the VALGRIND_3_24_BRANCH

commit febe1ccef09f70777b086f938c03f3e71989a7c8
Author: Paul Floyd <pjfloyd@wanadoo.fr>
Date:   Tue Jan 7 08:05:20 2025 +0100

    Bug 498317 - FdBadUse is not a valid CoreError type in a suppression even though it's generated by --gen-suppressions=yes
    
    https://bugs.kde.org/show_bug.cgi?id=498317
    
    (cherry picked from commit 47bdc4a6f3de8e2071561d349fdd5f830388c489)