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

PS-9328: Fix valgrind errors in test_services.test_execute_prepared_s… #5431

Conversation

dlenev
Copy link
Contributor

@dlenev dlenev commented Sep 17, 2024

…tatement test.

Implementation of "mysql_statement_service" service which allows to execute normal and prepared SQL statements from components, didn't initialize arrays of value_t objects which it used to represent rows produced by SQL statement.

As result valgrind errors were generated when test_execute_prepared_statement test used this service and the service code tried to store some values in such a uninitialized array. This was done using value_t's "operator =". And since value_t is a specialization of std::variant template, its "operator =" needs to read old data in object being assigned into to correctly handle disposal of old value stored in it (and this old data was uninitialized in this case).

This patch fixes the problem by ensuring that we call default value_t constructor for elements of array in question after its allocation. It also fixes code which resets such arrays before reuse, instead of filling it with zeros using memset() (which is not guaranteed to work in general case), we simply reset each element of array by assigning std::monostate to it.

…tatement test.

Implementation of "mysql_statement_service" service which allows to execute
normal and prepared SQL statements from components, didn't initialize arrays
of value_t objects which it used to represent rows produced by SQL statement.

As result valgrind errors were generated when test_execute_prepared_statement
test used this service and the service code tried to store some values in such
a uninitialized array. This was done using value_t's "operator =". And since
value_t is a specialization of std::variant template, its "operator =" needs
to read old data in object being assigned into to correctly handle disposal
of old value stored in it (and this old data was uninitialized in this case).

This patch fixes the problem by ensuring that we call default value_t
constructor for elements of array in question after its allocation.
It also fixes code which resets such arrays before reuse, instead of filling
it with zeros using memset() (which is not guaranteed to work in general case),
we simply reset each element of array by assigning std::monostate to it.
Copy link
Collaborator

@percona-ysorokin percona-ysorokin left a comment

Choose a reason for hiding this comment

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

LGTM

@dlenev dlenev merged commit 9f60008 into percona:release-8.4.2-2 Sep 17, 2024
22 checks passed
@dlenev dlenev deleted the ps-9328-test_execute_prepared_statement-valgring-fix branch September 17, 2024 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants