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

*: add non-nil check to avoid panic #30529

Closed
wants to merge 1 commit into from

Conversation

crazycs520
Copy link
Contributor

Signed-off-by: crazycs520 crazycs520@gmail.com

What problem does this PR solve?

Issue Number: close #30252

What is changed and how it works?

  • Add non-nil check.

In fact, I didn’t understand why the StatementContext.digestMemo.digest value is nil. I check all related function call chain, normally, it should never happen. So I just add some non-nil check to avoid panic.

Check List

Tests

  • No code

Side effects

  • N/A

Documentation

  • N/A

Release note

None

Signed-off-by: crazycs520 <crazycs520@gmail.com>
@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has not been approved.

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Dec 8, 2021
@crazycs520
Copy link
Contributor Author

@tangenta @wjhuang2016 PTAL

@tangenta
Copy link
Contributor

tangenta commented Dec 8, 2021

@crazycs520 I don't think this is a good way to fix it, because it can cause another nil-pointer problem.

We need to find out the root cause. How about adding a warning log in InitSQLDigest and printing the stack?

@crazycs520
Copy link
Contributor Author

@crazycs520 I don't think this is a good way to fix it, because it can cause another nil-pointer problem.

We need to find out the root cause. How about adding a warning log in InitSQLDigest and printing the stack?

Anyhow, this PR can avoid the risk of potential panic, and does not affect the correctness.

I am not sure about adding log to print the stack to troubleshoot the issue.

@tangenta
Copy link
Contributor

@crazycs520 I mean we should prevent StatementContext.digestMemo.digest to be nil, so that we don't need to add not-nil check to every usage.

@crazycs520 crazycs520 closed this Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tidb panic: invalid memory address or nil pointer dereference
3 participants