Skip to content

Panic when platform of referenced tool command pattern not installed #2042

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

Closed
3 tasks done
per1234 opened this issue Jan 23, 2023 · 0 comments · Fixed by #2211
Closed
3 tasks done

Panic when platform of referenced tool command pattern not installed #2042

per1234 opened this issue Jan 23, 2023 · 0 comments · Fixed by #2211
Assignees
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@per1234
Copy link
Contributor

per1234 commented Jan 23, 2023

Describe the problem

Arduino boards platforms can reference resources from other platforms. This introduces a dependency on the referenced platform. Arduino CLI does not support automatic installation of these dependencies along with the dependent platform, so the user must handle the installation, which they don't always do.

If the platform for a referenced tool command pattern is not installed, Arduino CLI panics when running an operation that uses the tool.

🐛 Arduino CLI does not clearly communicate the cause of the error to the user.

To reproduce

$ arduino-cli version
arduino-cli.exe  Version: git-snapshot Commit: a58d5adb Date: 2023-01-23T04:39:11Z

$ export ARDUINO_DIRECTORIES_DATA="/tmp/foo-data" # Use a throwaway directories.data for the demo.

$ arduino-cli core install arduino:[email protected]

[...]

$ echo "uno.upload.tool.default=foo:bar" >> "${ARDUINO_DIRECTORIES_DATA}/packages/arduino/hardware/avr/1.8.6/boards.txt" # Simulate reference of missing platform.

$ arduino-cli sketch new "/tmp/FooSketch"
Sketch created in: C:\Users\per\AppData\Local\Temp\FooSketch

$ arduino-cli compile --fqbn arduino:avr:uno --upload "/tmp/FooSketch"  # Run command that depends on referenced tool.
Sketch uses 444 bytes (1%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x30 pc=0x122ab71]

goroutine 1 [running]:
github.com/arduino/arduino-cli/arduino/cores/packagemanager.(*Explorer).GetInstalledPlatformRelease(0xc005e2fb00, 0xc0003b89c0?)
        E:/git/arduino-cli/arduino/cores/packagemanager/package_manager.go:462 +0x31
github.com/arduino/arduino-cli/commands/upload.runProgramAction(0xc005e2fb00, 0x0?, {0x0, 0x0}, {0x0, 0x0}, {0xc00011e0a0, 0xf}, 0xc000e58f50, {0x0, ...}, ...)
        E:/git/arduino-cli/commands/upload/upload.go:273 +0x91e
github.com/arduino/arduino-cli/commands/upload.Upload({0x1e8b9c0?, 0x0?}, 0xc00046a960, {0x18872e0, 0xc00011d398}, {0x18872e0, 0xc00011d3b0})
        E:/git/arduino-cli/commands/upload/upload.go:143 +0x445
github.com/arduino/arduino-cli/internal/cli/compile.runCompileCommand(0xc00038a280?, {0xc00026bb40, 0x1, 0x4?})
        E:/git/arduino-cli/internal/cli/compile/compile.go:257 +0xedb
github.com/spf13/cobra.(*Command).execute(0xc00038a280, {0xc00026bb00, 0x4, 0x4})
        C:/Users/per/go/pkg/mod/github.com/spf13/[email protected]/command.go:860 +0x663
github.com/spf13/cobra.(*Command).ExecuteC(0xc0002d2a00)
        C:/Users/per/go/pkg/mod/github.com/spf13/[email protected]/command.go:974 +0x3bd
github.com/spf13/cobra.(*Command).Execute(...)
        C:/Users/per/go/pkg/mod/github.com/spf13/[email protected]/command.go:902
main.main()
        E:/git/arduino-cli/main.go:31 +0x77

🐛

Expected behavior

Arduino CLI only panics on unexpected (i.e., caused by a bug in the Arduino CLI codebase) failures. Any failure that can result from normal (even if incorrect) usage should be handled gracefully and the problem clearly communicated to the user.

Arduino CLI version

a58d5ad

Operating system

  • Windows
  • macOS

Operating system version

  • Windows 11
  • macOS Ventura

Additional context

For the sake of simplicity, I simulated the required conditions in the demo by modifying the arduino:avr platform. For a real world occurrence, do an upload using version 0.1.5 of this platform without the sandeepmistry:nRF5 platform installed.


Originally reported by @ljunquera at https://forum.arduino.cc/t/no-connections-established/1048343/19

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the nightly build
  • My report contains all necessary details
@per1234 per1234 added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project labels Jan 23, 2023
@cmaglie cmaglie assigned cmaglie and unassigned Bikappa Jun 9, 2023
@cmaglie cmaglie added this to the Arduino CLI 0.34.0 milestone Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants