Bug 30700 - tmpdir/gp-collect-app_F test fails
Summary: tmpdir/gp-collect-app_F test fails
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gprofng (show other bugs)
Version: 2.41
: P2 normal
Target Milestone: 2.42
Assignee: Vladimir Mezentsev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-07-30 18:13 UTC by Sam James
Modified: 2023-12-20 02:37 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
gprofng.log (2.11 KB, text/plain)
2023-07-30 18:13 UTC, Sam James
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sam James 2023-07-30 18:13:13 UTC
Created attachment 15023 [details]
gprofng.log

The 'tmpdir/gp-collect-app_F' test fails for me with binutils-2.41.

```
Running /var/tmp/portage/sys-devel/binutils-2.41/work/binutils-2.41/gprofng/testsuite/gprofng.display/gp-collect-app_F.exp ...
mkdir -p tmpdir/gp-collect-app_F
% timeout 300 sh -c 'mkdir -p tmpdir/gp-collect-app_F' 2>&1
cd tmpdir/gp-collect-app_F &&  /var/tmp/portage/sys-devel/binutils-2.41/work/build/gprofng/src/gprofng collect app -p on -a off -F 'off' -O exp.er  sh -c 'mkdir t && touch t/x; rm -rf t'
% timeout 300 sh -c 'cd tmpdir/gp-collect-app_F &&  /var/tmp/portage/sys-devel/binutils-2.41/work/build/gprofng/src/gprofng collect app -p on -a off -F 'off' -O exp.er  sh -c 'mkdir t && touch t/x; rm -rf t' ' 2>&1
find tmpdir/gp-collect-app_F -name '*x1.er' | wc -l
% timeout 300 sh -c 'find tmpdir/gp-collect-app_F -name '*x1.er' | wc -l' 2>&1
cd tmpdir/gp-collect-app_F &&  /var/tmp/portage/sys-devel/binutils-2.41/work/build/gprofng/src/gprofng collect app -p on -a off -F 'on' -O exp.er  sh -c 'mkdir t && touch t/x; rm -rf t'
% timeout 300 sh -c 'cd tmpdir/gp-collect-app_F &&  /var/tmp/portage/sys-devel/binutils-2.41/work/build/gprofng/src/gprofng collect app -p on -a off -F 'on' -O exp.er  sh -c 'mkdir t && touch t/x; rm -rf t' ' 2>&1
find tmpdir/gp-collect-app_F -name '*x1.er' | wc -l
% timeout 300 sh -c 'find tmpdir/gp-collect-app_F -name '*x1.er' | wc -l' 2>&1
Test failed for -F on. subExp=1. Shold be 3
FAIL: tmpdir/gp-collect-app_F
testcase /var/tmp/portage/sys-devel/binutils-2.41/work/binutils-2.41/gprofng/testsuite/gprofng.display/gp-collect-app_F.exp completed in 1 seconds
```
Comment 1 Sam James 2023-07-30 18:13:45 UTC
Reported by doko as well at https://inbox.sourceware.org/binutils/86e6e812-4968-cd28-0c1c-6a38a053c404@debian.org/.
Comment 2 Vladimir Mezentsev 2023-07-31 17:53:40 UTC
It looks like libpthread has a new version number for pthread_create.

What is an output of `nm /usr/lib/libpthread.so | grep pthread_create`
on your machine.
Comment 3 Matthias Klose 2023-07-31 20:18:30 UTC
$ nm /usr/lib/x86_64-linux-gnu/libpthread.so.0
nm: /usr/lib/x86_64-linux-gnu/libpthread.so.0: no symbols

glibc 2.37, there is no libpthread.so anymore.
Comment 4 Vladimir Mezentsev 2023-07-31 20:58:34 UTC
Use the -D flag:
% nm -D /usr/lib/x86_64-linux-gnu/libpthread.so.0 | grep pthread_create
Comment 5 Matthias Klose 2023-07-31 21:07:26 UTC
$ nm -D /usr/lib/x86_64-linux-gnu/libpthread.so.0 
                 w __cxa_finalize@GLIBC_2.2.5
0000000000000000 A GLIBC_2.11
0000000000000000 A GLIBC_2.12
0000000000000000 A GLIBC_2.18
0000000000000000 A GLIBC_2.2.5
0000000000000000 A GLIBC_2.2.6
0000000000000000 A GLIBC_2.28
0000000000000000 A GLIBC_2.30
0000000000000000 A GLIBC_2.31
0000000000000000 A GLIBC_2.3.2
0000000000000000 A GLIBC_2.3.3
0000000000000000 A GLIBC_2.3.4
0000000000000000 A GLIBC_2.4
                 w __gmon_start__
                 w _ITM_deregisterTMCloneTable
                 w _ITM_registerTMCloneTable
0000000000001100 T __libpthread_version_placeholder@GLIBC_2.28
0000000000001100 T __libpthread_version_placeholder@GLIBC_2.11
0000000000001100 T __libpthread_version_placeholder@GLIBC_2.4
0000000000001100 T __libpthread_version_placeholder@GLIBC_2.2.5
0000000000001100 T __libpthread_version_placeholder@GLIBC_2.30
0000000000001100 T __libpthread_version_placeholder@GLIBC_2.3.3
0000000000001100 T __libpthread_version_placeholder@GLIBC_2.12
0000000000001100 T __libpthread_version_placeholder@GLIBC_2.18
0000000000001100 T __libpthread_version_placeholder@GLIBC_2.31
0000000000001100 T __libpthread_version_placeholder@GLIBC_2.2.6
0000000000001100 T __libpthread_version_placeholder@GLIBC_2.3.4
0000000000001100 T __libpthread_version_placeholder@GLIBC_2.3.2
Comment 6 Matthias Klose 2023-07-31 21:08:46 UTC
$ nm -D /lib/x86_64-linux-gnu/libc.so.6 | grep pthread_create
0000000000088580 T pthread_create@GLIBC_2.2.5
0000000000088580 T pthread_create@@GLIBC_2.34
Comment 7 Vladimir Mezentsev 2023-08-01 05:19:37 UTC
We should OK with this libc.
What version of Linux are you using?
I will try to reproduce the problem tomorrow.
Comment 8 Matthias Klose 2023-08-01 05:42:48 UTC
these are the current Debian and Ubuntu development versions.
Comment 9 Sam James 2023-08-01 06:16:35 UTC
Gentoo here. I can give you a Dockerfile or something if you can't reproduce. Just let me know.
Comment 10 Vladimir Mezentsev 2023-08-03 03:33:43 UTC
This test tests the -F option (-F on, -F off, -F <regexp>).
The test profiles this command:
    sh -c 'mkdir t && touch t/x; rm -rf t'
and looks at how many sub-experiments have been created.

The test uses `find $tdir -name '*x1.er' | wc -l` to count sub-experiments.
This is wrong in Debian.

In RH/OL, sh runs fork() -> exec() for each command.
In this case, gprofng creates these sub-experiments:
% ls -1d tmpdir/gp-collect-app_F/exp.er/*er
tmpdir/gp-collect-app_F/exp.er/_f1_x0_x1.er
tmpdir/gp-collect-app_F/exp.er/_f2_x0_x1.er
tmpdir/gp-collect-app_F/exp.er/_f3_x0_x1.er

In Debian, sh runs vfork() -> exec().
In this case, gprofng creates these sub-experiments:
% ls -1d tmpdir/gp-collect-app_F/exp.er/*er
tmpdir/gp-collect-app_F/exp.er/_x1.er
tmpdir/gp-collect-app_F/exp.er/_x2.er
tmpdir/gp-collect-app_F/exp.er/_x3.er


Proposed fix:
% git diff
diff --git a/gprofng/testsuite/gprofng.display/gp-collect-app_F.exp b/gprofng/testsuite/gprofng.display/gp-collect-app_F.exp
index f791b0f7a95..02bcc8e5b49 100644
--- a/gprofng/testsuite/gprofng.display/gp-collect-app_F.exp
+++ b/gprofng/testsuite/gprofng.display/gp-collect-app_F.exp
@@ -46,11 +46,11 @@ proc run_gp_collect_app { subExpCnt F_opt } {
     return -code break
   }
 
-  set output [run_native_host_cmd "find $tdir -name '*x1.er' | wc -l"]
+  set output [run_native_host_cmd "find $tdir -name '*_x?.er' | wc -l"]
   set subExp [lindex $output 1]
   if { $subExp != $subExpCnt } then {
     set out [lindex $output 1]
-    send_log "Test failed for -F $F_opt. subExp=$subExp. Shold be $subExpCnt\n"
+    send_log "Test failed for -F $F_opt. subExp=$subExp. Should be $subExpCnt\n"
     fail $tdir
     return -code break
   }
Comment 11 Matthias Klose 2023-08-03 09:55:13 UTC
that patch fixes the issue for me
Comment 13 Sourceware Commits 2023-08-07 21:35:39 UTC
The master branch has been updated by Vladimir Mezentsev <vmezents@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e0282cf1284b4d358892427a6b4f60d6f4c0580b

commit e0282cf1284b4d358892427a6b4f60d6f4c0580b
Author: Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
Date:   Thu Aug 3 12:56:54 2023 -0700

    gprofng: 30700 tmpdir/gp-collect-app_F test fails
    
    gprofng/ChangeLog
    2023-08-03  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>
    
            PR gprofng/30700
            * testsuite/gprofng.display/gp-collect-app_F.exp: Fix -name argument
            for sub-experiment filtering.
Comment 14 Vladimir Mezentsev 2023-08-08 16:49:07 UTC
Update status as resolved/fixed.
Comment 15 Sourceware Commits 2023-12-20 02:37:51 UTC
The binutils-2_41-branch branch has been updated by Sam James <sjames@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1ce656c66f1859d0f6066e0f9064033712e37aea

commit 1ce656c66f1859d0f6066e0f9064033712e37aea
Author: Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
Date:   Thu Aug 3 12:56:54 2023 -0700

    gprofng: 30700 tmpdir/gp-collect-app_F test fails
    
    gprofng/ChangeLog
    2023-08-03  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>
    
            PR gprofng/30700
            * testsuite/gprofng.display/gp-collect-app_F.exp: Fix -name argument
            for sub-experiment filtering.
    
    (cherry picked from commit e0282cf1284b4d358892427a6b4f60d6f4c0580b)