-
-
Notifications
You must be signed in to change notification settings - Fork 141
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
bug: valgrind: definitely lost: 21 bytes in 1 blocks #60
Labels
Milestone
Comments
RingsC
changed the title
bug: definitely lost: 21 bytes in 1 blocks
bug: valgrind: definitely lost: 21 bytes in 1 blocks
Jun 20, 2022
"add_ pfs_ instr_ to_ array" function code: int add_pfs_instr_to_array(const char* name, const char* value)
{
int name_length= strlen(name);
int value_length= strlen(value);
/* Allocate structure plus string buffers plus null terminators */
PFS_instr_config* e = (PFS_instr_config*)my_malloc(sizeof(PFS_instr_config)
+ name_length + 1 + value_length + 1, MYF(MY_WME));
if (!e) return 1;
/* Copy the instrument name */
e->m_name= (char*)e + sizeof(PFS_instr_config);
memcpy(e->m_name, name, name_length);
e->m_name_length= name_length;
e->m_name[name_length]= '\0';
/* Set flags accordingly */
if (!my_strcasecmp(&my_charset_latin1, value, "counted"))
{
e->m_enabled= true;
e->m_timed= false;
}
else
if (!my_strcasecmp(&my_charset_latin1, value, "true") ||
!my_strcasecmp(&my_charset_latin1, value, "on") ||
!my_strcasecmp(&my_charset_latin1, value, "1") ||
!my_strcasecmp(&my_charset_latin1, value, "yes"))
{
e->m_enabled= true;
e->m_timed= true;
}
else
if (!my_strcasecmp(&my_charset_latin1, value, "false") ||
!my_strcasecmp(&my_charset_latin1, value, "off") ||
!my_strcasecmp(&my_charset_latin1, value, "0") ||
!my_strcasecmp(&my_charset_latin1, value, "no"))
{
e->m_enabled= false;
e->m_timed= false;
}
else
{
my_free(e);
return 1;
}
/* Add to the array of default startup options */
if (insert_dynamic(&pfs_instr_config_array, &e)) //When a problem occurs, the insert succeeds and returns false, resulting in no free
{
my_free(e);
return 1;
}
return 0;
} In "insert_dynamic "function, the" memcpy "is used to insert" element "into" buffer "instead of direct address passing. The successful insertion returns false, resulting in no free for" element ".
int add_pfs_instr_to_array(const char* name, const char* value)
{
int name_length= strlen(name);
int value_length= strlen(value);
/* Allocate structure plus string buffers plus null terminators */
PFS_instr_config* e = (PFS_instr_config*)my_malloc(sizeof(PFS_instr_config)
+ name_length + 1 + value_length + 1, MYF(MY_WME));
if (!e) return 1;
/* Copy the instrument name */
e->m_name= (char*)e + sizeof(PFS_instr_config);
memcpy(e->m_name, name, name_length);
e->m_name_length= name_length;
e->m_name[name_length]= '\0';
/* Set flags accordingly */
if (!my_strcasecmp(&my_charset_latin1, value, "counted"))
{
e->m_enabled= true;
e->m_timed= false;
}
else
if (!my_strcasecmp(&my_charset_latin1, value, "true") ||
!my_strcasecmp(&my_charset_latin1, value, "on") ||
!my_strcasecmp(&my_charset_latin1, value, "1") ||
!my_strcasecmp(&my_charset_latin1, value, "yes"))
{
e->m_enabled= true;
e->m_timed= true;
}
else
if (!my_strcasecmp(&my_charset_latin1, value, "false") ||
!my_strcasecmp(&my_charset_latin1, value, "off") ||
!my_strcasecmp(&my_charset_latin1, value, "0") ||
!my_strcasecmp(&my_charset_latin1, value, "no"))
{
e->m_enabled= false;
e->m_timed= false;
}
else
{
my_free(e);
return 1;
}
/* Add to the array of default startup options */
if (insert_dynamic(&pfs_instr_config_array, &e)) //When a problem occurs, the insert succeeds and returns false, resulting in no free
{
my_free(e);
return 1;
}
my_free(e); //Increase the release of local dynamic variables regardless of the success of "insert_dynamic"
return 0;
} |
This was referenced Jun 30, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the problem
【error】definitely lost: 21 bytes in 1 blocks
【error promot】21 bytes in 1 blocks are definitely lost in loss record 5 of 316
at 0x484147B: calloc (vg_replace_malloc.c:1328)
by 0xBFECE9: my_malloc (my_malloc.c:38)
by 0xE1A368: add_pfs_instr_to_array(char const*, char const*) (pfs_server.cc:251)
by 0x897A8B: mysqld_get_one_option (mysqld.cc:8792)
by 0xC0FE1C: my_handle_options (my_getopt.cc:613)
by 0x89AA85: handle_early_options() (mysqld.cc:6881)
by 0x89FC72: mysqld_main(int, char**) (mysqld.cc:5272)
by 0x4B22082: (below main) (libc-start.c:308)
Expected behavior
no definitely lost
How To Reproduce
1、create database tpch;
2、use tpch;
3、create table,example:
CREATE TABLE NATION (
N_NATIONKEY INTEGER NOT NULL,
N_NAME CHAR(25) NOT NULL,
N_REGIONKEY INTEGER NOT NULL,
N_COMMENT VARCHAR(152),
primary key (n_nationkey)
);
Environment
1、Ubuntu 20.04.4
2、valgrind-3.19.0
Additional context
no
The text was updated successfully, but these errors were encountered: