Hi, I'm running test_maps under net-next/samples/bpf/, commit 601009780635. The code logic all make sense but I got the assertion errors / coredump for some unknown reason under different compiler optimization flags (-O0 and -O2). The test_hashmap_sanity() works fine but fails at test_percpu_hashmap_sanity().
First run with normal build (which has -O2) [root@vm-dev bpf]# ./test_maps test_maps: samples/bpf/test_maps.c:137: test_percpu_hashmap_sanity: Assertion `bpf_lookup_elem(map_fd, &key, value) == -1 && (*__errno_location ()) == 2' failed. where line test_maps.c: 137 is /* check that key=2 is not found */ assert(bpf_lookup_elem(map_fd, &key, value) == -1 && errno == ENOENT); Running it with strace, everything looks correct (bpf() return -1 and errno == ENOENT) [root@vm-dev bpf]# strace ./test_maps bpf(0x1, 0x7ffcafe7f290, 0x30) = -1 ENOENT (No such file or directory) write(2, "test_maps: samples/bpf/test_maps"..., 162test_maps: samples/bpf/test_maps.c:137: test_percpu_hashmap_sanity: Assertion `bpf_lookup_elem(map_fd, &key, value) == -1 && (*__errno_location ()) == 2' failed. ) = 162 Then I twisted Makefile with "-O0" instead of -O2, then line 137 passes but it fails at line 161. test_maps: samples/bpf/test_maps.c:161: test_percpu_hashmap_sanity: Assertion `(expected_key_mask & next_key) == next_key' failed. using gdb to debug: Aborted (core dumped) (gdb) f 4 #4 0x0000000000401330 in test_percpu_hashmap_sanity (task=0, data=0x0) at samples/bpf/test_maps.c:161 161 assert((expected_key_mask & next_key) == next_key); (gdb) p key $1 = 140736693748448 (gdb) p next_key $2 = 2 It seems that the value of the key is corrupted. Any suggestion for how to debug this? Thank you! William _______________________________________________ iovisor-dev mailing list [email protected] https://lists.iovisor.org/mailman/listinfo/iovisor-dev
