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

loopd: nil-pointer bug when showing subsystems #560

Merged
merged 2 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions loopd/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
const Subsystem = "LOOPD"

var (
logWriter *build.RotatingLogWriter
log btclog.Logger
interceptor signal.Interceptor
)
Expand All @@ -30,7 +29,6 @@ var (
func SetupLoggers(root *build.RotatingLogWriter, intercept signal.Interceptor) {
genLogger := genSubLogger(root, intercept)

logWriter = root
log = build.NewSubLogger(Subsystem, genLogger)
interceptor = intercept

Expand Down
15 changes: 8 additions & 7 deletions loopd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,6 @@ func Run(rpcCfg RPCConfig) error {
os.Exit(0)
}

// Special show command to list supported subsystems and exit.
if config.DebugLevel == "show" {
fmt.Printf("Supported subsystems: %v\n",
logWriter.SupportedSubsystems())
os.Exit(0)
}

// Validate our config before we proceed.
if err := Validate(&config); err != nil {
return err
Expand All @@ -205,6 +198,14 @@ func Run(rpcCfg RPCConfig) error {
logWriter := build.NewRotatingLogWriter()
SetupLoggers(logWriter, shutdownInterceptor)

// Special show command to list supported subsystems and exit.
if config.DebugLevel == "show" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this fix effective because if err := Validate(&config) precedes now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm let me check

Copy link
Contributor Author

@ziggie1984 ziggie1984 Mar 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah so debuglevel validation seems not part and not necessary to validate so it should be fixed, but maybe we clean this code part up a bit, maybe just get rid of the global pointer variable which led to the bug in the first place and do a clean initialization ?

fmt.Printf("Supported subsystems: %v\n",
logWriter.SupportedSubsystems())

os.Exit(0)
}

err = logWriter.InitLogRotator(
filepath.Join(config.LogDir, defaultLogFilename),
config.MaxLogFileSize, config.MaxLogFiles,
Expand Down
Loading