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

cpp-qt5-client: add valgrind memory test #3663

Merged
merged 1 commit into from
Aug 23, 2019

Conversation

MartinDelille
Copy link
Contributor

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh, ./bin/openapi3/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\. If contributing template-only or documentation-only changes which will change sample output, be sure to build the project first.
  • Filed the PR against the correct branch: master, 4.1.x, 5.0.x. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR

This PR perfoms valgrind test for Qt5 client test. #3661 is not merge so it should fail (I'll rebase once it is merged).

What do you think of the way I handle valgrind result?

@ravinikam @stkrwork @etherealjoy @muttleyxd

@etherealjoy
Copy link
Contributor

etherealjoy commented Aug 17, 2019

What do you think of the way I handle valgrind result?

I think it is a good approach.

Copy link
Contributor

@muttleyxd muttleyxd left a comment

Choose a reason for hiding this comment

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

A little concern regarding debug -O0 flag, otherwise seems fine to me

@@ -26,3 +26,6 @@ SOURCES += main.cpp \
HEADERS += PetApiTests.h \
StoreApiTests.h \
UserApiTests.h

# Disable optimisation for better valgrind report
QMAKE_CXXFLAGS += -O0
Copy link
Contributor

Choose a reason for hiding this comment

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

How about QMAKE_CXXFLAGS_DEBUG?
in build-and-test.bash you call qmake with CONFIG+=debug, so I assume debug flags will be used (I might be wrong though, I've never used qmake)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed.

@MartinDelille
Copy link
Contributor Author

There is still memory leak.

After investigation, it seems that the exit(0) instruction in UserApiTests destructor is responsible for it.

Shouldn't we first merge #3667 which remove this instruction?

@muttleyxd
Copy link
Contributor

There is still memory leak.

After investigation, it seems that the exit(0) instruction in UserApiTests destructor is responsible for it.

Shouldn't we first merge #3667 which remove this instruction?

#3667 is merged, so I think Travis should pass now

@etherealjoy
Copy link
Contributor

I restarted CI and it passed .

@etherealjoy etherealjoy added this to the 4.1.1 milestone Aug 23, 2019
@etherealjoy etherealjoy merged commit 1fc03c8 into OpenAPITools:master Aug 23, 2019
@MartinDelille MartinDelille deleted the add-valgrind branch August 23, 2019 13:40
@wing328
Copy link
Member

wing328 commented Aug 24, 2019

Intermittent CI tests failure due to

QDEBUG : UserApiTests::updateUserTest() got a request body
PASS   : UserApiTests::updateUserTest()
PASS   : UserApiTests::cleanupTestCase()
Totals: 10 passed, 0 failed, 0 skipped, 0 blacklisted, 381ms
********* Finished testing of UserApiTests *********
==28679== Invalid free() / delete / delete[] / realloc()
==28679==    at 0x4C2BDEC: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==28679==    by 0x5A55E2B: __libc_freeres (in /lib/x86_64-linux-gnu/libc-2.19.so)
==28679==    by 0x4A256BC: _vgnU_freeres (in /usr/lib/valgrind/vgpreload_core-amd64-linux.so)
==28679==    by 0x592916A: __run_exit_handlers (exit.c:97)
==28679==    by 0x59291F4: exit (exit.c:104)
==28679==    by 0x590EF4B: (below main) (libc-start.c:321)
==28679==  Address 0x5caf3c0 is 0 bytes inside data symbol "noai6ai_cached"
==28679== 
==28679== 
==28679== HEAP SUMMARY:
==28679==     in use at exit: 101,531 bytes in 179 blocks
==28679==   total heap usage: 25,270 allocs, 25,092 frees, 3,358,281 bytes allocated
==28679== 
==28679== 304 bytes in 1 blocks are possibly lost in loss record 131 of 144
==28679==    at 0x4C2CC70: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==28679==    by 0x4012EE4: allocate_dtv (dl-tls.c:296)
==28679==    by 0x4012EE4: _dl_allocate_tls (dl-tls.c:460)
==28679==    by 0x5CBED92: allocate_stack (allocatestack.c:589)
==28679==    by 0x5CBED92: pthread_create@@GLIBC_2.2.5 (pthread_create.c:500)
==28679==    by 0x4EE6675: QThread::start(QThread::Priority) (in /opt/qt510/lib/libQt5Core.so.5.10.1)
==28679==    by 0xAB8CA12: ??? (in /opt/qt510/lib/libQt5DBus.so.5.10.1)
==28679==    by 0xAB8DC8B: QDBusConnection::systemBus() (in /opt/qt510/lib/libQt5DBus.so.5.10.1)
==28679==    by 0xAB4B3F0: ??? (in /opt/qt510/plugins/bearer/libqconnmanbearer.so)
==28679==    by 0xAB5ED13: ??? (in /opt/qt510/plugins/bearer/libqconnmanbearer.so)
==28679==    by 0xAB4958F: ??? (in /opt/qt510/plugins/bearer/libqconnmanbearer.so)
==28679==    by 0x411FDF0: QNetworkConfigurationManagerPrivate::updateConfigurations() (in /opt/qt510/lib/libQt5Network.so.5.10.1)
==28679==    by 0x41200B2: QNetworkConfigurationManagerPrivate::initialize() (in /opt/qt510/lib/libQt5Network.so.5.10.1)
==28679==    by 0x411C110: qNetworkConfigurationManagerPrivate() (in /opt/qt510/lib/libQt5Network.so.5.10.1)
==28679== 
==28679== LEAK SUMMARY:
==28679==    definitely lost: 0 bytes in 0 blocks
==28679==    indirectly lost: 0 bytes in 0 blocks
==28679==      possibly lost: 304 bytes in 1 blocks
==28679==    still reachable: 101,227 bytes in 178 blocks
==28679==         suppressed: 0 bytes in 0 blocks
==28679== Reachable blocks (those to which a pointer was found) are not shown.
==28679== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==28679== 
==28679== For counts of detected and suppressed errors, rerun with: -v
==28679== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
Make sure the tests are launched:
Ok
Make sure the tests passed:
Ok
Check if no memory leaks occured:
There was memory leaks!!!
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (pet-test) on project CppQt5PetstoreClientTests: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]
[ERROR] 

