Bug 2315921

Summary: error: ‘uprobe_unregister’ undeclared here (not in a function)
Product: [Fedora] Fedora Reporter: Jun Aruga <jaruga>
Component: systemtapAssignee: Frank Ch. Eigler <fche>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: rawhideCC: amerey, fche, mcermak, mjw, scox, vondruch, wcohen
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: systemtap-5.2~pre17283218gc5774e18-1.fc42 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2024-10-07 20:45:02 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jun Aruga 2024-10-01 14:25:09 UTC
We got the following error on Fedora rawhide. I wanted to report this error originally, mentioned at <https://bugzilla.redhat.com/show_bug.cgi?id=2314458#c3>.

```
# stap -v /usr/share/doc/ruby-doc/ruby-exercise.stp
Pass 1: parsed user script and 487 library scripts using 144528virt/111580res/14916shr/98128data kb, in 200usr/50sys/501real ms.
Pass 2: analyzed script: 19 probes, 7 functions, 1 embed, 0 globals using 222296virt/121244res/20612shr/110312data kb, in 130usr/50sys/1887real ms.
Pass 3: translated to C into "/tmp/stapeexHVU/stap_ecb420d96500e6c3d0f41709904a85b4_18907_src.c" using 222640virt/122184res/21212shr/110656data kb, in 180usr/370sys/2058real ms.
In file included from /tmp/stapeexHVU/stap_ecb420d96500e6c3d0f41709904a85b4_18907_src.c:2968:
/usr/share/systemtap/runtime/linux/uprobes-inode.c:50:17: error: ‘uprobe_unregister’ undeclared here (not in a function); did you mean ‘uprobe_register’?
   50 | typedef typeof(&uprobe_unregister) uprobe_unregister_fn;
      |                 ^~~~~~~~~~~~~~~~~
      |                 uprobe_register
/usr/share/systemtap/runtime/linux/uprobes-inode.c: In function ‘stapiu_register’:
/usr/share/systemtap/runtime/linux/uprobes-inode.c:290:52: error: passing argument 3 of ‘uprobe_register’ makes integer from pointer without a cast [-Wint-conversion]
  290 |     ret = uprobe_register (inst->inode, c->offset, &inst->kconsumer);
      |                                                    ^~~~~~~~~~~~~~~~
      |                                                    |
      |                                                    struct uprobe_consumer *
In file included from ./include/linux/mm_types.h:16,
                 from ./include/linux/mmzone.h:22,
                 from ./include/linux/gfp.h:7,
                 from /usr/share/systemtap/runtime/linux/runtime_defines.h:1,
                 from /usr/share/systemtap/runtime/runtime_defines.h:8,
                 from /tmp/stapeexHVU/stap_ecb420d96500e6c3d0f41709904a85b4_18907_src.c:12:
./include/linux/uprobes.h:116:82: note: expected ‘loff_t’ {aka ‘long long int’} but argument is of type ‘struct uprobe_consumer *’
  116 | extern struct uprobe *uprobe_register(struct inode *inode, loff_t offset, loff_t ref_ctr_offset, struct uprobe_consumer *uc);
      |                                                                           ~~~~~~~^~~~~~~~~~~~~~
/usr/share/systemtap/runtime/linux/uprobes-inode.c:290:11: error: too few arguments to function ‘uprobe_register’
  290 |     ret = uprobe_register (inst->inode, c->offset, &inst->kconsumer);
      |           ^~~~~~~~~~~~~~~
./include/linux/uprobes.h:116:23: note: declared here
  116 | extern struct uprobe *uprobe_register(struct inode *inode, loff_t offset, loff_t ref_ctr_offset, struct uprobe_consumer *uc);
      |                       ^~~~~~~~~~~~~~~
In file included from /usr/share/systemtap/runtime/runtime.h:26,
                 from /tmp/stapeexHVU/stap_ecb420d96500e6c3d0f41709904a85b4_18907_src.c:21:
/usr/share/systemtap/runtime/linux/uprobes-inode.c: In function ‘stapiu_unregister’:
/usr/share/systemtap/runtime/linux/uprobes-inode.c:54:19: error: invalid type argument of unary ‘*’ (have ‘int’)
   54 | void_ibt_wrapper((* (uprobe_unregister_fn)kallsyms_uprobe_unregister)((a),(b),(c)))
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/share/systemtap/runtime/linux/runtime.h:324:4: note: in definition of macro ‘void_ibt_wrapper’
  324 |   (function);                                   \
      |    ^~~~~~~~
/usr/share/systemtap/runtime/linux/uprobes-inode.c:315:10: note: in expansion of macro ‘uprobe_unregister’
  315 |   (void) uprobe_unregister (inst->inode, c->offset, &inst->kconsumer);
      |          ^~~~~~~~~~~~~~~~~
make[1]: *** [scripts/Makefile.build:229: /tmp/stapeexHVU/stap_ecb420d96500e6c3d0f41709904a85b4_18907_src.o] Error 1
make: *** [Makefile:1982: /tmp/stapeexHVU] Error 2
WARNING: kbuild exited with status: 2
Pass 4: compiled C into "stap_ecb420d96500e6c3d0f41709904a85b4_18907.ko" in 28840usr/3820sys/33307real ms.
Pass 4: compilation failed.  [man error::pass4]
Kernel version 6.12.0 is outside tested range 3.10 ... 6.11-rc3

# echo $?
1
```


Reproducible: Always

Steps to Reproduce:
1. # dnf install kernel-devel systemtap ruby ruby-doc
2. # dnf upgrade  # To use the same version of kernel and kernel-devel RPM package.
3. # reboot
4. # stap -v /usr/share/doc/ruby-doc/ruby-exercise.stp


Actual Results:  
```
# stap -v /usr/share/doc/ruby-doc/ruby-exercise.stp
Pass 1: parsed user script and 487 library scripts using 144528virt/111580res/14916shr/98128data kb, in 200usr/50sys/501real ms.
Pass 2: analyzed script: 19 probes, 7 functions, 1 embed, 0 globals using 222296virt/121244res/20612shr/110312data kb, in 130usr/50sys/1887real ms.
Pass 3: translated to C into "/tmp/stapeexHVU/stap_ecb420d96500e6c3d0f41709904a85b4_18907_src.c" using 222640virt/122184res/21212shr/110656data kb, in 180usr/370sys/2058real ms.
In file included from /tmp/stapeexHVU/stap_ecb420d96500e6c3d0f41709904a85b4_18907_src.c:2968:
/usr/share/systemtap/runtime/linux/uprobes-inode.c:50:17: error: ‘uprobe_unregister’ undeclared here (not in a function); did you mean ‘uprobe_register’?
   50 | typedef typeof(&uprobe_unregister) uprobe_unregister_fn;
      |                 ^~~~~~~~~~~~~~~~~
      |                 uprobe_register
/usr/share/systemtap/runtime/linux/uprobes-inode.c: In function ‘stapiu_register’:
/usr/share/systemtap/runtime/linux/uprobes-inode.c:290:52: error: passing argument 3 of ‘uprobe_register’ makes integer from pointer without a cast [-Wint-conversion]
  290 |     ret = uprobe_register (inst->inode, c->offset, &inst->kconsumer);
      |                                                    ^~~~~~~~~~~~~~~~
      |                                                    |
      |                                                    struct uprobe_consumer *
In file included from ./include/linux/mm_types.h:16,
                 from ./include/linux/mmzone.h:22,
                 from ./include/linux/gfp.h:7,
                 from /usr/share/systemtap/runtime/linux/runtime_defines.h:1,
                 from /usr/share/systemtap/runtime/runtime_defines.h:8,
                 from /tmp/stapeexHVU/stap_ecb420d96500e6c3d0f41709904a85b4_18907_src.c:12:
./include/linux/uprobes.h:116:82: note: expected ‘loff_t’ {aka ‘long long int’} but argument is of type ‘struct uprobe_consumer *’
  116 | extern struct uprobe *uprobe_register(struct inode *inode, loff_t offset, loff_t ref_ctr_offset, struct uprobe_consumer *uc);
      |                                                                           ~~~~~~~^~~~~~~~~~~~~~
/usr/share/systemtap/runtime/linux/uprobes-inode.c:290:11: error: too few arguments to function ‘uprobe_register’
  290 |     ret = uprobe_register (inst->inode, c->offset, &inst->kconsumer);
      |           ^~~~~~~~~~~~~~~
./include/linux/uprobes.h:116:23: note: declared here
  116 | extern struct uprobe *uprobe_register(struct inode *inode, loff_t offset, loff_t ref_ctr_offset, struct uprobe_consumer *uc);
      |                       ^~~~~~~~~~~~~~~
In file included from /usr/share/systemtap/runtime/runtime.h:26,
                 from /tmp/stapeexHVU/stap_ecb420d96500e6c3d0f41709904a85b4_18907_src.c:21:
/usr/share/systemtap/runtime/linux/uprobes-inode.c: In function ‘stapiu_unregister’:
/usr/share/systemtap/runtime/linux/uprobes-inode.c:54:19: error: invalid type argument of unary ‘*’ (have ‘int’)
   54 | void_ibt_wrapper((* (uprobe_unregister_fn)kallsyms_uprobe_unregister)((a),(b),(c)))
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/share/systemtap/runtime/linux/runtime.h:324:4: note: in definition of macro ‘void_ibt_wrapper’
  324 |   (function);                                   \
      |    ^~~~~~~~
/usr/share/systemtap/runtime/linux/uprobes-inode.c:315:10: note: in expansion of macro ‘uprobe_unregister’
  315 |   (void) uprobe_unregister (inst->inode, c->offset, &inst->kconsumer);
      |          ^~~~~~~~~~~~~~~~~
make[1]: *** [scripts/Makefile.build:229: /tmp/stapeexHVU/stap_ecb420d96500e6c3d0f41709904a85b4_18907_src.o] Error 1
make: *** [Makefile:1982: /tmp/stapeexHVU] Error 2
WARNING: kbuild exited with status: 2
Pass 4: compiled C into "stap_ecb420d96500e6c3d0f41709904a85b4_18907.ko" in 28840usr/3820sys/33307real ms.
Pass 4: compilation failed.  [man error::pass4]
Kernel version 6.12.0 is outside tested range 3.10 ... 6.11-rc3

# echo $?
1
```

Expected Results:  
The stap command execute the /usr/share/doc/ruby-doc/ruby-exercise.stp without errors.

The installed RPM packages related to this topic are below.

```
# uname -r
6.12.0-0.rc0.20240927git075dbe9f6e3c.14.fc42.x86_64

# rpm -q kernel kernel-devel systemtap systemtap-devel ruby ruby-doc
kernel-6.12.0-0.rc0.20240920gitbaeb9a7d8b60.7.fc42.x86_64
kernel-6.12.0-0.rc0.20240927git075dbe9f6e3c.14.fc42.x86_64
kernel-devel-6.12.0-0.rc0.20240927git075dbe9f6e3c.14.fc42.x86_64
systemtap-5.2~pre17250223gd07e4284-1.fc42.x86_64
systemtap-devel-5.2~pre17250223gd07e4284-1.fc42.x86_64
ruby-3.3.5-15.fc42.x86_64
ruby-doc-3.3.5-15.fc42.noarch
```

The used .stp file is below.

```
# rpm -qf /usr/share/doc/ruby-doc/ruby-exercise.stp
ruby-doc-3.3.5-15.fc42.noarch
```

```
# cat /usr/share/doc/ruby-doc/ruby-exercise.stp
/* Example tapset file.
 *
 * You can execute the tapset using following command (please adjust the path
 * prior running the command, if needed):
 *
 * stap /usr/share/doc/ruby-2.0.0.0/ruby-exercise.stp -c "ruby -e \"puts 'test'\""
 */

probe ruby.cmethod.entry {
  printf("%d -> %s::%s %s:%d\n", tid(), classname, methodname, file, line);
}

probe ruby.cmethod.return {
  printf("%d <- %s::%s %s:%d\n", tid(), classname, methodname, file, line);
}

probe ruby.method.entry {
  printf("%d -> %s::%s %s:%d\n", tid(), classname, methodname, file, line);
}

probe ruby.method.return {
  printf("%d <- %s::%s %s:%d\n", tid(), classname, methodname, file, line);
}

probe ruby.gc.mark.begin { printf("%d gc.mark.begin\n", tid()); }

probe ruby.gc.mark.end { printf("%d gc.mark.end\n", tid()); }

probe ruby.gc.sweep.begin { printf("%d gc.sweep.begin\n", tid()); }

probe ruby.gc.sweep.end { printf("%d gc.sweep.end\n", tid()); }

probe ruby.object.create{
  printf("%d obj.create %s %s:%d\n", tid(), classname, file, line);
}

probe ruby.raise {
  printf("%d raise %s %s:%d\n", tid(), classname, file, line);
}
```

