Skip to content

Commit

Permalink
Resolves #432 - Fixes deadlock when zero generated as an example value (
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-r-west authored Jan 7, 2024
1 parent fd18a23 commit e6eb696
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,9 @@ go fmt "./..."
echo "Adding changed files back to git"
git diff --cached --name-only --diff-filter=ACM | grep -E "\.(go)$" | xargs git add
```

### Generating Go Routine Dumps

You can send a `SIGQUIT` to `epcc` to get it to generate a go routine dump, this can be useful for debugging deadlocks and other performance issues.

On Linux and maybe other OS, you can use CTRL+\ to send a `SIGQUIT` to the process.
28 changes: 27 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/thediveo/enumflag"
"os"
"os/signal"
"runtime"
"syscall"
"time"

Expand Down Expand Up @@ -61,6 +62,8 @@ var profileNameFromCommandLine = ""

func InitializeCmd() {

DumpTraces()

os.Args = misc.AddImplicitDoubleDash(os.Args)
if len(os.Args) > 1 && os.Args[1] == "__complete" {
DisableLongOutput = true
Expand All @@ -76,7 +79,10 @@ func InitializeCmd() {
}

applyLogLevelEarlyDetectionHack()
log.Tracef("Root Command Building In Progress")

initRunbookCommands()
log.Tracef("Runbooks initialized")
RootCmd.AddCommand(
cmCommand,
docsCommand,
Expand All @@ -91,10 +97,17 @@ func InitializeCmd() {
runbookGlobalCmd,
)

log.Tracef("Building Create Commands")
NewCreateCommand(RootCmd)
log.Tracef("Building Delete Commands")
NewDeleteCommand(RootCmd)
log.Tracef("Building Get Commands")
NewGetCommand(RootCmd)

log.Tracef("Building Update Commands")
NewUpdateCommand(RootCmd)

log.Tracef("Building Delete All Commands")
NewDeleteAllCommand(RootCmd)

Logs.AddCommand(LogsList, LogsShow, LogsClear)
Expand Down Expand Up @@ -134,6 +147,7 @@ func InitializeCmd() {
logoutCmd.AddCommand(LogoutHeaders)

NewHeadersCommand(RootCmd)
log.Tracef("Root Command Constructed")
}

// If there is a log level argument, we will set it much earlier on a dummy command
Expand Down Expand Up @@ -225,7 +239,6 @@ Environment Variables
}

func Execute() {

sigs := make(chan os.Signal, 1)
normalShutdown := make(chan bool, 1)
shutdownHandlerDone := make(chan bool, 1)
Expand Down Expand Up @@ -278,6 +291,19 @@ func Execute() {
}
}

func DumpTraces() {
go func() {
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGQUIT)
buf := make([]byte, 1<<20)
for {
<-sigs
stacklen := runtime.Stack(buf, true)
fmt.Printf("=== received SIGQUIT ===\n*** goroutine dump...\n%s\n*** end\n", buf[:stacklen])
}
}()
}

func initConfig() {

envProfileName, ok := os.LookupEnv("EPCC_PROFILE")
Expand Down
2 changes: 2 additions & 0 deletions external/autofill/autofill.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func GetJsonArrayForResource(r *resources.Resource) []string {
for true {
v := result[0].Uint()
if v == 0 && rejectZero {
result = method.Call([]reflect.Value{})
continue
}
arg = strconv.FormatUint(v, 10)
Expand All @@ -56,6 +57,7 @@ func GetJsonArrayForResource(r *resources.Resource) []string {
for true {
v := result[0].Int()
if v == 0 && rejectZero {
result = method.Call([]reflect.Value{})
continue
}
arg = strconv.FormatInt(v, 10)
Expand Down

0 comments on commit e6eb696

Please sign in to comment.