Skip to content

MDEV-39241: THD::backup_commit_lock warning dangling-pointer#4891

Open
grooverdan wants to merge 1 commit intoMariaDB:10.11from
grooverdan:MDEV-39241
Open

MDEV-39241: THD::backup_commit_lock warning dangling-pointer#4891
grooverdan wants to merge 1 commit intoMariaDB:10.11from
grooverdan:MDEV-39241

Conversation

@grooverdan
Copy link
Copy Markdown
Member

The mechanisms of XA backup locks use a stack allocated mdl_request object. This is passed and stored in the THD object. Compilers complain about this behaviour because the lifetime of the THD->backup_commit_lock may exceed the lifetime of the stack variable mdl_request.

As the complier is also free to reuse the memory of mdl_request after its last reference in the code, the lifetime of the variable isn't defined after the function call to trans_xa_get_backup_lock.

As the THD has an allocation mechanism defined, and can release used memory, lets change this implementation and be explicit, and not rely on the compiler doing the right thing in the realm of undefined behaviour.

Caused by MDEV-39241.

The mechanisms of XA backup locks use a stack allocated
mdl_request object. This is passed and stored in the THD
object. Compilers complain about this behaviour because
the lifetime of the THD->backup_commit_lock may exceed the
lifetime of the stack variable mdl_request.

As the complier is also free to reuse the memory of
mdl_request after its last reference in the code, the
lifetime of the variable isn't defined after the function
call to trans_xa_get_backup_lock.

As the THD has an allocation mechanism defined, and can
release used memory, lets change this implementation and
be explicit, and not rely on the compiler doing the right
thing in the realm of undefined behaviour.

Caused by MDEV-39241.
@grooverdan grooverdan requested a review from knielsen April 2, 2026 03:48
@grooverdan grooverdan added the MariaDB Foundation Pull requests created by MariaDB Foundation label Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

MariaDB Foundation Pull requests created by MariaDB Foundation

Development

Successfully merging this pull request may close these issues.

1 participant