llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.55k stars 11.8k forks source link

valgrind error in function NoteFunctionCandidate, file SemaOverload.cpp line 11961 #98769

Closed dcb314 closed 2 weeks ago

dcb314 commented 3 months ago

cvise $ /home/dcb40b/valgrind/results/bin/valgrind -q --trace-children=yes /home/dcb40b/llvm/results/bin/clang++ -c bug157.cc ==1668426== Conditional jump or move depends on uninitialised value(s) ==1668426== at 0x47E3526: NoteFunctionCandidate (SemaOverload.cpp:11961) ==1668426== by 0x47E3526: clang::OverloadCandidateSet::NoteCandidates(clang::Sema&, llvm::ArrayRef<clang::Expr>, llvm::ArrayRef<clang::OverloadCandidate>, llvm::StringRef, clang::SourceLocation) (SemaOverload.cpp:12591)

bug157.cc.gz

File SemaOverload.cpp, line 11961 is

  !Cand->Function->hasCXXExplicitFunctionObjectParameter() &&

This bug has existed since sometime before git hash 005758eb6b35aaf548c3a59da860ecd2465a73f0, dated 20240614.

llvmbot commented 3 months ago

@llvm/issue-subscribers-clang-frontend

Author: None (dcb314)

cvise $ /home/dcb40b/valgrind/results/bin/valgrind -q --trace-children=yes /home/dcb40b/llvm/results/bin/clang++ -c bug157.cc ==1668426== Conditional jump or move depends on uninitialised value(s) ==1668426== at 0x47E3526: NoteFunctionCandidate (SemaOverload.cpp:11961) ==1668426== by 0x47E3526: clang::OverloadCandidateSet::NoteCandidates(clang::Sema&, llvm::ArrayRef<clang::Expr*>, llvm::ArrayRef<clang::OverloadCandidate*>, llvm::StringRef, clang::SourceLocation) (SemaOverload.cpp:12591) [bug157.cc.gz](https://github.com/user-attachments/files/16203516/bug157.cc.gz) File SemaOverload.cpp, line 11961 is !Cand->Function->hasCXXExplicitFunctionObjectParameter() && This bug has existed since sometime before git hash 005758eb6b35aaf548c3a59da860ecd2465a73f0, dated 20240614.
shafik commented 3 months ago

This indeed looks like a bug, everywhere else Cand->Function is checked before using it.

This came in w/ d0223b9ffc401

CC @cor3ntin

llvmbot commented 3 months ago

Hi!

This issue may be a good introductory issue for people new to working on LLVM. If you would like to work on this issue, your first steps are:

  1. Check that no other contributor has already been assigned to this issue. If you believe that no one is actually working on it despite an assignment, ping the person. After one week without a response, the assignee may be changed.
  2. In the comments of this issue, request for it to be assigned to you, or just create a pull request after following the steps below. Mention this issue in the description of the pull request.
  3. Fix the issue locally.
  4. Run the test suite locally. Remember that the subdirectories under test/ create fine-grained testing targets, so you can e.g. use make check-clang-ast to only run Clang's AST tests.
  5. Create a Git commit.
  6. Run git clang-format HEAD~1 to format your changes.
  7. Open a pull request to the upstream repository on GitHub. Detailed instructions can be found in GitHub's documentation. Mention this issue in the description of the pull request.

If you have any further questions about this issue, don't hesitate to ask via a comment in the thread below.

llvmbot commented 3 months ago

@llvm/issue-subscribers-good-first-issue

Author: None (dcb314)

cvise $ /home/dcb40b/valgrind/results/bin/valgrind -q --trace-children=yes /home/dcb40b/llvm/results/bin/clang++ -c bug157.cc ==1668426== Conditional jump or move depends on uninitialised value(s) ==1668426== at 0x47E3526: NoteFunctionCandidate (SemaOverload.cpp:11961) ==1668426== by 0x47E3526: clang::OverloadCandidateSet::NoteCandidates(clang::Sema&, llvm::ArrayRef<clang::Expr*>, llvm::ArrayRef<clang::OverloadCandidate*>, llvm::StringRef, clang::SourceLocation) (SemaOverload.cpp:12591) [bug157.cc.gz](https://github.com/user-attachments/files/16203516/bug157.cc.gz) File SemaOverload.cpp, line 11961 is !Cand->Function->hasCXXExplicitFunctionObjectParameter() && This bug has existed since sometime before git hash 005758eb6b35aaf548c3a59da860ecd2465a73f0, dated 20240614.
vortex73 commented 3 months ago

I'm looking into this issue. The issue is Cand->Function nott being checking in this case am I right?

shafik commented 3 months ago

I'm looking into this issue. The issue is Cand->Function nott being checking in this case am I right?

Yes, something like this:

https://github.com/llvm/llvm-project/blob/a78b19d8ea513a2e88fa431b549b65406384a12d/clang/lib/Sema/SemaOverload.cpp#L9996-L10000

shafik commented 3 months ago

As a side note, I think it is unfortunate in some place in SemaOverload.cpp they check Cand->Function and then pass Cand and then within the called function they can now assume Cand->Function is valid. I think it would have been a better choice to pass Cand->Function as a another argument maybe FunctionDecl *Fn and then use that.

It obscures when Cand->Function can be assumed valid or not, you really have to check across the code to know.

zyn0217 commented 2 weeks ago

https://github.com/llvm/llvm-project/pull/98965 claims it fixes this.