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

fix: unexpected uncalled judge in recursive loop #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

timakin
Copy link

@timakin timakin commented Apr 4, 2019

Related issue

gostaticanalysis/sqlrows#1

Detail

func (c *calledFrom) succs(b *ssa.BasicBlock) bool ignores other than the first BasicBlock in a recursive loop.
It causes an unexpected pass through when the function's signature has multiple return values.

@timakin timakin requested a review from tenntenn April 4, 2019 15:55
if !c.instrs(s.Instrs) && !c.succs(s) {
return false
if c.instrs(s.Instrs) || c.succs(s) {
called = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does not return immediately?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a defer function, the index of instr won't be 1.
So the loop will be returned before the Instruction was checked.
For an accurate validation, an iteration for "all of" s.Succs values is needed.

Copy link
Member

@tenntenn tenntenn Apr 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this code only checks whether the function was called in any succsesors yet.
Because there is only an assignment which changes value of var called, called = true.

@tenntenn
Copy link
Member

tenntenn commented Apr 4, 2019

Could you put a sample code on the issue?
I found the issue of sqlrows.

@tenntenn tenntenn changed the base branch from master to main November 23, 2020 06:45
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

Successfully merging this pull request may close these issues.

2 participants