-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
/usr/share/bcc/tools/trace cannot exit from loops #3049
Comments
Maybe |
It does not fail in my environment with python 3.7
Do you know why it fails? Maybe due to python site packages? |
sys.exit() and other way would trigger the same call trace. |
This could be related to #4649 |
jeromemarchand
added a commit
to jeromemarchand/bcc
that referenced
this issue
Oct 16, 2023
To exit the tool when the maximal number of event is reached (-M option), the tool currently call exit(), which raise a SystemExit exception. The handling of exception from ctype callback doesn't seem straightforward and dependent on python version. This patch avoid the issue altogether by using a global variable instead. Closes iovisor#3049 Signed-off-by: Jerome Marchand <[email protected]>
yonghong-song
pushed a commit
that referenced
this issue
Nov 6, 2023
To exit the tool when the maximal number of event is reached (-M option), the tool currently call exit(), which raise a SystemExit exception. The handling of exception from ctype callback doesn't seem straightforward and dependent on python version. This patch avoid the issue altogether by using a global variable instead. Closes #3049 Signed-off-by: Jerome Marchand <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On python 3.8.5 and kernel 5.8
root@intel-x86-64:~# /usr/share/bcc/tools/trace do_sys_openat2 -M 1
PID TID COMM FUNC
179 179 systemd-journal do_sys_openat2
Exception ignored on calling ctypes callback function: <function PerfEventArray.open_perf_buffer..raw_cb at 0x7f2a75f060d0>
Traceback (most recent call last):
File "/usr/lib64/python3.8/site-packages/bcc/table.py", line 685, in raw_cb_
callback(cpu, data, size)
File "/usr/share/bcc/tools/trace", line 630, in print_event
exit()
File "/usr/lib64/python3.8/_sitebuiltins.py", line 26, in call
raise SystemExit(code)
SystemExit: None
The above repeated endlessly
The following change could make it work, but not sure if it's the best way to do.
diff --git a/tools/trace.py b/tools/trace.py
index 7a61594f..d09dd2a8 100755
--- a/tools/trace.py
+++ b/tools/trace.py
@@ -627,7 +627,7 @@ BPF_PERF_OUTPUT(%s);
Probe.event_count += 1
if Probe.max_events is not None and
Probe.event_count >= Probe.max_events:
"- exit()"
"+ os._exit(0)"
sys.stdout.flush()
" def attach(self, bpf, verbose):"
The text was updated successfully, but these errors were encountered: