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

arduino-cli board details crashes with external FQBNs #759

Closed
a7hybnj2 opened this issue Jun 24, 2020 · 10 comments
Closed

arduino-cli board details crashes with external FQBNs #759

a7hybnj2 opened this issue Jun 24, 2020 · 10 comments

Comments

@a7hybnj2
Copy link

Bug Report

Current behavior

arduino-cli board details ATTinyCore:avr:attinyx4
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x46b324f]

goroutine 1 [running]:
github.com/arduino/arduino-cli/commands/board.Details(0x4b080a0, 0xc000126008, 0xc000547d60, 0x46bebc7, 0xc000190200, 0xc000589d70)
        /private/tmp/arduino-cli-20200624-55394-jn0e1u/commands/board/details.go:65 +0x4df
github.com/arduino/arduino-cli/cli/board.runDetailsCommand(0xc000168b00, 0xc000119ba0, 0x1, 0x1)
        /private/tmp/arduino-cli-20200624-55394-jn0e1u/cli/board/details.go:57 +0x145
github.com/spf13/cobra.(*Command).execute(0xc000168b00, 0xc000119b80, 0x1, 0x1, 0xc000168b00, 0xc000119b80)
        /Users/a7hybnj2/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:846 +0x29d
github.com/spf13/cobra.(*Command).ExecuteC(0xc000168000, 0x0, 0x0, 0xc00010e058)
        /Users/a7hybnj2/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:950 +0x349
github.com/spf13/cobra.(*Command).Execute(...)
        /Users/a7hybnj2/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:887
main.main()
        /private/tmp/arduino-cli-20200624-55394-jn0e1u/main.go:31 +0x36

Expected behavior

I would like for the command to show me all the available options for the board I am specifying.

Environment

  • CLI version (output of arduino-cli version): arduino-cli Version: HEAD-7541c80 Commit: 7541c80d180106f4370731de45a3ff4cc6709657
  • OS and platform: macOS 10.15.5

Additional Info

arduino-cli board listall
Board Name                    FQBN                         
ATtiny1634 (No bootloader)    ATTinyCore:avr:attiny1634    
ATtiny1634 (Optiboot)         ATTinyCore:avr:attiny1634opti
ATtiny167/87 (Optiboot)       ATTinyCore:avr:attinyx7opti  
ATtiny2313/4313               ATTinyCore:avr:attinyx313    
ATtiny24/44/84                ATTinyCore:avr:attinyx4      
ATtiny25/45/85                ATTinyCore:avr:attinyx5      
ATtiny261/461/861             ATTinyCore:avr:attinyx61     
ATtiny43                      ATTinyCore:avr:attiny43      
ATtiny44/84 (optiboot)        ATTinyCore:avr:attinyx4opti  
ATtiny441/841 (No bootloader) ATTinyCore:avr:attinyx41     
ATtiny441/841 (Optiboot)      ATTinyCore:avr:attinyx41opti 
ATtiny45/85 (Optiboot)        ATTinyCore:avr:attinyx5opti  
ATtiny461/861 (optiboot)      ATTinyCore:avr:attinyx61opti 
ATtiny48/88                   ATTinyCore:avr:attinyx8      
ATtiny48/88 (optiboot)        ATTinyCore:avr:attinyx8opti  
ATtiny828 (No bootloader)     ATTinyCore:avr:attiny828     
ATtiny828 (Optiboot)          ATTinyCore:avr:attiny828opti 
ATtiny87/167 (No bootloader)  ATTinyCore:avr:attinyx7      
Arduino Nano Every            arduino:megaavr:nona4809     
Arduino Uno WiFi Rev2         arduino:megaavr:uno2018      
@fpistm
Copy link

fpistm commented Jul 1, 2020

Hi
I've got the same issue with our CI and the STM32 core. It works fine with 0.10.0 (and above) but not with the new release 0.11.0.
I've updated our python build scripts to manage the breaking changes (--output) anyway we could not get the boards details.
One strange things is that I could not reproduce locally (under Windows 10 or Linux Ubuntu 18.04), only with the GitHub action running under Linux Ubuntu 18.04.
See: https://github.com/stm32duino/Arduino_Core_STM32/pull/1107/checks?check_run_id=827270930

Extract of the log:

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

goroutine 1 [running]:
github.com/arduino/arduino-cli/commands/board.Details(0xf33100, 0xc000098010, 0xc0000f1d38, 0xad2ab7, 0xc000104a00, 0xc0001cdd48)
/__w/arduino-cli/arduino-cli/commands/board/details.go:65 +0x4df
github.com/arduino/arduino-cli/cli/board.runDetailsCommand(0xc000191080, 0xc00026ebd0, 0x1, 0x3)
/__w/arduino-cli/arduino-cli/cli/board/details.go:57 +0x145
github.com/spf13/cobra.(*Command).execute(0xc000191080, 0xc00026eba0, 0x3, 0x3, 0xc000191080, 0xc00026eba0)
/github/home/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:846 +0x2aa
github.com/spf13/cobra.(*Command).ExecuteC(0xc000190840, 0x0, 0xc6f6e0, 0xc000082058)
/github/home/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:950 +0x349
github.com/spf13/cobra.(*Command).Execute(...)
/github/home/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:887
main.main()
/__w/arduino-cli/arduino-cli/main.go:31 +0x36
panic: runtime error: invalid memory address or nil pointer dereference

Here the full Raw log:
FullRawLogOfTheCI.txt

fpistm added a commit to stm32duino/actions that referenced this issue Jul 3, 2020
Latest release 0.11.0 has a bug which prevent to build properly.
When arduino/arduino-cli#759 will be fixed then
this commit could be revert.

Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
fpistm added a commit to stm32duino/actions that referenced this issue Jul 3, 2020
Latest release 0.11.0 has a bug which prevent to build properly.
When arduino/arduino-cli#759 will be fixed then
this commit could be revert.

Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
@matthijskooijman
Copy link
Collaborator

I also ran into this issue, getting exactly the same backtrace with the Adafruit SAMD platform, installed through the board manager and running arduino-cli board details adafruit:samd:adafruit_feather_m0 with current git master (locally compiled).

The problem seems to be that boardPlatform.Resource is nil here:

Url: boardPlatform.Resource.URL,

I looked around a little bit for how this value is set, but couldn't quickly find my way, so I'm just leaving this here instead.

@fpistm
Copy link

fpistm commented Aug 26, 2020

Hi @matthijskooijman
Which version of the cli you used ?
I didn't test with the 0.12 yet.

@matthijskooijman
Copy link
Collaborator

Current git master, just pulled and built it.

@fpistm
Copy link

fpistm commented Aug 26, 2020

Ok thanks. Sorry mireading your first comment.

I've tested with the latest release 0.12 and same issue:
For ref: https://github.com/stm32duino/Arduino_Core_STM32/pull/1154/checks?check_run_id=1030660344

Arduino CLI version used: 0.12.0
Cores configuration JSON file that will be used:
/github/home/.arduino15/packages/STM32/hardware/stm32/2.0.0-dev/CI/build/conf/cores_config_ci.json
Build configuration for 'STM32' maintainer and 'stm32' architecture
"arduino-cli board details --format json STM32:stm32:Nucleo_64" failed with code: 2!
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xbae548]

goroutine 1 [running]:
github.com/arduino/arduino-cli/commands/board.Details(0x1058da0, 0xc000038048, 0xc00013bd30, 0xa, 0xa, 0x9)
	/__w/arduino-cli/arduino-cli/commands/board/details.go:65 +0x4e8
github.com/arduino/arduino-cli/cli/board.runDetailsCommand(0xc0001f3600, 0xc0002b5aa0, 0x1, 0x3)
	/__w/arduino-cli/arduino-cli/cli/board/details.go:67 +0x11e