Ref: https://travis-ci.org/OpenAPITools/openapi-generator/builds/576220434

Please take a look when you've time.

Have a nice weekend.

jimschubert added a commit that referenced this pull request Aug 25, 2019
* master: (45 commits)
  update python samples
  Two tiny fixes for Java Vertx client (#3683)
  Exclude "test" from packages so that it is not installed as top-level package when "pip installing" the generated sdk (#3731)
  [java-client] add unit test for JDK 11 HttpClient (#3735)
  [R] feat(r): handling error response for 3xx cases (#3571)
  [Dart] Avoid redundant null checking in fromJson (#3632)
  [core] Set isMultipart=true for multipart operations, fix possible NPE (#3750)
  reenable kotlin client tests in shippable ci (#3751)
  Fix null assignation to header/query param map (#3749)
  Mockito 3.0.0 (#3732)
  Update to swagger-parser to 2.0.14-OpenAPITools.org-1 (#3737)
  Add a link to a Qiita blog post (#3747)
  update csharp samples
  Simple spelling error in dotnet core comments (#3746)
  better support for multipart (#3736)
  [typescript-fetch] fix #1998: prefix req ifaces. (#3740)
  cpp-qt5-client: add valgrind memory test (#3663)
  [typescript-angular] Encode objects for multipart/form-data with json - fixes #2733 (#3738)
  [BUG] Https protocol schema is not handled correctly in java 11 native code #3729 (#3730)
  comment out kotlin client tests
  ...
@wing328
Copy link
Member

wing328 commented Aug 26, 2019

Even if the test passed, I still found Invalid free() / delete / delete[] / realloc() in the output:

QDEBUG : UserApiTests::updateUserTest() got a request body
PASS   : UserApiTests::updateUserTest()
PASS   : UserApiTests::cleanupTestCase()
Totals: 10 passed, 0 failed, 0 skipped, 0 blacklisted, 345ms
********* Finished testing of UserApiTests *********
==28578== Invalid free() / delete / delete[] / realloc()
==28578==    at 0x4C2BDEC: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==28578==    by 0x5A55E2B: __libc_freeres (in /lib/x86_64-linux-gnu/libc-2.19.so)
==28578==    by 0x4A256BC: _vgnU_freeres (in /usr/lib/valgrind/vgpreload_core-amd64-linux.so)
==28578==    by 0x592916A: __run_exit_handlers (exit.c:97)
==28578==    by 0x59291F4: exit (exit.c:104)
==28578==    by 0x590EF4B: (below main) (libc-start.c:321)
==28578==  Address 0x5caf3c0 is 0 bytes inside data symbol "noai6ai_cached"
==28578== 
==28578== 
==28578== HEAP SUMMARY:
==28578==     in use at exit: 101,227 bytes in 178 blocks
==28578==   total heap usage: 25,247 allocs, 25,070 frees, 3,308,372 bytes allocated
==28578== 
==28578== LEAK SUMMARY:
==28578==    definitely lost: 0 bytes in 0 blocks
==28578==    indirectly lost: 0 bytes in 0 blocks
==28578==      possibly lost: 0 bytes in 0 blocks
==28578==    still reachable: 101,227 bytes in 178 blocks
==28578==         suppressed: 0 bytes in 0 blocks
==28578== Reachable blocks (those to which a pointer was found) are not shown.
==28578== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==28578== 
==28578== For counts of detected and suppressed errors, rerun with: -v
==28578== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
Make sure the tests are launched:
Ok
Make sure the tests passed:
Ok
Check if no memory leaks occured:

Ref: https://travis-ci.org/OpenAPITools/openapi-generator/builds/576585660

@wing328
Copy link
Member

wing328 commented Aug 26, 2019

Commented out qt5 c++ tests via 7e772e1 as we plan to release 4.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants