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

panic: runtime error: invalid memory address or nil pointer dereference #257

Closed
Rakhil-Pilachrey opened this issue Oct 11, 2022 · 11 comments · Fixed by magodo/azlist#1 or #262
Closed
Labels
bug Something isn't working

Comments

@Rakhil-Pilachrey
Copy link

Hello Team,

I'm getting below error when I tried to run aztfy command to import all resources inside a resource group. this resource group has around 500 resources inside it.

Azure Terrafy

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x1660809]

                                                                                                                     goroutine 176 [running]:
                                                                                                                                             github.com/magodo/azlist/azlist.listDirectChildResource({0x2c4b110, 0xc000038100}, 0xc003199780, 0x10000c0032c7290?, {{0x2c4f818?, 0xc003458cd0?}, 0xc00273bce0?})
                                                                    github.com/magodo/azlist@v0.0.0-20220923015326-17b16cc9b805/azlist/azlist.go:347 +0x129
                                                                                                                                                           github.com/magodo/azlist/azlist.ListChildResource.func2()
                                                                                                                                                                                                                            github.com/magodo/azlist@v0.0.0-20220923015326-17b16cc9b805/azlist/azlist.go:285 +0x47
                                                                     github.com/magodo/workerpool.(*workPool).Run.func1(0x0?)
                                                                                                                                    github.com/magodo/workerpool@v0.0.0-20211124060943-1c48f3e5a514/workerpool.go:75 +0x99
                                                                                                                                                                                                                          created by github.com/magodo/workerpool.(*workPool).Run
                                            github.com/magodo/workerpool@v0.0.0-20211124060943-1c48f3e5a514/workerpool.go:66 +0x5d
@magodo
Copy link
Collaborator

magodo commented Oct 12, 2022

@RakhilRavindran007 Thank you for submitting this! I've made a fix in the https://github.com/magodo/azlist project. However, I don't have the environment the reproduce this issue, as I have tried to use azlist to list all the resources under my subscription, which won't trigger this panic.

Could you please verify that using the latest azlist, the issue is fixed on your side? You can simply install it via go install github.com/magodo/azlist@latest. Then run it via azlist 'resourceGroup =~ "YOUR_RG_NAME"'. Once you confirmed it works, I'll update the dependency in aztfy.

@Rakhil-Pilachrey
Copy link
Author

Hello @magodo I followed the above steps and installed latest version of azlist. however when I tried to run it via azlist 'resourceGroup =~ "MY_RG_NAME"' im getting required flag missing error as show below.
image

@magodo
Copy link
Collaborator

magodo commented Oct 12, 2022

You'll have to set the subscription id, either via -s or the env var ARM_SUBSCRIPTION_ID.

@Rakhil-Pilachrey
Copy link
Author

Hi @magodo Thanks for your prompt reply. I tried to run the command which includes the subscription id. Im getting a bad request output when run the command. please see below screenshot.
image

@magodo
Copy link
Collaborator

magodo commented Oct 12, 2022

That's weired... It works for me:

💤  azlist  'resourceGroup =~ "aztfy-vmdisk"'            
/subscriptions/xxxx/resourceGroups/AZTFY-VMDISK/providers/Microsoft.Compute/disks/aztfy-test-test_OsDisk_1_3ef6711919624d5594387b69adc35634
/subscriptions/xxxx/resourceGroups/AZTFY-VMDISK/providers/Microsoft.Compute/virtualMachines/aztfy-test-test
/subscriptions/xxxx/resourceGroups/AZTFY-VMDISK/providers/Microsoft.Compute/virtualMachines/aztfy-test-test/extensions/Microsoft.Azure.Security.Monitoring.AzureSecurityLinuxAgent
/subscriptions/xxxx/resourceGroups/aztfy-vmdisk/providers/Microsoft.Compute/disks/aztfy-test-test
/subscriptions/xxxx/resourceGroups/aztfy-vmdisk/providers/Microsoft.Network/networkInterfaces/aztfy-test-test
/subscriptions/xxxx/resourceGroups/aztfy-vmdisk/providers/Microsoft.Network/networkSecurityGroups/NRMS-clhxdfaurwj2oaztfy-test-test-internal
/subscriptions/xxxx/resourceGroups/aztfy-vmdisk/providers/Microsoft.Network/networkSecurityGroups/NRMS-oyhsp3ghi6phaaztfy-test-test
/subscriptions/xxxx/resourceGroups/aztfy-vmdisk/providers/Microsoft.Network/virtualNetworks/aztfy-test-test

I suspect it might because the quote around your rg name is not reserved by the powershell?

@teerakdv
Copy link

Hi @magodo
I 've faced the identical issue than @RakhilRavindran007
When would you be able to update aztfy with this fix on azlist ?

Thanks

@bhmahler
Copy link

bhmahler commented Nov 9, 2022

Assuming this is merged into main, I am still seeing this issue. I can list resources for an RG with azlist but aztfy still throws panic: runtime error: invalid memory address or nil pointer dereference. Is there a timeframe on this fix?

@magodo
Copy link
Collaborator

magodo commented Nov 10, 2022

@bhmahler Yes it is merged in main. Did you install it from source? Would you please check the output of go version -m ~/go/bin/aztfy | grep vcs.revision?

@bhmahler
Copy link

bhmahler commented Nov 10, 2022

I am running on windows so no grep but I installed with go install github.com/Azure/aztfy@latest I do not see vcs.revision anywhere in the output of go version -m ...
The aztfy version is mod github.com/Azure/aztfy v0.9.0 h1:+gcSgOqyzAFpCONt/gbuStEP6A/dXnuyOAJ5bKvWA/w=

I am trying to build from the source but having issues with stthe complied app being blocked. Working on getting that resolved and will test with this version once I do.

UPDATE: When running from the compiled source it appears to be working correctly

@magodo
Copy link
Collaborator

magodo commented Nov 11, 2022

@bhmahler go install github.com/Azure/aztfy@latest installs the latest release, while go install github.com/Azure/aztfy@main install the main branch (i.e. the latest version).

@najx
Copy link

najx commented Jan 31, 2023

Installing from the main branch instead of the latest release solved my issue. Thanks @magodo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
5 participants