Comments (9)
Thanks, will take a look
from kmesh.
Can you provide the panic information?
from kmesh.
Can you provide the panic information?
I am outside, but i remember it is due to clustertogolang function, the buf len is zero, so convertToPack which will convert &buf[0]
to pointer will panic.
More weird is if you add more fields to cluster, like adding appstatus, connecttimeout, it will not cause panic, but you cannot get the name. (the deserialization is not complete)
cc @hzxuzhonghu @supercharge-xsy
from kmesh.
when marshal use proto.Marshal, we get size A
when unmarshal we use c function, we get size B
I observed that A was not equal to B
from kmesh.
=== RUN TestClusterLookUp
time="2024-09-13T11:37:40+08:00" level=info msg="kmesh start with Normal" subsys=pkg/bpf
time="2024-09-13T11:37:42+08:00" level=info msg="Clean kmesh_version map and bpf prog" subsys=pkg/bpf
unmount /mnt/kmesh_cgroup2 error: no such file or directory
unmount /sys/fs/bpf error: invalid argument
--- FAIL: TestClusterLookUp (2.56s)
panic: runtime error: index out of range [0] with length 0 [recovered]
panic: runtime error: index out of range [0] with length 0
goroutine 7 [running]:
testing.tRunner.func1.2({0x1b05340, 0xc0001564e0})
/root/go/pkg/mod/golang.org/[email protected]/src/testing/testing.go:1631 +0x24a
testing.tRunner.func1()
/root/go/pkg/mod/golang.org/[email protected]/src/testing/testing.go:1634 +0x377
panic({0x1b05340?, 0xc0001564e0?})
/root/go/pkg/mod/golang.org/[email protected]/src/runtime/panic.go:770 +0x132
kmesh.net/kmesh/pkg/cache/v2/maps.convertToPack(...)
/root/go/src/kmesh.net/kmesh/pkg/cache/v2/maps/common.go:37
kmesh.net/kmesh/pkg/cache/v2/maps.clusterToGolang.func2(0x31bea10?, {0x2f629e0?, 0x31bc3d0?, 0x7fe0bdc9e7d0?})
/root/go/src/kmesh.net/kmesh/pkg/cache/v2/maps/cluster.go:38 +0x6f
kmesh.net/kmesh/pkg/cache/v2/maps.clusterToGolang(0xc0005c2d80, 0x31bea10)
/root/go/src/kmesh.net/kmesh/pkg/cache/v2/maps/cluster.go:38 +0x56
kmesh.net/kmesh/pkg/cache/v2/maps.ClusterLookup({0x1c4eada, 0xc}, 0xc0005c2d80)
/root/go/src/kmesh.net/kmesh/pkg/cache/v2/maps/cluster.go:74 +0xc5
kmesh.net/kmesh/pkg/cache/v2.TestClusterLookUp(0xc0000c91e0)
/root/go/src/kmesh.net/kmesh/pkg/cache/v2/cluster_test.go:334 +0x169
testing.tRunner(0xc0000c91e0, 0x1d618a8)
/root/go/pkg/mod/golang.org/[email protected]/src/testing/testing.go:1689 +0xfb
created by testing.(*T).Run in goroutine 1
/root/go/pkg/mod/golang.org/[email protected]/src/testing/testing.go:1742 +0x390
FAIL kmesh.net/kmesh/pkg/cache/v2 2.588s
from kmesh.
deserial_lookup_elem
this function must be wrong, C.cluster__cluster__get_packed_size return 0 with the elem returned.
from kmesh.
I find something interesting, if we change the cluster in the test. It will not panic, i guess the name filed is not written into the map, or deserial does not set it well, so if only name is set, it panic.
func TestClusterLookUp(t *testing.T) {
cluster := cluster_v2.Cluster{
// Name: "test-cluster",
// LbPolicy: cluster_v2.Cluster_ROUND_ROBIN,
ConnectTimeout: 10000,
LoadAssignment: &endpoint.ClusterLoadAssignment{
ClusterName: "test-cluster",
},
}
config := options.BpfConfig{
Mode: "ads",
BpfFsPath: "/sys/fs/bpf",
Cgroup2Path: "/mnt/kmesh_cgroup2",
}
cleanup, _ := test.InitBpfMap(t, config)
t.Cleanup(cleanup)
err := maps_v2.ClusterUpdate(cluster.Name, &cluster)
assert.Nil(t, err)
got_cluster := cluster_v2.Cluster{}
err = maps_v2.ClusterLookup(cluster.Name, &got_cluster)
assert.Nil(t, err)
data, _ := json.Marshal(got_cluster)
fmt.Println("got_cluster: ", string(data))
assert.Equal(t, cluster.Name, got_cluster.Name)
}
from kmesh.
In the lookup process, valid_field_value
does not need to be checked because the outter_key stored for members of the pointer type may be 0.
// create_struct
if (!selected_oneof_field(ctx->value, field) || !valid_field_value(ctx->value, field))
continue;
// after modify, valid_field_value does not need to be invoked.
if (!selected_oneof_field(ctx->value, field))
continue;
But after I corrected it, there was still an error, and I didn't know why.
[root@k8s-node1 v2]# go test . -v
=== RUN TestClusterLookUp
time="2024-09-13T21:29:49+08:00" level=info msg="kmesh start with Normal" subsys=pkg/bpf
SIGSEGV: segmentation violation
PC=0x7f01d050eae1 m=0 sigcode=128 addr=0x0
signal arrived during cgo execution
goroutine 14 gp=0xc0004a5180 m=0 mp=0x2f160e0 [syscall]:
runtime.cgocall(0x17ef870, 0xc000063d88)
/usr/local/go/src/runtime/cgocall.go:157 +0x4b fp=0xc000063d60 sp=0xc000063d28 pc=0x40ab4b
kmesh.net/kmesh/pkg/cache/v2/maps._Cfunc_cluster__cluster__get_packed_size(0x39c1580)
_cgo_gotypes.go:570 +0x48 fp=0xc000063d88 sp=0xc000063d60 pc=0x74c748
kmesh.net/kmesh/pkg/cache/v2/maps.clusterToGolang.func1(0x39c1580)
/home/wcy/code/github/kmesh/pkg/cache/v2/maps/cluster.go:36 +0x34 fp=0xc000063db8 sp=0xc000063d88 pc=0x74d6d4
kmesh.net/kmesh/pkg/cache/v2/maps.clusterToGolang(0xc000780ba0, 0x39c1580)
/home/wcy/code/github/kmesh/pkg/cache/v2/maps/cluster.go:36 +0x25 fp=0xc000063e00 sp=0xc000063db8 pc=0x74d545
kmesh.net/kmesh/pkg/cache/v2/maps.ClusterLookup({0x1c522b8, 0xd}, 0xc000780ba0)
/home/wcy/code/github/kmesh/pkg/cache/v2/maps/cluster.go:74 +0xc5 fp=0xc000063ec8 sp=0xc000063e00 pc=0x74d965
kmesh.net/kmesh/pkg/cache/v2.TestClusterLookUp(0xc000439380)
/home/wcy/code/github/kmesh/pkg/cache/v2/cluster_test.go:52 +0x1a8 fp=0xc000063f70 sp=0xc000063ec8 pc=0x17e8ac8
testing.tRunner(0xc000439380, 0x1d63918)
/usr/local/go/src/testing/testing.go:1689 +0xfb fp=0xc000063fc0 sp=0xc000063f70 pc=0x54377b
testing.(*T).Run.gowrap1()
/usr/local/go/src/testing/testing.go:1742 +0x25 fp=0xc000063fe0 sp=0xc000063fc0 pc=0x5447a5
runtime.goexit({})
/usr/local/go/src/runtime/asm_amd64.s:1695 +0x1 fp=0xc000063fe8 sp=0xc000063fe0 pc=0x47c5c1
created by testing.(*T).Run in goroutine 1
/usr/local/go/src/testing/testing.go:1742 +0x390
from kmesh.
If outter_index
starts from 1, this problem can be solved. The valid_field_value
check is still required in the lookup process. The detailed reason will be described in the PR later.
// alloc_outter_map_entry
- for (i = 0; i < MAX_OUTTER_MAP_ENTRIES; i++) {
+ for (i = 1; i < MAX_OUTTER_MAP_ENTRIES; i++) {
from kmesh.
Related Issues (20)
- e2e test hangs HOT 2
- Unexpected outbound accesslog HOT 3
- Panic with istio 1.24-alpha.96593644e05baa5c1b6aaab3647b2d9335a23942 HOT 3
- Headless service support
- "/debug/bpf/*" should output human-readable, real bpf information HOT 4
- Kmesh cli tool
- Add a configuration option to start accesslog HOT 1
- Can't use traffic mirroring capabilities of Kmesh HOT 1
- Kmesh-build image should be public HOT 2
- Redundant delete in update? HOT 1
- Memory Leak in /bpf/deserialization_to_bpf_map/deserialization_to_bpf_map.c HOT 1
- flaky of TestBookinfo HOT 1
- Stop duplicate logs into `/var/run/kmesh/daemon.log`
- `make gen` failed on arm64. HOT 2
- Add helm push github action HOT 2
- Unexpected error from test `unmount /mnt/kmesh_cgroup2 error: no such file or directory` HOT 1
- [E2E Enhancement] ServiceEntry related cases HOT 1
- [E2E Enhancement] Bypass related test cases
- Add copyright checker
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kmesh.