Hi Aaron,

On Thu, Jan 30, 2025 at 09:35:52PM -0500, Aaron Merey wrote:
> valgrind --track-fds=yes might incorrectly report an error due to the use
> of inherited file descriptors in check_native_core.

Note that this fixed upstream by
commit 9f0e4107c140b47ea2a9c097afcac73a8454e17f
https://bugs.kde.org/show_bug.cgi?id=487296#c6

But that isn't in any released valgrind version. So doing this (now)
unconditionally is the right thing.

> Prevent this false positive by temporarily removing "--track-fds=yes" from
> $VALGRIND_CMD for the duration of the testrun in check_native_core.

Cute solution.

IMHO it makes sense to commit this before (or together with) enabling
--track-fds=yes by default (patch 1). Otherwise the backtrace tests
fail till this patch is applied.

Thanks,

Mark

> Signed-off-by: Aaron Merey <ame...@redhat.com>
> ---
>  tests/backtrace-subr.sh | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/backtrace-subr.sh b/tests/backtrace-subr.sh
> index b63e3814..0a5b38f8 100644
> --- a/tests/backtrace-subr.sh
> +++ b/tests/backtrace-subr.sh
> @@ -187,7 +187,9 @@ check_native_core()
>    fi
>  
>    if [ "x$SAVED_VALGRIND_CMD" != "x" ]; then
> -    VALGRIND_CMD="$SAVED_VALGRIND_CMD"
> +    # Restore $VALGRIND_CMD but disable --track-fds for the following 
> testrun.
> +    # Valgrind --track-fds might complain about an inherited fd.
> +    VALGRIND_CMD=$(sed 's/--track-fds=yes//g' <<< "$SAVED_VALGRIND_CMD")
>      export VALGRIND_CMD
>    fi
>  
> @@ -195,6 +197,12 @@ check_native_core()
>    # - see function check_err.
>    tempfiles $core{,.{bt,err}}
>    (set +ex; testrun ${abs_builddir}/backtrace -e ${abs_builddir}/$child 
> --core=$core 1>$core.bt 2>$core.err; true)
> +
> +  if [ "x$SAVED_VALGRIND_CMD" != "x" ]; then
> +    VALGRIND_CMD="$SAVED_VALGRIND_CMD"
> +    export VALGRIND_CMD
> +  fi
> +
>    cat $core.{bt,err}
>    check_native_unsupported $core.err $child-$core
>    check_all $core.{bt,err} $child-$core
> -- 
> 2.48.1
> 

Reply via email to