iovisor / bcc

BCC - Tools for BPF-based Linux IO analysis, networking, monitoring, and more
Apache License 2.0
20.34k stars 3.86k forks source link

Crash with struct/union combo in leaf definition #216

Open drzaeus77 opened 9 years ago

drzaeus77 commented 9 years ago

The following code causes a stack overflow and subsequent crash:

from bcc import BPF

text = """
struct routing_key_2 {
    u32 key_field_0;
};
enum routing_actions_1 {
    routing_nop,
};
struct routing_value_3 {
    enum routing_actions_1 action;
    union {
        struct {
        } nop;
    } u;
};
BPF_TABLE("hash", struct routing_key_2, struct routing_value_3, routing, 512);
"""

b = BPF(text=text)
brendangregg commented 9 years ago

I'm getting a Segmentation fault, might be the same thing, when I add a 4th BPF_HASH.

brendangregg commented 9 years ago

A potential workaround for my crash. Before:

BPF_HASH(filebyreq, struct request *, struct dentry *);
BPF_HASH(filebymap, struct address_space *, struct dentry *);

After:

BPF_HASH(filebyaddr, u64, struct dentry *);

Why have 2 hashes keyed on kernel memory addresses, when 1 would suffice? It's not like the keys will clash. ;-)

Dirty hack of the day.

pchaigno commented 6 years ago

@drzaeus77 I can't reproduce with the last version of bcc. I'm guessing it was fixed in the meantime.