compilation failure
- Dominant language
- C
- Stars
- 22.7k
- Forks
- 4.1k
- Avg merge
- 10d 4h
- Merged PRs (30d)
- 3
Description
I'm getting `error: :0:0: in function trace_trans_doing i32 (%struct.pt_regs*): A call to built-in function 'abort' is not supported.` When I try to load the following program:
```
#include
enum transaction_state {
STATE_DOING,
STATE_CRIT_1, // idx 2, 3
STATE_CRIT_2, // idx 4, 5
STATE_UNBLOCKED, //idx 6, 7
STATE_NUM
};
BPF_HASH(state_crit_1, u32);
BPF_HASH(state_crit_2, u32);
BPF_HASH(state_doing, u32);
// + 1 due to implicit "return from trans" state.
BPF_ARRAY(wrk_pad, u64, (STATE_NUM +1) * 2);
static int trace_return(struct pt_regs *ctx, int state)
{
u64 *tsp, delta, *avg, *count;
u32 key1 = state * 2;
u32 key2 = key1 + 1;
u64 pid_tgid = bpf_get_current_pid_tgid();
u32 pid = pid_tgid;
u64 ts = bpf_ktime_get_ns();
if (state == STATE_DOING) {
state_doing.update(&pid, &ts);
} else if (state == STATE_UNBLOCKED) {
tsp = state_crit_2.lookup(&pid);
state_crit_2.delete(&pid);
} else if (state == STATE_CRIT_1) {
state_crit_1.update(&pid, &ts);
tsp = state_doing.lookup(&pid);
state_doing.delete(&pid);
} else if (state == STATE_CRIT_2) {
state_crit_2.update(&pid, &ts);
tsp = state_crit_1.lookup(&pid);
state_crit_1.delete(&pid);
}
if (tsp == 0) {
return 0; // missed start
}
// calculate delta time
delta = bpf_ktime_get_ns() - *tsp;
//roll into average
avg = wrk_pad.lookup(&key1);
count = wrk_pad.lookup(&key2);
if (avg && count) {
*avg += delta;
(*count)++;
}
return 0;
}
int trace_trans_doing(struct pt_regs *ctx)
{
return trace_return(ctx, STATE_DOING);
}
int trace_trans_unblocked(struct pt_regs *ctx)
{
return trace_return(ctx, STATE_UNBLOCKED);
}
int trace_trans_stage1(struct pt_regs *ctx)
{
return trace_return(ctx, STATE_CRIT_1);
}
int trace_trans_stage2(struct pt_regs *ctx)
{
return trace_return(ctx, STATE_CRIT_2);
}
```
If I add an explicit `return 0` in the` if (STATE_DOING)` or explicitly set `tsp = 0` compilation also succeeds. Without those changes I'd really expect a warning or an error because tsp would be checked without being initialized instead I get a rather cryptic abort error.
I'm using bcc built from trunk and my head is at: ceb458d6a07a ("prepare for release v0.14.0")
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.