steampipe icon indicating copy to clipboard operation
steampipe copied to clipboard

Error: runtime error: invalid memory address or nil pointer dereference (SQLSTATE HV000)

Open createchange opened this issue 2 years ago • 6 comments

Describe the bug

select az.user_principal_name as upn, slack.email as email, az.account_enabled as az_enabled, slack.deleted as slack_deleted from slack_user slack, azuread_user az where slack.email = az.user_principal_name;
Error: runtime error: invalid memory address or nil pointer dereference (SQLSTATE HV000)

Steampipe version (steampipe -v) ~ ➜ steampipe -v steampipe version 0.15.3

To reproduce Run the above command

Expected behavior Command successfully completes.

createchange avatar Jul 19 '22 21:07 createchange

Thanks for reporting this issue @createchange, sorry you've run into it - crashes are particularly nasty / unexpected, so keen to get it resolved.

Questions to help us troubleshoot:

  • Can you query the slack_user table on it's own?
  • Can you query the azuread_user table on it's own?

Also, can you please try again and share the log you get after running with:

STEAMPIPE_LOG=trace steampipe query

You should get output on the screen, and you can also check ~/.steampipe/logs.

e-gineer avatar Jul 19 '22 22:07 e-gineer

You're welcome! Seems like a great tool that should help me out quite a bit!

I can indeed query both slack_user and azuread_user on their own.

I should have mentioned that sometimes I get some results from the original query. But, it's always truncated, and includes the original error message:

> select az.user_principal_name as upn, slack.email as email, az.account_enabled as az_enabled, slack.deleted as slack_deleted from slack_user slack, azuread_user az where slack.email = az.user_principal_name;

Error: runtime error: invalid memory address or nil pointer dereference (SQLSTATE HV000)

+----------------------------+----------------------------+------------+---------------+
| upn                        | email                      | az_enabled | slack_deleted |
+----------------------------+----------------------------+------------+---------------+
| <redacted>   | <redacted>   | false | true   |
...

Finally, here is the requested log output:

2022-07-19 22:21:32.525 UTC [TRACE] steampipe: Connection.PopulateChildren for aggregator connection aws_hitrust
2022-07-19 22:21:32.525 UTC [TRACE] steampipe: Connection.PopulateChildren found matching connection aws_prod
2022-07-19 22:21:32.525 UTC [TRACE] steampipe: Connection.PopulateChildren found matching connection aws_mgmt
2022-07-19 22:21:32.525 UTC [TRACE] steampipe: Connection.PopulateChildren for aggregator connection aws_all
2022-07-19 22:21:32.525 UTC [TRACE] steampipe: Connection.PopulateChildren found matching connection aws_prod
2022-07-19 22:21:32.525 UTC [TRACE] steampipe: Connection.PopulateChildren found matching connection aws_mgmt
2022-07-19 22:21:32.525 UTC [TRACE] steampipe: Connection.PopulateChildren found matching connection aws_dev
2022-07-19 22:21:32.525 UTC [TRACE] steampipe: Connection.PopulateChildren no connection matches aws_public_resource - treating as a wildcard
2022-07-19 22:21:32.525 UTC [TRACE] steampipe: Connection.PopulateChildren found matching connection aws_administration
2022-07-19 22:21:32.525 UTC [TRACE] steampipe: Connection.PopulateChildren found matching connection aws_sandbox
2022-07-19 22:21:32.525 UTC [TRACE] steampipe: no modfile exists in workspace folder - NOT creating pseudoresources and only loading resource files from top level folder
2022-07-19 22:21:32.526 UTC [TRACE] steampipe: parse complete after 1 decode passes
2022-07-19 22:21:32.526 UTC [TRACE] steampipe: parse complete after 1 decode passes
2022-07-19 22:21:32.527 UTC [TRACE] steampipe: telemetry.Init service 'steampipe', tracingEnabled: false, metricsEnabled: false
2022-07-19 22:21:32.527 UTC [TRACE] steampipe: metrics and tracing disabled' - returning
Welcome to Steampipe v0.15.3
For more information, type .help
2022-07-19 22:21:32.527 UTC [TRACE] steampipe: GetRunStatus - loadRunningInstanceInfo returned nil
2022-07-19 22:21:32.527 UTC [TRACE] steampipe: StartDB invoker query
2022-07-19 22:21:32.527 UTC [TRACE] steampipe: StartDB started plugin manager
> 2022-07-19 22:21:32.531 UTC [TRACE] steampipe: Connection string:  host=localhost port=9193 user=root dbname=postgres sslmode=disable
2022-07-19 22:21:32.548 UTC [TRACE] steampipe: SERVICE: 2022-07-19 22:21:32.548 UTC [17847] LOG:  redirecting log output to logging collector process
2022-07-19 22:21:32.548 UTC [TRACE] steampipe: SERVICE: 2022-07-19 22:21:32.548 UTC [17847] HINT:  Future log output will appear in directory "/Users/jweaver/.steampipe/logs".
2022-07-19 22:21:32.636 UTC [TRACE] steampipe: status:  {"pid":17847,"port":9193,"listen":["localhost","127.0.0.1"],"listen_type":"local","invoker":"query","password":"XXXX-XXXX-XXXX","user":"steampipe","database":"steampipe","struct_version":20220411}
2022-07-19 22:21:32.636 UTC [TRACE] steampipe: Connection string:  host=localhost port=9193 user=root dbname=postgres sslmode=require
2022-07-19 22:21:32.782 UTC [TRACE] steampipe: status:  {"pid":17847,"port":9193,"listen":["localhost","127.0.0.1"],"listen_type":"local","invoker":"query","password":"XXXX-XXXX-XXXX","user":"steampipe","database":"steampipe","struct_version":20220411}
2022-07-19 22:21:32.782 UTC [TRACE] steampipe: Connection string:  host=localhost port=9193 user=root dbname=steampipe sslmode=require
2022-07-19 22:21:32.896 UTC [TRACE] steampipe: plugin manager state file not found
2022-07-19 22:21:32.896 UTC [TRACE] steampipe: plugin manager state file not found
2022-07-19 22:21:32.922 UTC [TRACE] steampipe: start: started plugin manager, pid 17865
2022-07-19 22:21:33.066 UTC [TRACE] steampipe: created local client 0x1400003a040
2022-07-19 22:21:33.070 UTC [TRACE] steampipe: getSchemaHashesForDynamicSchemas
2022-07-19 22:21:33.070 UTC [TRACE] steampipe: CreateConnectionPlugin creating 0 connections
2022-07-19 22:21:33.114 UTC [TRACE] steampipe: plugin manager is running - returning client
2022-07-19 22:21:33.116 UTC [TRACE] steampipe: fetched schema for 0 dynamic plugins
2022-07-19 22:21:33.116 UTC [TRACE] steampipe: CreateConnectionPlugin creating 0 connections
2022-07-19 22:21:33.151 UTC [TRACE] steampipe: plugin manager is running - returning client
2022-07-19 22:21:33.152 UTC [TRACE] steampipe: RefreshConnections: no updates required
2022-07-19 22:21:33.187 UTC [TRACE] steampipe: status:  {"pid":17847,"port":9193,"listen":["localhost","127.0.0.1"],"listen_type":"local","invoker":"query","password":"XXXX-XXXX-XXXX","user":"steampipe","database":"steampipe","struct_version":20220411}
2022-07-19 22:21:33.187 UTC [TRACE] steampipe: Connection string:  host=localhost port=9193 user=root dbname=steampipe sslmode=require
2022-07-19 22:21:33.287 UTC [TRACE] steampipe: setting user search path to [public aws_administration aws_all aws_dev aws_hitrust aws_mgmt aws_prod aws_public_resources aws_sandbox azuread slack steampipe whois internal]
2022-07-19 22:21:33.292 UTC [TRACE] steampipe: user search path sql: alter user "steampipe" set search_path to "public","aws_administration","aws_all","aws_dev","aws_hitrust","aws_mgmt","aws_prod","aws_public_resources","aws_sandbox","azuread","slack","steampipe","whois","internal";
2022-07-19 22:21:33.329 UTC [TRACE] steampipe: status:  {"pid":17847,"port":9193,"listen":["localhost","127.0.0.1"],"listen_type":"local","invoker":"query","password":"XXXX-XXXX-XXXX","user":"steampipe","database":"steampipe","struct_version":20220411}
2022-07-19 22:21:33.329 UTC [TRACE] steampipe: Connection string:  host=localhost port=9193 user=root dbname=steampipe sslmode=require
2022-07-19 22:21:33.422 UTC [TRACE] steampipe: ensureSessionSearchPath
2022-07-19 22:21:33.422 UTC [TRACE] steampipe: updated the required search path to "public","aws_administration","aws_all","aws_dev","aws_hitrust","aws_mgmt","aws_prod","aws_public_resources","aws_sandbox","azuread","slack","steampipe","whois","internal"
2022-07-19 22:21:33.422 UTC [TRACE] steampipe: session search path will be updated to  "public","aws_administration","aws_all","aws_dev","aws_hitrust","aws_mgmt","aws_prod","aws_public_resources","aws_sandbox","azuread","slack","steampipe","whois","internal"
2022-07-19 22:21:33.426 UTC [TRACE] steampipe: CreatePreparedStatements
2022-07-19 22:21:33.442 UTC [TRACE] steampipe: ensureSessionSearchPath
2022-07-19 22:21:33.442 UTC [TRACE] steampipe: updated the required search path to "public","aws_administration","aws_all","aws_dev","aws_hitrust","aws_mgmt","aws_prod","aws_public_resources","aws_sandbox","azuread","slack","steampipe","whois","internal"
2022-07-19 22:21:33.442 UTC [TRACE] steampipe: session search path is already correct - nothing to do
2022-07-19 22:21:33.555 UTC [TRACE] steampipe: ensureSessionSearchPath
2022-07-19 22:21:33.556 UTC [TRACE] steampipe: updated the required search path to "public","aws_administration","aws_all","aws_dev","aws_hitrust","aws_mgmt","aws_prod","aws_public_resources","aws_sandbox","azuread","slack","steampipe","whois","internal"
2022-07-19 22:21:33.556 UTC [TRACE] steampipe: session search path is already correct - nothing to do
2022-07-19 22:21:33.556 UTC [TRACE] steampipe: readInitDataStream - data has arrived
> select az.user_principal_name as upn, slack.email as email, slack.deleted as del from slack_user slack, azuread_user az where slack.email = az.user_principal_name;
2022-07-19 22:21:36.940 UTC [TRACE] steampipe: resolveQuery select az.user_principal_name as upn, slack.email as email, slack.deleted as del from slack_user slack, azuread_user az where slack.email = az.user_principal_name; args <empty>
2022-07-19 22:21:36.958 UTC [TRACE] steampipe: ensureSessionSearchPath
2022-07-19 22:21:36.958 UTC [TRACE] steampipe: updated the required search path to "public","aws_administration","aws_all","aws_dev","aws_hitrust","aws_mgmt","aws_prod","aws_public_resources","aws_sandbox","azuread","slack","steampipe","whois","internal"
2022-07-19 22:21:36.958 UTC [TRACE] steampipe: session search path is already correct - nothing to do
Error: runtime error: invalid memory address or nil pointer dereference (SQLSTATE HV000)

createchange avatar Jul 19 '22 22:07 createchange

Very helpful - seems like the issue is from the azuread plugin.

For the simpler azuread query that fails is there anything in the ~/.steampipe/logs/plugin-XYZ.log when you do STEAMPIPE_LOG=trace?

e-gineer avatar Jul 19 '22 22:07 e-gineer

Oh - sorry - I see now that the partial results come from the join.

Anything in the plugin log for that?

e-gineer avatar Jul 19 '22 22:07 e-gineer

Here is a clean log, with only minimal redactions where needed.

plugin-2022-07-19.log

createchange avatar Jul 19 '22 22:07 createchange

thanks @createchange, that plugin log has some clues:

2022-07-19 22:28:11.462 UTC [WARN]  steampipe-plugin-azuread.plugin: [WARN]  1658269691156: Execute recover from panic: callId: 1658269691156 table: azuread_user error: runtime error: invalid memory address or nil pointer dereference

Let me see if I can reproduce it

kaidaguerre avatar Jul 21 '22 14:07 kaidaguerre

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Sep 13 '23 09:09 github-actions[bot]

cannot reproduce in current version

kaidaguerre avatar Sep 13 '23 12:09 kaidaguerre