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

BUG#1618634 [sql] [binlog] fix undefined behavior #947

Closed
wants to merge 1 commit into from

Conversation

bryonglodencissp
Copy link

@bryonglodencissp bryonglodencissp commented Aug 30, 2016

Greetings, on line number 7072 of ‘sql/binlog.cc’ there is a double-delete causing undefined behavior.

So, after calling ‘delete pending’ the first time (on line number 7067), we should do pending= NULL, so if (by any chance), ‘delete pending’ is called again, nothing will happen.

REF: https://bugs.launchpad.net/percona-server/+bug/1618634

[sql/binlog.cc:7072]: (error) Memory pointed to by 'pending' is freed twice.

Found by https://github.com/cppcheck/bryongloden
@laurynas-biveinis laurynas-biveinis self-assigned this Sep 2, 2016
@laurynas-biveinis
Copy link
Contributor

The code in question reads

  if (Rows_log_event* pending= cache_data->pending())
  {
    /*
      Write pending event to the cache.
    */
    if (cache_data->write_event(thd, pending))
    {
      set_write_error(thd, is_transactional);
      if (check_write_error(thd) && cache_data &&
          stmt_cannot_safely_rollback(thd))
        cache_data->set_incident();
      delete pending;
      cache_data->set_pending(NULL);
      DBUG_RETURN(1);
    }

    delete pending;
  }

If the first delete pending is executed, the method returns (DBUG_RETURN(1)). Thus there is no way to reach the 2nd delete pending from the 1st one.

@laurynas-biveinis
Copy link
Contributor

Please open new bugs/PRs should you find new issues. Thanks!

satya-bodapati pushed a commit to satya-bodapati/percona-server that referenced this pull request Feb 22, 2019
)

Summary:
Jira issue: https://jira.percona.com/browse/FB8-49

Reference patch: facebook/mysql-5.6@915b131

MySQL client doesn't remove padding chars for binary columns. Do the same for RBR. Tools parsing the replication stream vs. the client output can then use memcmp to compare keys. Otherwise, the tools need to handle padding characters correctly.
Pull Request resolved: facebook/mysql-5.6#947

Reviewed By: hermanlee

Differential Revision: D13972586

Pulled By: hermanlee

fbshipit-source-id: a00cb7ab748
inikep pushed a commit to inikep/percona-server that referenced this pull request Apr 23, 2020
)

Summary:
Jira issue: https://jira.percona.com/browse/FB8-49

Reference patch: facebook/mysql-5.6@915b131

MySQL client doesn't remove padding chars for binary columns. Do the same for RBR. Tools parsing the replication stream vs. the client output can then use memcmp to compare keys. Otherwise, the tools need to handle padding characters correctly.
Pull Request resolved: facebook/mysql-5.6#947

Reviewed By: hermanlee

Differential Revision: D13972586

Pulled By: hermanlee

fbshipit-source-id: 310bf42d7fb
inikep pushed a commit to inikep/percona-server that referenced this pull request Feb 24, 2021
)

Summary:
Jira issue: https://jira.percona.com/browse/FB8-49

Reference patch: facebook/mysql-5.6@915b131

MySQL client doesn't remove padding chars for binary columns. Do the same for RBR. Tools parsing the replication stream vs. the client output can then use memcmp to compare keys. Otherwise, the tools need to handle padding characters correctly.
Pull Request resolved: facebook/mysql-5.6#947

Reviewed By: hermanlee

Differential Revision: D13972586

Pulled By: hermanlee

fbshipit-source-id: 310bf42d7fb
inikep pushed a commit to inikep/percona-server that referenced this pull request Nov 15, 2021
) (percona#947)

Summary:
Jira issue: https://jira.percona.com/browse/FB8-49

Reference patch: facebook/mysql-5.6@915b131

MySQL client doesn't remove padding chars for binary columns. Do the same for RBR. Tools parsing the replication stream vs. the client output can then use memcmp to compare keys. Otherwise, the tools need to handle padding characters correctly.
Pull Request resolved: facebook/mysql-5.6#947

Differential Revision: D13972586 (facebook/mysql-5.6@2b73efa)

Pulled By: hermanlee

fbshipit-source-id: a1bf6e34e76
ldonoso pushed a commit to ldonoso/percona-server that referenced this pull request Mar 15, 2022
) (percona#947)

Summary:
Jira issue: https://jira.percona.com/browse/FB8-49

Reference patch: facebook/mysql-5.6@915b131

MySQL client doesn't remove padding chars for binary columns. Do the same for RBR. Tools parsing the replication stream vs. the client output can then use memcmp to compare keys. Otherwise, the tools need to handle padding characters correctly.
Pull Request resolved: facebook/mysql-5.6#947

Differential Revision: D13972586

Pulled By: hermanlee
ldonoso pushed a commit to ldonoso/percona-server that referenced this pull request Mar 15, 2022
) (percona#947)

Summary:
Jira issue: https://jira.percona.com/browse/FB8-49

Reference patch: facebook/mysql-5.6@915b131

MySQL client doesn't remove padding chars for binary columns. Do the same for RBR. Tools parsing the replication stream vs. the client output can then use memcmp to compare keys. Otherwise, the tools need to handle padding characters correctly.
Pull Request resolved: facebook/mysql-5.6#947

Differential Revision: D13972586

Pulled By: hermanlee
ldonoso pushed a commit to ldonoso/percona-server that referenced this pull request Mar 18, 2022
) (percona#947)

Summary:
Jira issue: https://jira.percona.com/browse/FB8-49

Reference patch: facebook/mysql-5.6@915b131

MySQL client doesn't remove padding chars for binary columns. Do the same for RBR. Tools parsing the replication stream vs. the client output can then use memcmp to compare keys. Otherwise, the tools need to handle padding characters correctly.
Pull Request resolved: facebook/mysql-5.6#947

Differential Revision: D13972586

Pulled By: hermanlee
ldonoso pushed a commit to ldonoso/percona-server that referenced this pull request Apr 12, 2022
) (percona#947)

Summary:
Jira issue: https://jira.percona.com/browse/FB8-49

Reference patch: facebook/mysql-5.6@915b131

MySQL client doesn't remove padding chars for binary columns. Do the same for RBR. Tools parsing the replication stream vs. the client output can then use memcmp to compare keys. Otherwise, the tools need to handle padding characters correctly.
Pull Request resolved: facebook/mysql-5.6#947

Differential Revision: D13972586

Pulled By: hermanlee
inikep pushed a commit to inikep/percona-server that referenced this pull request Apr 17, 2024
) (percona#947)

Summary:
Jira issue: https://jira.percona.com/browse/FB8-49

Reference patch: facebook/mysql-5.6@915b131

MySQL client doesn't remove padding chars for binary columns. Do the same for RBR. Tools parsing the replication stream vs. the client output can then use memcmp to compare keys. Otherwise, the tools need to handle padding characters correctly.
Pull Request resolved: facebook/mysql-5.6#947

Differential Revision: D13972586

Pulled By: hermanlee
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