Bug #110516 Github sample code memory leaks
Submitted: 27 Mar 2023 17:21 Modified: 28 Jun 2024 13:11
Reporter: Vitalii Kaplenko Email Updates:
Status: No Feedback Impact on me:
None 
Category:Connector / C++ Severity:S3 (Non-critical)
Version:8.0.32 OS:Ubuntu (22.04)
Assigned to: MySQL Verification Team CPU Architecture:x86 (Intel Core i5 10th GEN)
Tags: connector c++, debug builds, Sample, valgrind error

[27 Mar 2023 17:21] Vitalii Kaplenko
Description:
Dear, MySQL team,

After 

$ sudo apt install mysql-server

And debug builds MySQL Connector/C++ and Sample code from (https://github.com/mysql/mysql-connector-cpp) I've run 

$ valgrind --leak-check=full ./sampleCodeExecutable

without any changes in the Sample source code and got expected error:

Creating session on mysqlx://root@127.0.0.1 ...
ERROR: CDK Error: Access denied for user 'root'@'localhost' (using password: NO)

But after that were Valgrind's errors:

==56868== 
==56868== HEAP SUMMARY:
==56868==     in use at exit: 80 bytes in 2 blocks
==56868==   total heap usage: 13,748 allocs, 13,746 frees, 1,797,811 bytes allocated
==56868== 
==56868== LEAK SUMMARY:
==56868==    definitely lost: 0 bytes in 0 blocks
==56868==    indirectly lost: 0 bytes in 0 blocks
==56868==      possibly lost: 0 bytes in 0 blocks
==56868==    still reachable: 80 bytes in 2 blocks
==56868==         suppressed: 0 bytes in 0 blocks
==56868== Reachable blocks (those to which a pointer was found) are not shown.
==56868== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==56868== 
==56868== For lists of detected and suppressed errors, rerun with: -s
==56868== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

How to repeat:
- Install MySQL Community Server

- Build debug MySQL Connector/C++ and Sample code

- Run valgrind --leak-check=full ./sampleCodeExecutable 
  without any changes to MySQL Community Server and the Sample code.

Suggested fix:
No ideas.
[10 Apr 2023 17:28] Vitalii Kaplenko
When I've tried to compile & run

// === main.cpp ===
#include <iostream>

int main()
{}
// ================

$ valgrind --leak-check=full ./mainExecutable

==43334== Memcheck, a memory error detector
==43334== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==43334== Using Valgrind-3.20.0 and LibVEX; rerun with -h for copyright info
==43334== Command: ./memorier
==43334== 
==43334== 
==43334== HEAP SUMMARY:
==43334==     in use at exit: 0 bytes in 0 blocks
==43334==   total heap usage: 1 allocs, 1 frees, 72,704 bytes allocated
==43334== 
==43334== All heap blocks were freed -- no leaks are possible

It was fine, But 

When I've tried to compile & run

// === main.cpp ===
#include <iostream>
#include <mysqlx/xdevapi.h>

int main()
{}
// ================

$ valgrind --leak-check=full ./mainExecutable

==43479== Memcheck, a memory error detector
==43479== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==43479== Using Valgrind-3.20.0 and LibVEX; rerun with -h for copyright info
==43479== Command: ./memorier
==43479== 
==43479== 
==43479== HEAP SUMMARY:
==43479==     in use at exit: 80 bytes in 2 blocks
==43479==   total heap usage: 417 allocs, 415 frees, 99,049 bytes allocated
==43479== 
==43479== LEAK SUMMARY:
==43479==    definitely lost: 0 bytes in 0 blocks
==43479==    indirectly lost: 0 bytes in 0 blocks
==43479==      possibly lost: 0 bytes in 0 blocks
==43479==    still reachable: 80 bytes in 2 blocks
==43479==         suppressed: 0 bytes in 0 blocks
==43479== Reachable blocks (those to which a pointer was found) are not shown.
==43479== To see them, rerun with: --leak-check=full --show-leak-kinds=all

So adding

#include <mysqlx/xdevapi.h>

to empty cpp-file with the only

int main(){}

causes memory leaks.
[28 May 2024 13:11] MySQL Verification Team
Hello Vitalii Kaplenko,

Thank you for the bug report.
Please upgrade to latest version and report us back if issue persist even in latest version along with test case. Thank you.

Regards,
Ashwini Patil
[29 Jun 2024 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".