Comment 1 William Cohen 2024-10-01 15:23:07 UTC
This is addressed in the upstream git commit b1d109410c27538bfd2148add9272aca89f46b72

Author: Martin Cermak <mcermak>  2024-09-24 06:00:10
Committer: Martin Cermak <mcermak>  2024-09-24 06:04:17
Parent: 2f085c803d5eea6029e32feefc91510b439085a3 (RHEL-47342: clarify that the systemtap-client subrpm is for -server use)
Child:  0b7f672260ae1de1f20ee9927c7b1e956cbde0e5 (PR32209: Define the __COUNT_ARGS macro conditionally)
Branches: master, remotes/origin/master
Follows: release-5.1
Precedes: 

    PR32194: Use v6.12 versions of uprobe register and unregister functions
    
    Kernel 6.12 comes with kernel commits 04b01625d and 3c83a9ad changing
    the way uprobe register and unregister functions work.



Doing a respin for Fedora rawhide to address this, systemtap-5.2~pre17277956g0b7f6722-1.fc42.

Comment 2 William Cohen 2024-10-01 16:35:33 UTC
This should be addressed by systemtap-5.2~pre17277956g0b7f6722-1.fc42.

Comment 3 Jun Aruga 2024-10-02 13:12:12 UTC
Thanks for fixing this issue quickly.

I confirmed the systemtap-5.2~pre17250223gd07e4284-1.fc42.x86_64 fixed this issue by the following steps.

Below is the koji build of systemtap-5.2~pre17250223gd07e4284-1.fc42.
https://koji.fedoraproject.org/koji/buildinfo?buildID=2558654

I installed the RPMs directly.

```
# rpm -Uvh systemtap-5.2~pre17277956g0b7f6722-1.fc42.x86_64.rpm systemtap-runtime-5.2~pre17277956g0b7f6722-1.fc42.x86_64.rpm systemtap-devel-5.2~pre17277956g0b7f6722-1.fc42.x86_64.rpm systemtap-client-5.2~pre17277956g0b7f6722-1.fc42.x86_64.rpm
```

Then the installed and used RPM packages are below.

