Bug 2042238

Summary: [bcc-tools] compactsnoop aborted with "Error at line 82: Unsupport signed division..."
Product: Red Hat Enterprise Linux 8 Reporter: Shizhao Chen <shichen>
Component: bccAssignee: Jerome Marchand <jmarchan>
Status: VERIFIED --- QA Contact: Ziqian SUN (Zamir) <zsun>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 8.6CC: jmarchan, rdossant, zsun
Target Milestone: rcKeywords: Triaged
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
Whiteboard:
Fixed In Version: bcc-0.25.0-5.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Shizhao Chen 2022-01-19 05:14:15 UTC
Description of problem:
`compactsnoop' aborted when executed.

Version-Release number of selected component (if applicable):
kernel-devel-4.18.0-359.el8.x86_64
bcc-0.19.0-5.el8.x86_64
bcc-tools-0.19.0-5.el8.x86_64

How reproducible:
always

Steps to Reproduce:
1. /usr/share/bcc/tools/compactsnoop
2.
3.

Actual results:
[root@ci-vm-10-0-139-181 tools]# ./compactsnoop 
Error at line 82: Unsupport signed division for DAG: 0x563f86a77fa0: i64 = sdiv exact 0x563f85704ea8, Constant:i64<1472>, /virtual/main.c:82:17 @[ /virtual/main.c:159:17 @[ /virtual/main.c:192:5 ] ]Please convert to unsigned div/mod.
LLVM ERROR: Cannot select: 0x563f86a77fa0: i64 = sdiv exact 0x563f85704ea8, Constant:i64<1472>, /virtual/main.c:82:17 @[ /virtual/main.c:159:17 @[ /virtual/main.c:192:5 ] ]
  0x563f85704ea8: i64 = sub 0x563f86a77b28, 0x563f86a780d8, /virtual/main.c:82:17 @[ /virtual/main.c:159:17 @[ /virtual/main.c:192:5 ] ]
    0x563f86a77b28: i64,ch = CopyFromReg 0x563f844640e8, Register:i64 %0, /virtual/main.c:168:25
      0x563f86a77d30: i64 = Register %0
    0x563f86a780d8: i64,ch = load<(dereferenceable load (s64) from %ir.2, !tbaa !2713)> 0x563f85705320, FrameIndex:i64<0>, undef:i64, /virtual/main.c:82:19 @[ /virtual/main.c:159:17 @[ /virtual/main.c:192:5 ] ]
      0x563f86a776b0: i64 = FrameIndex<0>
      0x563f86a77920: i64 = undef
  0x563f86a77f38: i64 = Constant<1472>
In function: raw_tracepoint__mm_compaction_suitable
Aborted (core dumped)

Expected results:
Proceed without error.

Additional info:
An identical bug for rhel9 filed at bz2042236.

Comment 2 Shizhao Chen 2022-05-17 06:09:27 UTC
FYI, 84z has the same issue:

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::   Error messages generated for './compactsnoop --timestamp --duration 10 --kernel-stack --extended_fields'
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

In file included from <built-in>:2:
In file included from /virtual/include/bcc/bpf.h:12:
In file included from include/linux/types.h:6:
In file included from include/uapi/linux/types.h:14:
In file included from include/uapi/linux/posix_types.h:5:
In file included from include/linux/stddef.h:5:
In file included from include/uapi/linux/stddef.h:2:
In file included from include/linux/compiler_types.h:78:
include/linux/compiler-clang.h:29:9: warning: '__no_sanitize_address' macro redefined [-Wmacro-redefined]
#define __no_sanitize_address
        ^
include/linux/compiler-gcc.h:339:9: note: previous definition is here
#define __no_sanitize_address __attribute__((no_sanitize_address))
        ^
1 warning generated.
bpf: Failed to load program: Permission denied
; int ret = (int)ctx->args[2];
0: (79) r2 = *(u64 *)(r1 +16)
; int ret = (int)ctx->args[2];
1: (67) r2 <<= 32
2: (77) r2 >>= 32
; if(ret != COMPACT_CONTINUE)
3: (55) if r2 != 0x4 goto pc+123
 R1=ctx(id=0,off=0,imm=0) R2_w=inv4 R10=fp0
;
4: (79) r2 = *(u64 *)(r1 +8)
5: (7b) *(u64 *)(r10 -104) = r2
6: (79) r6 = *(u64 *)(r1 +0)
; id = bpf_get_current_pid_tgid();
7: (85) call bpf_get_current_pid_tgid#14
; id = bpf_get_current_pid_tgid();
8: (7b) *(u64 *)(r10 -16) = r0
; struct val_t *valp = bpf_map_lookup_elem((void *)bpf_pseudo_fd(1, -1), &id);
9: (18) r1 = 0xffff9585c6b6ac00
11: (bf) r2 = r10
;
12: (07) r2 += -16
; struct val_t *valp = bpf_map_lookup_elem((void *)bpf_pseudo_fd(1, -1), &id);
13: (85) call bpf_map_lookup_elem#1
14: (bf) r8 = r0
;
15: (bf) r7 = r8
16: (07) r7 += 4
R7 pointer arithmetic on map_value_or_null prohibited, null-check it first
processed 16 insns (limit 1000000) max_states_per_insn 0 total_states 1 peak_states 1 mark_read 1

Traceback (most recent call last):
  File "./compactsnoop", line 291, in <module>
    b = BPF(text=bpf_text)
  File "/usr/lib/python3.6/site-packages/bcc/__init__.py", line 372, in __init__
    self._trace_autoload()
  File "/usr/lib/python3.6/site-packages/bcc/__init__.py", line 1243, in _trace_autoload
    fn = self.load_func(func_name, BPF.RAW_TRACEPOINT)
  File "/usr/lib/python3.6/site-packages/bcc/__init__.py", line 412, in load_func
    (func_name, errstr))
Exception: Failed to load BPF program b'raw_tracepoint__mm_compaction_suitable': Permission denied