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

kcl run --debug crashes to unrecoverable state #1333

Closed
excalq opened this issue May 18, 2024 · 2 comments
Closed

kcl run --debug crashes to unrecoverable state #1333

excalq opened this issue May 18, 2024 · 2 comments
Labels
bug Something isn't working CLI

Comments

@excalq
Copy link

excalq commented May 18, 2024

Bug Report

Hello, this is an odd situation, so I'm posting this issue in case others encounter it. I'm unsure if it's reproducible, but I'll attempt to assist with complete information.

1. Minimal reproduce step (Required)

  1. I ran kcl run some_script.k --debug, from a vscode ZSH terminal (in MacOS). I don't actually know what --debug does, or how to use it, but that's a separate topic.

It crashed with the following error:

Init kcl runtime failed, path:  /Users/arthur/Library/Preferences
Tip: Have you used a binary version of KCL in your PATH that is not consistent with the KCL Go SDK? You can upgrade or reduce the KCL version or delete the KCL in your PATH
If not, you can run `rm -r /Users/arthur/Library/Preferences/bin` to fix this issue
panic: unexpected EOF

goroutine 1 [running]:
kcl-lang.io/kcl-go/pkg/runtime.initRuntime(0x0?)
        /home/runner/go/pkg/mod/kcl-lang.io/kcl-go@v0.8.6/pkg/runtime/init.go:62 +0x3b8
kcl-lang.io/kcl-go/pkg/runtime.GetRuntime.func1()
        /home/runner/go/pkg/mod/kcl-lang.io/kcl-go@v0.8.6/pkg/runtime/init.go:26 +0x20
sync.(*Once).doSlow(0x30?, 0x14000600900?)
        /opt/hostedtoolcache/go/1.21.9/x64/src/sync/once.go:74 +0x100
sync.(*Once).Do(...)
        /opt/hostedtoolcache/go/1.21.9/x64/src/sync/once.go:65
kcl-lang.io/kcl-go/pkg/runtime.GetRuntime()
        /home/runner/go/pkg/mod/kcl-lang.io/kcl-go@v0.8.6/pkg/runtime/init.go:26 +0x40
kcl-lang.io/kcl-go/pkg/service.NewKclvmServiceClient()
        /home/runner/go/pkg/mod/kcl-lang.io/kcl-go@v0.8.6/pkg/service/client_kclvm_service.go:21 +0x1c
kcl-lang.io/kcl-go/pkg/kcl.runWithHooks({0x14000f2f7f8, 0x0, 0x0}, {0x108a39be0, 0x1, 0x1}, {0x14000f2fa38, 0x1, 0x1})
        /home/runner/go/pkg/mod/kcl-lang.io/kcl-go@v0.8.6/pkg/kcl/api.go:477 +0xf4
kcl-lang.io/kcl-go/pkg/kcl.run(...)
        /home/runner/go/pkg/mod/kcl-lang.io/kcl-go@v0.8.6/pkg/kcl/api.go:486
kcl-lang.io/kcl-go/pkg/kcl.RunWithOpts({0x14000f2fa38?, 0x14000f2fa38?, 0x1?})
        /home/runner/go/pkg/mod/kcl-lang.io/kcl-go@v0.8.6/pkg/kcl/api.go:373 +0x50
kcl-lang.io/kpm/pkg/api.RunWithOpt(0x14000292800)
        /home/runner/go/pkg/mod/kcl-lang.io/kpm@v0.8.6/pkg/api/kpm_run.go:89 +0x2d8
kcl-lang.io/cli/pkg/options.(*RunOptions).Run(0x14000676540)
        /home/runner/work/cli/cli/pkg/options/run.go:137 +0x19c
kcl-lang.io/cli/cmd/kcl/commands.NewRunCmd.func1(0x14000988c00?, {0x14000987de0?, 0x4?, 0x101f3dd5a?})
        /home/runner/work/cli/cli/cmd/kcl/commands/run.go:49 +0x6c
github.com/spf13/cobra.(*Command).execute(0x140008fe300, {0x14000987dc0, 0x2, 0x2})
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:983 +0x840
github.com/spf13/cobra.(*Command).ExecuteC(0x140008fe000)
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1115 +0x344
github.com/spf13/cobra.(*Command).Execute(...)
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1039
main.main()
        /home/runner/work/cli/cli/cmd/kcl/main.go:14 +0x20

Possibly worth noting, I had kcl play (the Playground server) running in a different terminal.

  1. Any further invocation of kcl run CLI commands always hang indefinitely, with no output.

(kcl version or kcl run --help do work as expected.)

  1. kcl play confirms that KCL is still in "debug" mode. It's unclear how I'd end debug mode, and restore normal functionality.

The play web UI does launch, but shows Error communicating with remote server.

kcl play
[Info] Playground listens at :80
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.

[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:   export GIN_MODE=release
 - using code:  gin.SetMode(gin.ReleaseMode)

[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.

[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:   export GIN_MODE=release
 - using code:  gin.SetMode(gin.ReleaseMode`
  1. Running ps auux | grep kcl reveals 30 kclvm_cli processes:
USER               PID  %CPU %MEM      VSZ    RSS   TT  STAT STARTED      TIME COMMAND
arthur           38591   0.0  0.0 410060096     16 s091  UE   10:27AM   0:00.00 kclvm_cli server

The UE state is "uninterruptible wait" and "trying to exit". This is likely due to my issuing pkill and pkill -9, both of which were unsuccessful at killing the processes.

I lost the terminal scrollback history showing the state before pkill.

It appears as though rebooting is my only option to resume use of KCL at this point.

2. What did you expect to see? (Required)

KCL doesn't break, recovers, or is killable, with a new invocation restarting it.

Or documentation about how to recover/restart.

3. What did you see instead (Required)

Noted in repro steps above.

4. What is your KCL components version? (Required)

kcl version
0.8.7-darwin-arm64
@Peefy Peefy added bug Something isn't working CLI labels May 20, 2024
@Peefy
Copy link
Contributor

Peefy commented May 20, 2024

Thanks for the feedback. Here's a potential fix related issue kcl-lang/lib#74 and it's released in KCL v0.9.0-alpha.1

@Peefy
Copy link
Contributor

Peefy commented Jun 3, 2024

Fixed and Released in KCL v0.9.0-beta.1

@Peefy Peefy closed this as completed Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working CLI
Projects
None yet
Development

No branches or pull requests

2 participants