```
# rpm -qa | grep systemtap
systemtap-devel-5.2~pre17277956g0b7f6722-1.fc42.x86_64
systemtap-runtime-5.2~pre17277956g0b7f6722-1.fc42.x86_64
systemtap-client-5.2~pre17277956g0b7f6722-1.fc42.x86_64
systemtap-5.2~pre17277956g0b7f6722-1.fc42.x86_64

# uname -r
6.12.0-0.rc0.20240927git075dbe9f6e3c.14.fc42.x86_64

# rpm -q kernel kernel-devel systemtap systemtap-devel ruby ruby-doc
kernel-6.12.0-0.rc0.20240920gitbaeb9a7d8b60.7.fc42.x86_64
kernel-6.12.0-0.rc0.20240927git075dbe9f6e3c.14.fc42.x86_64
kernel-devel-6.12.0-0.rc0.20240927git075dbe9f6e3c.14.fc42.x86_64
systemtap-5.2~pre17277956g0b7f6722-1.fc42.x86_64
systemtap-devel-5.2~pre17277956g0b7f6722-1.fc42.x86_64
ruby-3.3.5-15.fc42.x86_64
ruby-doc-3.3.5-15.fc42.noarch

# rpm -qf /usr/share/doc/ruby-doc/ruby-exercise.stp
ruby-doc-3.3.5-15.fc42.noarch
```

Then the following command is working now.

```
# stap -v /usr/share/doc/ruby-doc/ruby-exercise.stp
Pass 1: parsed user script and 487 library scripts using 144488virt/111708res/15044shr/98084data kb, in 160usr/60sys/219real ms.
Pass 2: analyzed script: 19 probes, 7 functions, 1 embed, 0 globals using 222280virt/120956res/20324shr/110292data kb, in 130usr/40sys/1086real ms.
Pass 3: translated to C into "/tmp/stapQ9tuFw/stap_5a58380fb579a7865dd54e6a607a7271_18907_src.c" using 222576virt/121940res/20960shr/110588data kb, in 190usr/430sys/2057real ms.
Pass 4: compiled C into "stap_5a58380fb579a7865dd54e6a607a7271_18907.ko" in 31600usr/5140sys/37454real ms.
Pass 5: starting run.
```

Comment 4 Jun Aruga 2024-10-02 14:38:25 UTC
Hi William,
I was told at devel mailing list [1] that the gating for the systemtap-5.2~pre17277956g0b7f6722-1.fc42 build failed.[2] Therefore the build is not tagged to the the "f42" tag yet. You may take a look at the failure.

[1] https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/ITFJ6TJ5HENGXVY5J3PXSHRP4O6KXBCC/
[2] https://bodhi.fedoraproject.org/updates/FEDORA-2024-734dfcbc9d

Comment 5 Jun Aruga 2024-10-07 09:02:49 UTC
William,
I changed this ticket's status from CLOSED to MODIFIED. Because I mentioned above, the gating in Bodhi is failing.

Comment 6 William Cohen 2024-10-07 17:26:14 UTC
There appears to be an issue with the gating system rather than the systemtap build.  I retriggered the CI testing:

https://bodhi.fedoraproject.org/updates/FEDORA-2024-734dfcbc9d

Looks like the freshest Linux 6.12 kernels causing problems with the functional testing (https://artifacts.dev.testing-farm.io/ba52d499-9665-48c5-b1af-e10ad447aac6/). Doing another respin with the following patch just checked in:

commit c5774e18b7241cc484ef9d5e17214651b9b9d439 (HEAD -> master, origin/master, origin/HEAD)
Author: William Cohen <wcohen>
Date:   Mon Oct 7 11:27:10 2024 -0400

    Address the Linux 6.12 move of the unaligned.h include file
    
    The Linux git commit 5f60d5f6bb moved unaligned.h from asm/unaligned.h
    to linux/unaligned.h.  Adjusted runtime/sym.c to include the
    unaligned.h from the appropriate location.

Comment 7 Jun Aruga 2024-10-08 12:22:19 UTC
Thanks for working on it.

I can see all required tests passed with the systemtap-5.2~pre17283218gc5774e18-1.fc42.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-0d1a455d79

And the systemtap-5.2~pre17283218gc5774e18-1.fc42 has the f42 tag.
https://koji.fedoraproject.org/koji/buildinfo?buildID=2563213