Skip to content

Fix #14990: FP memleak with function call through function pointer - #8813

Open
aadanen wants to merge 10 commits into
cppcheck-opensource:mainfrom
aadanen:fptr_leak
Open

aadanen wants to merge 10 commits into
cppcheck-opensource:mainfrom
aadanen:fptr_leak

Conversation

@aadanen

@aadanen aadanen commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Modify checkleakautovar to consider calls to lambdas and function pointers as function calls that can allow resources to escape the current scope.

@aadanen

aadanen commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor Author

I am suprised to see all these segmentation faults. In my testing everything seemed to work nicely but I guess it was just crashing silently and working properly. I will need to modify functionCall() more heavily to not send nullptr to the library functions. This kinda undermines my idea of reusing functionCall for anonymous functions but I still think it is better than duplicating the function.

@aadanen

aadanen commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor Author

I switched from the makefile to cmake and ran the CI workflows locally so I think next time they run, they should pass. Sorry about that. Also I noticed that git was using my work account, so I sorted that out too.

@aadanen
aadanen force-pushed the fptr_leak branch 2 times, most recently from 4bc4b04 to 2621d76 Compare August 28, 2026 00:09

@danmar danmar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I am not sure why but there was significant slowdown in CI (selfchecking) after this?

Comment thread lib/checkleakautovar.cpp Outdated
@aadanen

aadanen commented Aug 29, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review! I will look into it more on monday.

@aadanen

aadanen commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

I found the issue with the selfcheck slowdown. isAnonymousFunctionCall would sometimes link() backwards causing the checker to loop forever.

void f(char ch16) {
    ch = static_cast<unsigned char>(((ch16 >= 0x80) ? 0xff : ch16));
}

@aadanen

aadanen commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

the sanitizers/build check failed because of some network thing:
Connecting to apt.llvm.org (apt.llvm.org)|2a04:4e42:8a::561|:443... failed: Network is unreachable.
I think it probably just needs to be re-run.

Thanks!

Comment thread lib/checkleakautovar.cpp
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