github.com/spf13/cobra.(*Command).execute(0xc0001f3600, 0xc0002b5a70, 0x3, 0x3, 0xc0001f3600, 0xc0002b5a70)
	/github/home/go/pkg/mod/github.com/spf13/cobra@v1.0.1-0.20200710201246-675ae5f5a98c/command.go:846 +0x2aa
github.com/spf13/cobra.(*Command).ExecuteC(0xc0001f2dc0, 0x0, 0xd4bb80, 0xc0000440b8)
	/github/home/go/pkg/mod/github.com/spf13/cobra@v1.0.1-0.20200710201246-675ae5f5a98c/command.go:950 +0x349
github.com/spf13/cobra.(*Command).Execute(...)
	/github/home/go/pkg/mod/github.com/spf13/cobra@v1.0.1-0.20200710201246-675ae5f5a98c/command.go:887
main.main()
	/__w/arduino-cli/arduino-cli/main.go:31 +0x36

##[error]Process completed with exit code 1.

@cmaglie
Copy link
Member

cmaglie commented Aug 26, 2020

Looking at stacktrace, the Resource.URL value comes from the various package_index jsons.
Recently, in the board details command, we added a print of the platform resources URLs. So the first though I had is that platforms manually installed in the sketchbook/hardware directory may be affected... and after testing it, indeed they are, so I will produce a fix for this problem.

Anyway I'm wondering how a package installed from a package_index (even from a 3rd party index) may end up in this situation.
I'm also unable to reproduce the issue with any of the example posted above, I tried with:

ATTinyCore:avr:attinyx4 (using http://drazzy.com/package_drazzy.com_index.json)
adafruit:samd:adafruit_feather_m0 (using https://adafruit.github.io/arduino-board-index/package_adafruit_index.json)
STM32:stm32:Nucleo_64 (using https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json)

and I always get the correct output without any issue, the procedure I followed is:

  1. add the 3rd party url in the arduino-cli configuration
  2. install the platform
  3. run board details with the board FQBN

Hopefully the patch will fix the issue in general but, in any case, if someone may provide a step-by-step procedure to reproduce the original issue, starting from a clean install, it may help to see if there are other bugs to fix.

@matthijskooijman
Copy link
Collaborator

So the first though I had is that platforms manually installed in the sketchbook/hardware directory may be affected...

Yeah, that was also my first thought, but it also happened for other platforms.

add the 3rd party url in the arduino-cli configuration

Ah, that's probably the problem. I installed this platform using the Java IDE, so I have no URLs configured for it in arduino-cli.yaml.

cmaglie added a commit to cmaglie/arduino-cli that referenced this issue Aug 26, 2020
The NPI is triggered if Platform.Resource is nil (this may happen for
platforms installed manually in the sketchbook/hardware directory for
example).

Related to arduino#759
@fpistm
Copy link

fpistm commented Aug 26, 2020

In fact,
Several calls uses the --additional-urls

  • core update-index
  • core install
  • core search

Then it fails on the board details without --additional-urls
I can try to add the --additional-urls to this call.

@fpistm
Copy link

fpistm commented Aug 26, 2020

I've tested to add the --additional-urls to the board details and it seems OK.
The question is why before it works without and now not, I guess?
stm32duino/Arduino_Core_STM32@2e5f440

cmaglie added a commit that referenced this issue Aug 27, 2020
* Fix NPE for 'board install' command

The NPI is triggered if Platform.Resource is nil (this may happen for
platforms installed manually in the sketchbook/hardware directory for
example).

Related to #759

* Update translations
@cmaglie
Copy link
Member

cmaglie commented Aug 27, 2020

The question is why before it works without and now not, I guess?

The reason is that we changed the board details command: now it prints more information (like the package URL) but it doesn't check if the information is available or not, so the nil excpetion.

This is totally our oversight, BTW this is now fixed after merging #924 and will be available in the next release.
Thanks for the bug report!

@cmaglie cmaglie closed this as completed Aug 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants