Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running function on different Cluster results in SIGSEGV #236

Open
schaschko opened this issue Feb 4, 2025 · 3 comments
Open

Running function on different Cluster results in SIGSEGV #236

schaschko opened this issue Feb 4, 2025 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@schaschko
Copy link

I have two Clusters where I'm running exactly the same CRDs, Crossplane Version, ...

function-kcl is 0.11.1

In the first Cluster on Machine 1 everything works as expected. Running exactly the same function on a different Cluster/Machine but with the same Cluster-Setup results in:

INFO    fn/fn.go:38    Running Function    {"tag": ""}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0x1b55f10]

goroutine 51 [running]:
kcl-lang.io/lib/go/path.HomeDir()
    /go/pkg/mod/kcl-lang.io/[email protected]/go/path/home.go:80 +0x30
kcl-lang.io/lib/go/path.CacheHome()
    /go/pkg/mod/kcl-lang.io/[email protected]/go/path/lazypath_unix.go:24 +0x13
kcl-lang.io/lib/go/native.libPath(...)
    /go/pkg/mod/kcl-lang.io/[email protected]/go/native/loader.go:15
kcl-lang.io/lib/go/native.loadServiceNativeLib()
    /go/pkg/mod/kcl-lang.io/[email protected]/go/native/loader.go:29 +0x18
kcl-lang.io/lib/go/native.initClient.func1()
    /go/pkg/mod/kcl-lang.io/[email protected]/go/native/client.go:39 +0x25
sync.(*Once).doSlow(0x411105?, 0x30?)
    /usr/local/go/src/sync/once.go:76 +0xb4
sync.(*Once).Do(...)
    /usr/local/go/src/sync/once.go:67
kcl-lang.io/lib/go/native.initClient(0xc0006d6890?)
    /go/pkg/mod/kcl-lang.io/[email protected]/go/native/client.go:38 +0x3a
kcl-lang.io/lib/go/native.NewNativeServiceClientWithPluginAgent(...)
    /go/pkg/mod/kcl-lang.io/[email protected]/go/native/client.go:62
kcl-lang.io/lib/go/native.NewNativeServiceClient(...)
    /go/pkg/mod/kcl-lang.io/[email protected]/go/native/client.go:58
kcl-lang.io/kcl-go/pkg/kcl.Service(...)
    /go/pkg/mod/kcl-lang.io/[email protected]/pkg/kcl/service.go:10
kcl-lang.io/kcl-go/pkg/kcl.runWithHooks({0xc0006d6890, 0x0, 0x0}, {0x51eb100, 0x1, 0x1}, {0xc0006d6960, 0x1, 0x1})
    /go/pkg/mod/kcl-lang.io/[email protected]/pkg/kcl/api.go:436 +0x15f
kcl-lang.io/kcl-go/pkg/kcl.run(...)
    /go/pkg/mod/kcl-lang.io/[email protected]/pkg/kcl/api.go:445
kcl-lang.io/kcl-go/pkg/kcl.RunWithOpts({0xc0006d6960?, 0xc000734e40?, 0x0?})
    /go/pkg/mod/kcl-lang.io/[email protected]/pkg/kcl/api.go:372 +0x45
kcl-lang.io/kpm/pkg/client.(*KpmClient).Run.func1(0xc000734e40)
    /go/pkg/mod/kcl-lang.io/[email protected]/pkg/client/run.go:666 +0x3aa
kcl-lang.io/kpm/pkg/visitor.(*VirtualPkgVisitor).Visit(0x0?, 0x0?, 0xc000ac7e90)
    /go/pkg/mod/kcl-lang.io/[email protected]/pkg/visitor/visitor.go:95 +0x3a8
kcl-lang.io/kpm/pkg/client.(*KpmClient).Run(0xc000b82500, {0xc0006d6e80, 0xe, 0xc0005da0f0?})
    /go/pkg/mod/kcl-lang.io/[email protected]/pkg/client/run.go:641 +0x20d
kcl-lang.io/cli/pkg/options.(*RunOptions).Run(0xc0007f5900)
    /go/pkg/mod/kcl-lang.io/[email protected]/pkg/options/run.go:154 +0xa17
kcl-lang.io/krm-kcl/pkg/edit.RunKCLWithConfig({0xc0004facc0?, 0x1bcab4d?}, {0xc0008d1200?, 0x5?}, {0x0, 0x0, 0x0}, 0xc0009bff00, 0xc0007f55a0, {0x527a3e0, ...})
    /go/pkg/mod/kcl-lang.io/[email protected]/pkg/edit/bootstrap.go:90 +0x2fb
kcl-lang.io/krm-kcl/pkg/edit.(*SimpleTransformer).Transform(0xc0006d71c0, {0xc0007cab20?, 0x26af861?, 0x21?})
    /go/pkg/mod/kcl-lang.io/[email protected]/pkg/edit/transformer.go:54 +0xc5
kcl-lang.io/krm-kcl/pkg/config.(*KCLRun).Transform(0xc0007f5540, {0xc0007ca898, 0x1, 0x0?}, 0xc0004facc0)
    /go/pkg/mod/kcl-lang.io/[email protected]/pkg/config/config.go:211 +0x745
kcl-lang.io/krm-kcl/pkg/kio.Filter.Filter({0xc0007a1ea0}, {0xc0007ca898, 0x1, 0x1})
    /go/pkg/mod/kcl-lang.io/[email protected]/pkg/kio/filter.go:33 +0xfa
sigs.k8s.io/kustomize/kyaml/kio.Pipeline.ExecuteWithCallback({{0xc0006d7730, 0x1, 0x1}, {0xc0006d7720, 0x1, 0x1}, {0xc0006d7710, 0x1, 0x1}, 0x0}, ...)
    /go/pkg/mod/sigs.k8s.io/kustomize/[email protected]/kio/kio.go:137 +0x25d
sigs.k8s.io/kustomize/kyaml/kio.Pipeline.Execute({{0xc0006d7730, 0x1, 0x1}, {0xc0006d7720, 0x1, 0x1}, {0xc0006d7710, 0x1, 0x1}, 0x0})
    /go/pkg/mod/sigs.k8s.io/kustomize/[email protected]/kio/kio.go:104 +0x3a
main.(*Function).RunFunction(0xc0000616f0, {0x2349460?, 0xc0000928a8?}, 0xc0009c3980)
    /fn/fn.go:159 +0x1378
github.com/crossplane/function-sdk-go/proto/v1._FunctionRunnerService_RunFunction_Handler({0x2349460, 0xc0000616f0}, {0x2cbbfb0, 0xc000a68e70}, 0xc0007ce000, 0x0)
    /go/pkg/mod/github.com/crossplane/[email protected]/proto/v1/run_function_grpc.pb.go:116 +0x1a6
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000778c00, {0x2cbbfb0, 0xc000a68e10}, 0xc0009c3920, 0xc0007bda70, 0x51edf60, 0x0)
    /go/pkg/mod/google.golang.org/[email protected]/server.go:1392 +0xfc3
google.golang.org/grpc.(*Server).handleStream(0xc000778c00, {0x2cbc9c8, 0xc0006781a0}, 0xc0009c3920)
    /go/pkg/mod/google.golang.org/[email protected]/server.go:1802 +0xbaa
google.golang.org/grpc.(*Server).serveStreams.func2.1()
    /go/pkg/mod/google.golang.org/[email protected]/server.go:1030 +0x7f
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 15
    /go/pkg/mod/google.golang.org/[email protected]/server.go:1041 +0x125
stream closed EOF for crossplane-system/function-kcl-0fb8603f18f8-6964d748f8-bq2l2 (package-runtime)

I know that is more of an open question. I have already enabled the debug flag, but this gives me not any useful info. Maybe you can point me in the right direction, would be greatly appreciated :)

@Peefy Peefy added the bug Something isn't working label Feb 5, 2025
@schaschko
Copy link
Author

Problem was, the HOME env var in function-kcl was not getting set by default on the second Cluster. If setting HOME e.g. via DeploymentRuntimeConfig everything worked as expected. Interesting enough, HOME was set automatically on the first machine/cluster. We did not investigate further, but it seems to have to do with the K8s environment the function runs in.

@zong-zhe
Copy link
Collaborator

zong-zhe commented Feb 6, 2025

Hi @schaschko 😄

Thanks very much for your feedback. I already know about this issue and will find and fix it soon. Thank you again. 👍

@zong-zhe
Copy link
Collaborator

zong-zhe commented Feb 6, 2025

I create an issue to track kcl-lang/kpm#595

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants