codeql icon indicating copy to clipboard operation
codeql copied to clipboard

Python codeql analysis hangs at `UnusedModuleVariable`

Open njzjz opened this issue 1 year ago • 2 comments

Description of the issue

The codeql runs in a PR (https://github.com/deepmodeling/deepmd-kit/pull/3199, commit https://github.com/deepmodeling/deepmd-kit/pull/3199/commits/ce87afc5be720c15fac114927052104028093764).

It hung at:

   [88/168 eval 3.7s] Evaluation done; writing results to codeql/python-queries/Variables/MultiplyDefined.bqrs.
  Starting evaluation of codeql/python-queries/Variables/UnusedModuleVariable.ql.

https://github.com/deepmodeling/deepmd-kit/actions/runs/7697851534/job/20975781045

I manually restarted it after several hours, and it hung here again.

https://github.com/deepmodeling/deepmd-kit/actions/runs/7697851534/job/20989521619

I don't quite understand what's wrong with UnusedModuleVariable in this PR. Thank you in advance.

njzjz avatar Jan 29 '24 21:01 njzjz

Finally, I found that if a class used the following decorator twice (via inheritance), codeql would hang. The reason is unclear to me.

def fitting_check_output(cls):
    class wrapper(cls):
        def __init__(
            self,
            *args,
            **kwargs,
        ):
            super().__init__(*args, **kwargs)
            self.md = self.output_def()

        def __call__(
            self,
            *args,
            **kwargs,
        ):
            ret = cls.__call__(self, *args, **kwargs)
            for kk in self.md.keys():
                dd = self.md[kk]
                check_var(ret[kk], dd)
            return ret

    return wrapper

See also https://github.com/deepmodeling/deepmd-kit/pull/3202, which resolves the hang by just removing this decorator once...

njzjz avatar Jan 30 '24 06:01 njzjz

Thanks for the detailed report! I'll ask the team to have a look.

aibaars avatar Jan 30 '24 13:01 aibaars

👋 @njzjz Apologies for the delayed response. We've invested some time in attempting to reproduce this issue, but haven't been able to so far. Since you have a workaround, I will close this issue for now. If we see others report something similar, we'll reopen and investigate the issue to determine next steps.

sidshank avatar Apr 21 '24 21:04 sidshank