Bug #120487 MySQLServerMock debug output prints an empty string due to use-after-move
| Submitted: | 17 May 10:47 | Modified: | 28 Oct 18:09 |
|---|---|---|---|
| Reporter: | S F. | Email Updates: | |
| Status: | Verified | Impact on me: | |
| Category: | MySQL Router | Severity: | S3 (Non-critical) |
| Version: | MySQL 9.6.0, commit 447eb26e094b444a88c5 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
| Tags: | mock-server, router | ||
[28 Oct 18:09]
Miguel Araujo
Thank you for the report. Verified: the debug message uses the moved-from parameter instead of expected_queries_file_. Printing expected_queries_file_, as suggested, is the correct fix.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.051 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: MySQLServerMock::MySQLServerMock moves the expected_queries_file constructor parameter into expected_queries_file_ in the initializer list, then prints the moved-from parameter when debug_mode_ is enabled. After the move, the parameter is valid but its value is unspecified. In practice it prints an empty filename: ```cpp expected_queries_file_{std::move(expected_queries_file)}, // ... std::cout << "\n\nExpected SQL queries come from file '" << expected_queries_file << "'\n\n" << std::flush; ``` How to repeat: Compile a small program that constructs server_mock::MySQLServerMock with debug_mode=true and a non-empty expected_queries_file. Observed output: Expected SQL queries come from file '' Expected output should include the actual filename. Suggested fix: Print the member that owns the moved string: ```cpp std::cout << "\n\nExpected SQL queries come from file '" << expected_queries_file_ << "'\n\n" << std::flush; ```