Skip to content

panic: runtime error: invalid memory address or nil pointer dereference when listing firmwares #141

Closed
@kittaakos

Description

@kittaakos

Describe the problem

This happened in the Arduino IDE. See the original comment here.

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x14bd30e]

goroutine 1 [running]:
github.com/arduino/arduino-fwuploader/cli/firmware.list(0x0, 0x0)
	/home/runner/work/arduino-fwuploader/arduino-fwuploader/cli/firmware/list.go:66 +0x4e
github.com/arduino/arduino-fwuploader/cli/firmware.newListCommand.func1(0xc000492500, 0xc000158ea0, 0x0, 0x2)
	/home/runner/work/arduino-fwuploader/arduino-fwuploader/cli/firmware/list.go:42 +0x39
github.com/spf13/cobra.(*Command).execute(0xc000492500, 0xc000158e80, 0x2, 0x2, 0xc000492500, 0xc000158e80)
	/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:856 +0x2c2
github.com/spf13/cobra.(*Command).ExecuteC(0xc0001eb900, 0x0, 0x0, 0x1501260)
	/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:960 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
	/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:897
main.main()
	/home/runner/work/arduino-fwuploader/arduino-fwuploader/main.go:35 +0x3c Error: Error executing "/Users/a.kitta/dev/git/arduino-ide/arduino-ide-extension/build/arduino-fwuploader" firmware list --format json: unexpected end of JSON input
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x14bd30e]

goroutine 1 [running]:
github.com/arduino/arduino-fwuploader/cli/firmware.list(0x0, 0x0)
	/home/runner/work/arduino-fwuploader/arduino-fwuploader/cli/firmware/list.go:66 +0x4e
github.com/arduino/arduino-fwuploader/cli/firmware.newListCommand.func1(0xc000492500, 0xc000158ea0, 0x0, 0x2)
	/home/runner/work/arduino-fwuploader/arduino-fwuploader/cli/firmware/list.go:42 +0x39
github.com/spf13/cobra.(*Command).execute(0xc000492500, 0xc000158e80, 0x2, 0x2, 0xc000492500, 0xc000158e80)
	/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:856 +0x2c2
github.com/spf13/cobra.(*Command).ExecuteC(0xc0001eb900, 0x0, 0x0, 0x1501260)
	/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:960 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
	/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:897
main.main()
	/home/runner/work/arduino-fwuploader/arduino-fwuploader/main.go:35 +0x3c
    at ChildProcess.<anonymous> (/Users/a.kitta/dev/git/arduino-ide/arduino-ide-extension/lib/node/exec-util.js:53:31)
    at ChildProcess.emit (node:events:394:28)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
    at Process.callbackTrampoline (node:internal/async_hooks:130:17)

To reproduce

I do not have a straightforward way to reproduce the defect, but as noted here, the firmware updater returns with an invalid JSON occasionally.

Click to expand the invalid JSON
[
  {
    "board_name": "Arduino MKR1000",
    "board_fqbn": "arduino:samd:mkr1000",
    "module": "WINC1500",
    "firmware_version": "19.4.4",
    "Latest": false
  },
  {
    "board_name": "Arduino MKR1000",
    "board_fqbn": "arduino:samd:mkr1000",
    "module": "WINC1500",
    "firmware_version": "19.5.2",
    "Latest": false
  },
  {
    "board_name": "Arduino MKR1000",
    "board_fqbn": "arduino:samd:mkr1000",
    "module": "WINC1500",
    "firmware_version": "19.5.4",
    "Latest": false
  },
  {
    "board_name": "Arduino MKR1000",
    "board_fqbn": "arduino:samd:mkr1000",
    "module": "WINC1500",
    "firmware_version": "19.6.1",
    "Latest": true
  },
  {
    "board_name": "Arduino MKR WiFi 1010",
    "board_fqbn": "arduino:samd:mkrwifi1010",
    "module": "NINA",
    "firmware_version": "1.0.0",
    "Latest": false
  },
  {
    "board_name": "Arduino MKR WiFi 1010",
    "board_fqbn": "arduino:samd:mkrwifi1010",
    "module": "NINA",
    "firmware_version": "1.1.0",
    "Latest": false
  },
  {
    "board_name": "Arduino MKR WiFi 1010",
    "board_fqbn": "arduino:samd:mkrwifi1010",
    "module": "NINA",
    "firmware_version": "1.2.1",
    "Latest": false
  },
  {
    "board_name": "Arduino MKR WiFi 1010",
    "board_fqbn": "arduino:samd:mkrwifi1010",
    "module": "NINA",
    "firmware_version": "1.2.2",
    "Latest": false
  },
  {
    "board_name": "Arduino MKR WiFi 1010",
    "board_fqbn": "arduino:samd:mkrwifi1010",
    "module": "NINA",
    "firmware_version": "1.2.3",
    "Latest": false
  },
  {
    "board_name": "Arduino MKR WiFi 1010",
    "board_fqbn": "arduino:samd:mkrwifi1010",
    "module": "NINA",
    "firmware_version": "1.2.4",
    "Latest": false
  },
  {
    "board_name": "Arduino MKR WiFi 1010",
    "board_fqbn": "arduino:samd:mkrwifi1010",
    "module": "NINA",
    "firmware_version": "1.3.0",
    "Latest": false
  },
  {
    "board_name": "Arduino MKR WiFi 1010",
    "board_fqbn": "arduino:samd:mkrwifi1010",
    "module": "NINA",
    "firmware_version": "1.4.0",
    "Latest": false
  },
  {
    "board_name": "Arduino MKR WiFi 1010",
    "board_fqbn": "arduino:samd:mkrwifi1010",
    "module": "NINA",
    "firmware_version": "1.4.1",
    "Latest": false
  },
  {
    "board_name": "Arduino MKR WiFi 1010",
    "board_fqbn": "arduino:samd:mkrwifi1010",
    "module": "NINA",
    "firmware_version": "1.4.2",
    "Latest": false
  },
  {
    "board_name": "Arduino MKR WiFi 1010",
    "board_fqbn": "arduino:samd:mkrwifi1010",
    "module": "NINA",
    "firmware_version": "1.4.3",
    "Latest": false
  },
  {
    "board_name": "Arduino MKR WiFi 1010",
    "board_fqbn": "arduino:samd:mkrwifi1010",
    "module": "NINA",
    "firmware_version": "1.4.4",
    "Latest": false
  },
  {
    "board_name": "Arduino MKR WiFi 1010",
    "board_fqbn": "arduino:samd:mkrwifi1010",
    "module": "NINA",
    "firmware_version": "1.4.5",
    "Latest": false
  },
  {
    "board_name": "Arduino MKR WiFi 1010",
    "board_fqbn": "arduino:samd:mkrwifi1010",
    "module": "NINA",
    "firmware_version": "1.4.6",
    "Latest": false
  },
  {
    "board_name": "Arduino MKR WiFi 1010",
    "board_fqbn": "arduino:samd:mkrwifi1010",
    "module": "NINA",
    "firmware_version": "1.4.7",
    "Latest": false
  },
  {
    "board_name": "Arduino MKR WiFi 1010",
    "board_fqbn": "arduino:samd:mkrwifi1010",
    "module": "NINA",
    "firmware_version": "1.4.8",
    "Latest": true
  },
  {
    "board_name": "Arduino NANO 33 IoT",
    "board_fqbn": "arduino:samd:nano_33_iot",
    "module": "NINA",
    "firmware_version": "1.0.0",
    "Latest": false
  },
  {
    "board_name": "Arduino NANO 33 IoT",
    "board_fqbn": "arduino:samd:nano_33_iot",
    "module": "NINA",
    "firmware_version": "1.1.0",
    "Latest": false
  },
  {
    "board_name": "Arduino NANO 33 IoT",
    "board_fqbn": "arduino:samd:nano_33_iot",
    "module": "NINA",
    "firmware_version": "1.2.1",
    "Latest": false
  },
  {
    "board_name": "Arduino NANO 33 IoT",
    "board_fqbn": "arduino:samd:nano_33_iot",
    "module": "NINA",
    "firmware_version": "1.2.2",
    "Latest": false
  },
  {
    "board_name": "Arduino NANO 33 IoT",
    "board_fqbn": "arduino:samd:nano_33_iot",
    "module": "NINA",
    "firmware_version": "1.2.3",
    "Latest": false
  },
  {
    "board_name": "Arduino NANO 33 IoT",
    "board_fqbn": "arduino:samd:nano_33_iot",
    "module": "NINA",
    "firmware_version": "1.2.4",
    "Latest": false
  },
  {
    "board_name": "Arduino NANO 33 IoT",
    "board_fqbn": "arduino:samd:nano_33_iot",
    "module": "NINA",
    "firmware_version": "1.3.0",
    "Latest": false
  },
  {
    "board_name": "Arduino NANO 33 IoT",
    "board_fqbn": "arduino:samd:nano_33_iot",
    "module": "NINA",
    "firmware_version": "1.4.0",
    "Latest": false
  },
  {
    "board_name": "Arduino NANO 33 IoT",
    "board_fqbn": "arduino:samd:nano_33_iot",
    "module": "NINA",
    "firmware_version": "1.4.1",
    "Latest": false
  },
  {
    "board_name": "Arduino NANO 33 IoT",
    "board_fqbn": "arduino:samd:nano_33_iot",
    "module": "NINA",
    "firmware_version": "1.4.2",
    "Latest": false
  },
  {
    "board_name": "Arduino NANO 33 IoT",
    "board_fqbn": "arduino:samd:nano_33_iot",
    "module": "NINA",
    "firmware_version": "1.4.3",
    "Latest": false
  },
  {
    "board_name": "Arduino NANO 33 IoT",
    "board_fqbn": "arduino:samd:nano_33_iot",
    "module": "NINA",
    "firmware_version": "1.4.4",
    "Latest": false
  },
  {
    "board_name": "Arduino NANO 33 IoT",
    "board_fqbn": "arduino:samd:nano_33_iot",
    "module": "NINA",
    "firmware_version": "1.4.5",
    "Latest": false
  },
  {
    "board_name": "Arduino NANO 33 IoT",
    "board_fqbn": "arduino:samd:nano_33_iot",
    "module": "NINA",
    "firmware_version": "1.4.6",
    "Latest": false
  },
  {
    "board_name": "Arduino NANO 33 IoT",
    "board_fqbn": "arduino:samd:nano_33_iot",
    "module": "NINA",
    "firmware_version": "1.4.7",
    "Latest": false
  },
  {
    "board_name": "Arduino NANO 33 IoT",
    "board_fqbn": "arduino:samd:nano_33_iot",
    "module": "NINA",
    "firmware_version": "1.4.8",
    "Latest": true
  },
  {
    "board_name": "Arduino MKR Vidor 4000",
    "board_fqbn": "arduino:samd:mkrvidor4000",
    "module": "NINA",
    "firmware_version": "1.0.0",
    "Latest": false
  },
  {
    "board_name": "Arduino MKR Vidor 4000",
    "board_fqbn": "arduino:samd:mkrvidor4000",
    "module": "NINA",
    "firmware_version": "1.1.0",
    "Latest": true
  },
  {
    "board_name": "Arduino Uno WiFi Rev2",
    "board_fqbn": "arduino:megaavr:uno2018",
    "module": "NINA",
    "firmware_version": "1.2.1",
    "Latest": false
  },
  {
    "board_name": "Arduino Uno WiFi Rev2",
    "board_fqbn": "arduino:megaavr:uno2018",
    "module": "NINA",
    "firmware_version": "1.2.2",
    "Latest": false
  },
  {
    "board_name": "Arduino Uno WiFi Rev2",
    "board_fqbn": "arduino:megaavr:uno2018",
    "module": "NINA",
    "firmware_version": "1.2.3",
    "Latest": false
  },
  {
    "board_name": "Arduino Uno WiFi Rev2",
    "board_fqbn": "arduino:megaavr:uno2018",
    "module": "NINA",
    "firmware_version": "1.2.4",
    "Latest": false
  },
  {
    "board_name": "Arduino Uno WiFi Rev2",
    "board_fqbn": "arduino:megaavr:uno2018",
    "module": "NINA",
    "firmware_version": "1.3.0",
    "Latest": false
  },
  {
    "board_name": "Arduino Uno WiFi Rev2",
    "board_fqbn": "arduino:megaavr:uno2018",
    "module": "NINA",
    "firmware_version": "1.4.0",
    "Latest": false
  },
  {
    "board_name": "Arduino Uno WiFi Rev2",
    "board_fqbn": "arduino:megaavr:uno2018",
    "module": "NINA",
    "firmware_version": "1.4.1",
    "Latest": false
  },
  {
    "board_name": "Arduino Uno WiFi Rev2",
    "board_fqbn": "arduino:megaavr:uno2018",
    "module": "NINA",
    "firmware_version": "1.4.2",
    "Latest": false
  },
  {
    "board_name": "Arduino Uno WiFi Rev2",
    "board_fqbn": "arduino:megaavr:uno2018",
    "module": "NINA",
    "firmware_version": "1.4.3",
    "Latest": false
  },
  {
    "board_name": "Arduino Uno WiFi Rev2",
    "board_fqbn": "arduino:megaavr:uno2018",
    "module": "NINA",
    "f

Expected behavior

No error.

Arduino Firmware Uploader version

arduino-fwuploader Version: 2.0.0 Commit: eb51bf2 Date: 2021-07-28T16:19:28Z

Operating system

macOS

Operating system version

12.3.1 (21E258)

Additional context

I could not reproduce the bug. The latest and 2.0.0 versions worked when I executed the following command in a terminal.

./arduino-fwuploader firmware list --format json

But it happened multiple times in the IDE. I do not know where the null pointer exception comes from.

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the latest version
  • My report contains all necessary details

Metadata

Metadata

Assignees

Labels

status: waiting for informationMore information must be provided before work can proceedtopic: codeRelated to content of the project itselftype: imperfectionPerceived defect in any part of project

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions