Skip to content

dutagent config validation crash #290

@AtomicFS

Description

@AtomicFS

Describe the bug
When running dutagent --check-config -c <PATH_TO_CONFIG>, the program crashes with panic on valid config, if GPIO module is used.

When running against non-GPIO config or invalid config, it exists properly as expected.

Expected behavior
Just run validation and exit. Exactly as described in the help:

Only validate the provided DUT configuration, not starting the service

Version
latest main (commit 268bb80)

Steps to reproduce

  • Run dutagent --check-config -c <PATH_TO_VALID_CONFIG>
    For example:
  • Run dutagent --check-config -c pkg/module/gpio/gpio-example-cfg.yml

Involved Components (please complete / adapt the following information):

  • dutagent running locally

DUT Agent YAML Configuration
Any valid config

I have used:

---
version: 0
devices:
  fwci-dutctl-tester:
    desc: "A fwci dutctl tester"
    cmds:
      power:
        desc: "Power switch"
        uses:
          - module: gpio-switch
            main: true
            with:
              pin: 26
              initial: off
      serial:
        desc: |
          Basic demo of the Serial module: After the DUT is powered on, use Serial
          as the main module to wait for magic strings in the DUT's boot log.
        uses:
          - module: serial
            main: true
            with:
              port: /home/oscar/ttyS2
              baudrate: 115200

Additional context
It outputs Configuration is valid and then crashes.

2026/03/03 13:31:44 Configuration is valid
2026/03/03 13:31:44 GRACEFUL SHUTDOWN: De-init modules
2026/03/03 13:31:44 gpio.Switch module: Deinit called
2026/03/03 13:31:44 Recovered from panic: runtime error: invalid memory address or nil pointer dereference
2026/03/03 13:31:44 GRACEFUL SHUTDOWN: De-init modules
2026/03/03 13:31:44 gpio.Switch module: Deinit called
panic: runtime error: invalid memory address or nil pointer dereference [recovered, repanicked]
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x94a55b]

goroutine 1 [running]:
github.com/BlindspotSoftware/dutctl/pkg/module/gpio.(*Switch).Deinit(0x31b463b29260)
	.../dutctl/pkg/module/gpio/gpio.go:261 +0x7b
github.com/BlindspotSoftware/dutctl/internal/dutagent.Deinit(0x31b463be5c80)
	.../dutctl/internal/dutagent/init.go:84 +0x23d
main.(*agent).cleanup(0x31b463b71810, 0x1)
	.../dutctl/cmds/dutagent/dutagent.go:100 +0x31
main.(*agent).start.func1()
	.../dutctl/cmds/dutagent/dutagent.go:244 +0x98
panic({0xb6ab80?, 0x12d9d40?})
	/usr/lib/go/src/runtime/panic.go:860 +0x13a
github.com/BlindspotSoftware/dutctl/pkg/module/gpio.(*Switch).Deinit(0x31b463b29260)
	.../dutctl/pkg/module/gpio/gpio.go:261 +0x7b
github.com/BlindspotSoftware/dutctl/internal/dutagent.Deinit(0x31b463be5c80)
	.../dutctl/internal/dutagent/init.go:84 +0x23d
main.(*agent).cleanup(0x31b463b71810, 0x0)
	.../dutctl/cmds/dutagent/dutagent.go:100 +0x31
main.(*agent).start(0x31b463b71810)
	.../dutctl/cmds/dutagent/dutagent.go:258 +0x1e9
main.main()
	.../dutctl/cmds/dutagent/dutagent.go:298 +0x45

Suggestions

  • you should run dutagent --check-config -c on all of the example config files as part of testing
  • you should use the same code that does config validation on startup as the one that runs when --check-config is used (I actually do not know how it is done internally right now)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions