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

NewDeleteLeaks false positive calling QTimer::singleShot with a lambda function #39713

Closed
llvmbot opened this issue Jan 17, 2019 · 1 comment
Closed
Assignees
Labels
bugzilla Issues migrated from bugzilla clang:static analyzer

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Jan 17, 2019

Bugzilla Link 40367
Version unspecified
OS Linux
Attachments Minimal example showing false positive of NewDeleteLeaks check
Reporter LLVM Bugzilla Contributor
CC @devincoughlin,@EugeneZelenko

Extended Description

The NewDeleteLeaks check thinks that QTimer::singleShot leaks the lambda function object, but internally Qt reference counts the object and takes care of deleting it.

The attached QtSingleShotNewDeleteLeakFalsePositive.cpp file demonstrates the error:

/usr/include/x86_64-linux-gnu/qt5/QtCore/qtimer.h:154:5: error: Potential memory leak [clang-analyzer-cplusplus.NewDeleteLeaks,-warnings-as-errors]
}
^
/home/.../QtSingleShotNewDeleteLeakFalsePositive.cpp:5:5: note: Calling 'QTimer::singleShot'
QTimer::singleShot(0, [=] {});
^
/usr/include/x86_64-linux-gnu/qt5/QtCore/qtimer.h:125:9: note: Calling 'QTimer::singleShot'
singleShot(interval, defaultTypeFor(interval), nullptr, slot);
^
/usr/include/x86_64-linux-gnu/qt5/QtCore/qtimer.h:152:24: note: Memory is allocated
new QtPrivate::QFunctorSlotObject<Func1, 0,
^
/usr/include/x86_64-linux-gnu/qt5/QtCore/qtimer.h:154:5: note: Potential memory leak
}
^

This is with Qt 5.9.5 on Ubuntu 18.04. I do not see the issue on Windows with the same Qt version.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Jan 17, 2019

assigned to @devincoughlin

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang:static analyzer
Projects
None yet
Development

No branches or pull requests

1 participant