Note that there are some explanatory texts on larger screens.

plurals
  1. POSuspicious memory leak when using getopt lib in MySQL?
    primarykey
    data
    text
    <p><img src="https://i.stack.imgur.com/3yVYW.jpg" alt="Memory Usage and Thread Usage monitor"></p> <p>I am posting this post on behalf of my college.</p> <p>He found a suspicious memory leak when using the handle_option (MySQL getopt lib) to read config file (/etc/my.cnf)</p> <p>He execute the Source code below after malloc host_name, user name:</p> <pre><code>char* host_name; char* user_name; struct my_option mysql_confgs[] = { {"host", "h", "MySQL Server", (uchar**) &amp; host_name, NULL, NULL, GET_STR, REQUIRED_ARG, 0,0,0,0,0,0}, {"user", "u", "userID", "h",(uchar**) &amp; user_name, NULL, NULL, GET_STR, REQUIRED_ARG, 0,0,0,0,0,0} } handle_options(&amp;argc, &amp;argv, mysql_configs, aux_config_reader); </code></pre> <p>He mention about the method above is using Error(Segment) instead of using free(host_name) and free(user_name)? So this is the possible reason of causing memory leakage?</p> <p>Well.. I have zero basic on MySQL, so I might not able to delivery 100% of the problem description. So, feel free to query on this and I will update the details of problem descriptions as per the query.</p> <p>My college is having language barrier so I am posting on behalf of him.</p> <p>Valgrind Report: </p> <pre><code>480 bytes in 1 blocks are possibly lost in loss record 26 of 43 at 0x4A068FE: malloc (vg_replace_malloc.c:270) by 0x33E4E293C1: my_malloc (in /usr/lib64/mysql/libmysqlclient.so.16.0.0) by 0x33E4E2C974: alloc_root (in /usr/lib64/mysql/libmysqlclient.so.16.0.0) by 0x33E4E2E620: ??? (in /usr/lib64/mysql/libmysqlclient.so.16.0.0) by 0x33E4E2F838: my_load_defaults (in /usr/lib64/mysql/libmysqlclient.so.16.0.0) by 0x408BF1: MS_MYSQL_init (MS_MYSQL_O.h:109) by 0x438A39: main_proc (AccLab.c:221) by 0x437F8A: main (AccLab.c:67) 75,840 bytes in 158 blocks are definitely lost in loss record 41 of 43 at 0x4A068FE: malloc (vg_replace_malloc.c:270) by 0x33E4E293C1: my_malloc (in /usr/lib64/mysql/libmysqlclient.so.16.0.0) by 0x33E4E2C974: alloc_root (in /usr/lib64/mysql/libmysqlclient.so.16.0.0) by 0x33E4E2E620: ??? (in /usr/lib64/mysql/libmysqlclient.so.16.0.0) by 0x33E4E2F838: my_load_defaults (in /usr/lib64/mysql/libmysqlclient.so.16.0.0) by 0x408BF1: MS_MYSQL_init (MS_MYSQL_O.h:109) by 0x438A39: main_proc (AccLab.c:221) by 0x437F8A: main (AccLab.c:67) </code></pre> <p>LEAK SUMMARY:</p> <pre><code>definitely lost: 75,840 bytes in 158 blocks indirectly lost: 0 bytes in 0 blocks possibly lost: 2,304 bytes in 7 blocks still reachable: 9,675,408 bytes in 2,387 blocks suppressed: 0 bytes in 0 blocks Reachable blocks (those to which a pointer was found) are not shown. To see them, rerun with: --leak-check=full --show-reachable=yes For counts of detected and suppressed errors, rerun with: -v ERROR SUMMARY: 8 errors from 8 contexts (suppressed: 4 from 4) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload