jump or move depends on uninitialised value in my_type_to_string
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
MariaDB |
Fix Released
|
Undecided
|
Unassigned | ||
PBXT |
Fix Released
|
Undecided
|
Vladimir Kolesnikov |
Bug Description
valgrind see 2 jump or move depends on uninitialised value in my_type_to_string in cast test:
==11018== Conditional jump or move depends on uninitialised value(s)
==11018== at 0x5AAF7D: String::c_ptr() (sql_string.h:110)
==11018== by 0x9BC1A7: my_type_
==11018== by 0x9BC42D: XTDDColumnFacto
==11018== by 0x9BC6D1: myxt_create_
==11018== by 0x9AB221: ha_pbxt:
==11018== by 0x7A4B26: handler:
==11018== by 0x7A7C19: ha_create_
==11018== by 0x75875B: rea_create_
==11018== by 0x7C61BE: mysql_create_
==11018== by 0x7C658F: mysql_create_
==11018== by 0x67C4AA: mysql_execute_
==11018== by 0x683ECE: mysql_parse(THD*, char const*, unsigned int, char const**) (sql_parse.cc:5979)
==11018== by 0x684CD8: dispatch_
==11018== by 0x68602C: do_command(THD*) (sql_parse.cc:862)
==11018== by 0x671F79: handle_
==11018== by 0x5048016: start_thread (in /lib64/
==11018==
==11018== Conditional jump or move depends on uninitialised value(s)
==11018== at 0x9CBC3F: xt_strcat(unsigned long, char*, char const*) (strutil_xt.cc:75)
==11018== by 0x9BC207: my_type_
==11018== by 0x9BC42D: XTDDColumnFacto
==11018== by 0x9BC6D1: myxt_create_
==11018== by 0x9AB221: ha_pbxt:
==11018== by 0x7A4B26: handler:
==11018== by 0x7A7C19: ha_create_
==11018== by 0x75875B: rea_create_
==11018== by 0x7C61BE: mysql_create_
==11018== by 0x7C658F: mysql_create_
==11018== by 0x67C4AA: mysql_execute_
==11018== by 0x683ECE: mysql_parse(THD*, char const*, unsigned int, char const**) (sql_parse.cc:5979)
==11018== by 0x684CD8: dispatch_
==11018== by 0x68602C: do_command(THD*) (sql_parse.cc:862)
==11018== by 0x671F79: handle_
==11018== by 0x5048016: start_thread (in /lib64/
for more cases see:
http://
http://
http://
Can be repeated if run pbxt test suite under valgrind (valgrind build (one of BUILD/compile*
Related branches
Changed in pbxt: | |
assignee: | nobody → Vladimir Kolesnikov (vkolesnikov) |
status: | New → In Progress |
Changed in pbxt: | |
status: | In Progress → Fix Committed |
Changed in pbxt: | |
status: | Fix Committed → Fix Released |
Changed in maria: | |
status: | New → Fix Released |
Hi!
>>>>> "Oleksandr" == Oleksandr Byelkin <Oleksandr> writes:
Oleksandr> ** Also affects: maria
Oleksandr> Importance: Undecided
Oleksandr> Status: New
Oleksandr> -- /bugs.launchpad .net/bugs/ 451085
Oleksandr> jump or move depends on uninitialised value in my_type_to_string
Oleksandr> https:/
Oleksandr> You received this bug notification because you are a member of Maria-
Oleksandr> captains, which is the registrant for Maria.
Oleksandr> Status in Maria: New
Oleksandr> Status in PrimeBase XT: New
Oleksandr> Bug description: to_string( XTThread* , Field*, st_table*) (myxt_xt.cc:2820) ry::createFromM ySQLField( XTThread* , st_table*, Field*) (myxt_xt.cc:3266)
Oleksandr> valgFrind see 2 jump or move depends on uninitialised value in my_type_to_string in cast test:
Oleksandr> ==11018== Conditional jump or move depends on uninitialised value(s)
Oleksandr> ==11018== at 0x5AAF7D: String::c_ptr() (sql_string.h:110)
Oleksandr> ==11018== by 0x9BC1A7: my_type_
Oleksandr> ==11018== by 0x9BC42D: XTDDColumnFacto
The reason for c_ptr() giving an error is that this function checks if
the end pointer is zero, which in some cases may be not initialized
memory (this is still safe in 99.999% of all cases as all strings
points to thread specific memory).
<cut>
Proposed fix:
ptr = type.c_ptr(); sizeof( buffer) , buffer, ptr);
if (ptr != buffer)
xt_strcpy(
-> min(sizeof( buffer) -1,type. length( ), buffer, ptr);
ptr = type.ptr();
if (ptr != buffer)
xt_strcpy(
An even better solution would be to introduce xt_strmake()
char *xt_strmake( register char *dst, register const char *src, size_t length)
{
memcpy(dst, src, length);
dst[length]= 0;
}
and then use this instead of xt_strcpy()
This would be the fastest solution...
Regards,
Monty