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

Add QPainterPath autotest #919

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Montel
Copy link
Contributor

@Montel Montel commented Apr 10, 2024

No description provided.

@Montel Montel self-assigned this Apr 10, 2024
@Montel
Copy link
Contributor Author

Montel commented Apr 10, 2024

==18729== HEAP SUMMARY:
==18729==     in use at exit: 27,609 bytes in 62 blocks
==18729==   total heap usage: 15,493 allocs, 15,431 frees, 1,473,500 bytes allocated
==18729== 
==18729== 512 (104 direct, 408 indirect) bytes in 1 blocks are definitely lost in loss record 48 of 53
==18729==    at 0x4849013: operator new(unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==18729==    by 0x4CB05EA: QPainterPath::ensureData_helper() (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.15.3)
==18729==    by 0x4CB4E57: QPainterPath::addEllipse(QRectF const&) (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.15.3)
==18729==    by 0x151C17: QPainterPathTest::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) (in /home/runner/cxx-qt/build/tests/qt_types_standalone/tests_qt_types_standalone)
==18729==    by 0x571325A: QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const (in /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.15.3)
==18729==    by 0x5410382: ??? (in /usr/lib/x86_64-linux-gnu/libQt5Test.so.5.15.3)
==18729==    by 0x5410E1A: ??? (in /usr/lib/x86_64-linux-gnu/libQt5Test.so.5.15.3)
==18729==    by 0x5411378: ??? (in /usr/lib/x86_64-linux-gnu/libQt5Test.so.5.15.3)
==18729==    by 0x5411863: QTest::qRun() (in /usr/lib/x86_64-linux-gnu/libQt5Test.so.5.15.3)
==18729==    by 0x5411C3F: QTest::qExec(QObject*, int, char**) (in /usr/lib/x86_64-linux-gnu/libQt5Test.so.5.15.3)
==18729==    by 0x167768: main::{lambda(QScopedPointer<QObject, QScopedPointerDeleter<QObject> >)#1}::operator()(QScopedPointer<QObject, QScopedPointerDeleter<QObject> >) const (in /home/runner/cxx-qt/build/tests/qt_types_standalone/tests_qt_types_standalone)
==18729==    by 0x1501F7: main (in /home/runner/cxx-qt/build/tests/qt_types_standalone/tests_qt_types_standalone)

For me it's a mem leak in qt no ?

@LeonMatthesKDAB
Copy link
Collaborator

That's not necessarily a leak in Qt.

While this means that the memory was allocated by Qt internally, the question is more why it wasn't deleted.
This could be caused by our code not running the deconstructor of QPainterPath or doing some incorrect copy, etc.

We've encountered similar issues before, where certain types were not quite compatible with the way CXX moves data around. I think that was with QTimeZone, but I unfortunately can't find our discussion on that.
I can recommend you try to run the test in a debugger and set breakpoints at the constructors and destructors of QPainterPath.

@Montel
Copy link
Contributor Author

Montel commented Apr 15, 2024

(gdb) c
Continuing.

Breakpoint 1.7, 0x00007ffff7911580 in QPainterPath::QPainterPath() () from /lib64/libQt6Gui.so.6
(gdb) c
Continuing.

Breakpoint 1.1, 0x0000000000418510 in QPainterPath::QPainterPath(QPainterPath const&)@plt ()
(gdb) c
Continuing.

Breakpoint 1.8, 0x00007ffff7911590 in QPainterPath::QPainterPath(QPainterPath const&) () from /lib64/libQt6Gui.so.6
(gdb) c
Continuing.

Breakpoint 2.1, 0x0000000000419680 in QPainterPath::~QPainterPath()@plt ()
(gdb) c
Continuing.

Breakpoint 2.3, 0x00007ffff7917a90 in QPainterPath::~QPainterPath() () from /lib64/libQt6Gui.so.6
(gdb) c
Continuing.
PASS   : QPainterPathTest::construct()

Breakpoint 1.2, 0x0000000000418b40 in QPainterPath::QPainterPath()@plt ()
(gdb) c
Continuing.

Breakpoint 1.7, 0x00007ffff7911580 in QPainterPath::QPainterPath() () from /lib64/libQt6Gui.so.6
(gdb) c
Continuing.

Breakpoint 1.1, 0x0000000000418510 in QPainterPath::QPainterPath(QPainterPath const&)@plt ()
(gdb) c
Continuing.

Breakpoint 1.8, 0x00007ffff7911590 in QPainterPath::QPainterPath(QPainterPath const&) () from /lib64/libQt6Gui.so.6
(gdb) c
Continuing.

Breakpoint 1.1, 0x0000000000418510 in QPainterPath::QPainterPath(QPainterPath const&)@plt ()
(gdb) c
Continuing.

Breakpoint 1.8, 0x00007ffff7911590 in QPainterPath::QPainterPath(QPainterPath const&) () from /lib64/libQt6Gui.so.6
(gdb) c
Continuing.

Breakpoint 2.1, 0x0000000000419680 in QPainterPath::~QPainterPath()@plt ()
(gdb) c
Continuing.

Breakpoint 2.3, 0x00007ffff7917a90 in QPainterPath::~QPainterPath() () from /lib64/libQt6Gui.so.6
(gdb) c
Continuing.

Breakpoint 2.1, 0x0000000000419680 in QPainterPath::~QPainterPath()@plt ()
(gdb) c
Continuing.

Breakpoint 2.3, 0x00007ffff7917a90 in QPainterPath::~QPainterPath() () from /lib64/libQt6Gui.so.6
(gdb) c
Continuing.
PASS   : QPainterPathTest::clone()
PASS   : QPainterPathTest::cleanupTestCase()
Totals: 4 passed, 0 failed, 0 skipped, 0 blacklisted, 14776ms

@LeonMatthesKDAB
Copy link
Collaborator

So it seems there are indeed more constructor (9) than destructor (6) calls.

That's likely caused by CXX "forgetting" an instance, which we've encountered before.
You may need to debug this further or try to just make QPainterPath an opaque type.

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