From: "agentzh at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: systemtap@sourceware.org
Subject: [Bug runtime/30408] New: Always fail to read userland memory (read faults) inside perf event probes with 6.2 kernels
Date: Sun, 30 Apr 2023 06:28:35 +0000 [thread overview]
Message-ID: <bug-30408-6586@http.sourceware.org/bugzilla/> (raw)
https://sourceware.org/bugzilla/show_bug.cgi?id=30408
Bug ID: 30408
Summary: Always fail to read userland memory (read faults)
inside perf event probes with 6.2 kernels
Product: systemtap
Version: unspecified
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: runtime
Assignee: systemtap at sourceware dot org
Reporter: agentzh at gmail dot com
Target Milestone: ---
I've noted a regression of stap when using Fedora 36 x86_64's latest 6.2.12
kernel. It always fails to read userland memory inside a perf event probe
handler. It can be demonstrated by the following minimal example.
First prepare a small C program as the tracing target:
```
#include <stdio.h>
unsigned long a = 0;
void foo (void) {
FILE *f = fopen("/dev/null", "w");
fputs("hello world!\n", f);
fclose(f);
}
int main (void) {
while (1) {
a++;
for (int i = 0; i < 100; i++) {
foo();
foo();
}
}
return 0;
}
```
Then we compile it with debug symbols:
```
gcc -g a.c
```
And we copy the resulting `./a.out` program file to `/tmp/`:
```
cp a.out /tmp/
```
Now we prepare a small stap script file named c.stp:
```
global fails = 0;
probe perf.type(1).config(0).sample(1000000) {
if (execname() == "a.out") {
ok = 1;
val = 0;
try {
val = @var("a", "/tmp/a.out");
} catch {
ok = 0;
fails++;
}
if (ok) {
printf("a = %d\n", val);
exit();
}
}
}
probe begin {
warn("Start tracing...");
}
probe timer.s(2) {
printf("failed %ld times\n", fails);
}
```
And we run it like this:
```
/opt/stap/bin/stap -c /tmp/a.out c.stp
WARNING: Start tracing...
failed 3927 times
failed 7854 times
failed 11769 times
failed 15741 times
failed 19705 times
failed 23671 times
failed 27668 times
failed 31639 times
failed 35613 times
failed 39563 times
failed 43491 times
failed 47463 times
failed 51465 times
...
```
No matter how long we wait, it always fails to read anything from `@var()`.
For comparison, I also ran this example on an older kernel (5.0.16) of an older
Fedora system and it works fine:
```
$ /opt/stap/bin/stap -c ./a.out c.stp
WARNING: Start tracing...
a = 150746
```
So it's definitely a behavior regression with the new kernel.
--
You are receiving this mail because:
You are the assignee for the bug.
next reply other threads:[~2023-04-30 6:28 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-30 6:28 agentzh at gmail dot com [this message]
2023-05-02 22:31 ` [Bug runtime/30408] " agentzh at gmail dot com
2023-05-02 22:32 ` [Bug runtime/30408] Always fail to read userland memory (read faults) inside perf event probes with 6.2/6.1 kernels agentzh at gmail dot com
2023-05-09 19:59 ` agentzh at gmail dot com
2023-05-09 20:04 ` agentzh at gmail dot com
2023-05-13 5:33 ` agentzh at gmail dot com
2023-05-13 6:28 ` agentzh at gmail dot com
2023-05-16 19:28 ` agentzh at gmail dot com
2023-05-16 19:51 ` agentzh at gmail dot com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-30408-6586@http.sourceware.org/bugzilla/ \
--to=sourceware-bugzilla@sourceware.org \
--cc=systemtap@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).