uber-go / nilaway

Static analysis tool to detect potential nil panics in Go code
Apache License 2.0
3.17k stars 65 forks source link

Nilaway does not detect possible nil value in go-routine function #132

Open wildwind123 opened 12 months ago

wildwind123 commented 12 months ago

this code from https://github.com/uber-go/nilaway/blob/main/README.md

// Example 2:
func foo() *int {
      return nil
}
func bar() {
     print(*foo()) // nilness reports NO error here, but NilAway does.
}

after run command

nilaway ./...

catch possible nil.

but if i wrap "print(*foo()) " in go-routine this does not detect

func foo() *int {
    return nil
}
func bar() {
    go func() {
        print(*foo()) 
    }()
}

after run command

nilaway ./...

does not catch possible nil, should catch, like from first example

dolmen commented 12 months ago

Please take time to explain what you expected: a meaningful title, a summary of the issue. Readers can't spend time deciphering your code.

wildwind123 commented 11 months ago

Please take time to explain what you expected: a meaningful title, a summary of the issue. Readers can't spend time deciphering your code.

done

sonalmahajan15 commented 11 months ago

@wildwind123 thanks for reporting the issue! We have implemented support for analyzing anonymous functions. However, currently it is hidden under a feature flag. You can add <nilaway anonymous function enable> to the file docstring to enable this feature, which will report the expected error in the go-routine code snippet.

We are conducting performance and correctness evaluations internally for the anonymous function feature before moving it to main NilAway. I'm keeping this issue open to track the work.