Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-98564

valgrind always fails when run with --track-fds=yes from ctest

Linking RHIVOS CVEs to...Migration: Automation ...SWIFT: POC ConversionSync from "Extern...XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Normal Normal
    • rhel-9.7
    • rhel-9.6
    • valgrind
    • None
    • Yes
    • Moderate
    • rhel-pt-perf-tools
    • 2
    • False
    • False
    • Hide

      None

      Show
      None
    • Yes
    • None
    • None
    • None
    • Unspecified Release Note Type - Unknown
    • Unspecified
    • Unspecified
    • Unspecified
    • None

      On RHEL 9.6, it's not possible to run valgrind with "--track-fds=yes" as part of a ctest test. That's because valgrind 3.24.0 reports the logfile file descriptor inherited from ctest as a leaked file descriptor, which is now treated as an error. This was not the case with RHEL 9.4's valgrind 3.22.0.

      Minimal repro:

      dnf install -y cmake valgrind
      cat > CTestTestfile.cmake <<EOF
      add_test(foo /usr/bin/valgrind --error-exitcode=1 --track-fds=yes /bin/true)
      EOF
      ctest --output-on-failure
      

      Observed output (with valgrind 3.24.0 in RHEL 9.6):

      Test project /
          Start 1: foo
      echo1/1 Test #1: foo ..............................***Failed    0.54 sec
      ==82== Memcheck, a memory error detector
      ==82== Copyright (C) 2002-2024, and GNU GPL'd, by Julian Seward et al.
      ==82== Using Valgrind-3.24.0 and LibVEX; rerun with -h for copyright info
      ==82== Command: /bin/true
      ==82== 
      ==82== 
      ==82== FILE DESCRIPTORS: 4 open (3 std) at exit.
      ==82== Open file descriptor 3: /Testing/Temporary/LastTest.log.tmp
      ==82==    <inherited from parent>
      ==82== 
      ==82== 
      ==82== HEAP SUMMARY:
      ==82==     in use at exit: 0 bytes in 0 blocks
      ==82==   total heap usage: 3 allocs, 3 frees, 1,616 bytes allocated
      ==82== 
      ==82== All heap blocks were freed -- no leaks are possible
      ==82== 
      ==82== For lists of detected and suppressed errors, rerun with: -s
      ==82== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
      
      
      0% tests passed, 1 tests failed out of 1
      
      Total Test time (real) =   0.54 sec
      
      The following tests FAILED:
                1 - foo (Failed)
      Errors while running CTest
      

      Expected output (as with valgrind 3.22.0 in RHEL 9.4):

      Test project /
          Start 1: foo
      1/1 Test #1: foo ..............................   Passed    0.25 sec
      
      100% tests passed, 0 tests failed out of 1
      
      Total Test time (real) =   0.25 sec
      

      The valgrind 3.24.0 release notes explain that fd leaks are now treated as errors:

      * Bad file descriptor usage now generates a real error with
        --track-fds=yes that is suppressible and shows up in the xml output
        with full execution backtrace. The warnings shown without using the
        option are deprecated and will be removed in a future valgrind
        version.
      

      It suggests that the errors are suppressible but that's not true for fds inherited from the parent, as their origin is not tracked.

      It looks like this is fixed in valgrind 3.25.0, for which the release notes say

      * The --track-fds=yes and --track-fds=all options now treat all
        inherited file descriptors the same as 0, 1, 2 (stdin/out/err).
      

      See https://sourceware.org/git/?p=valgrind.git;a=commit;h=9f0e4107c140b47ea2a9c097afcac73a8454e17f for that fix.

      I'm not aware of any workarounds, short of disabling fd tracking.

              rhn-engineering-mjw Mark Wielaard
              ntnx-jond Jonathan Davies
              Nutanix Confidential Group
              Mark Wielaard Mark Wielaard
              Martin Cermak Martin Cermak
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved: