Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-35494

fil_space_t::fil_space_t() is potentially unsafe with GCC -flifetime-dse

Details

    Description

      Starting with MDEV-8139, fil_space_t is no longer trivially constructible. In fil_space_t::create(), the object is being constructed using the following antipattern:

      	/* FIXME: if calloc() is defined as an inline function that calls
      	memset() or bzero(), then GCC 6 -flifetime-dse can optimize it away */
      	*after = space = new (ut_zalloc_nokey(sizeof(*space))) fil_space_t;
       
      	space->id = id;
       
      	UT_LIST_INIT(space->chain, &fil_node_t::chain);
       
      	space->purpose = purpose;
      	space->flags = flags;
      

      This needs to be refactored to an explicit fil_space_t::fil_space_t(), which will initialize all data fields, something like the following:

      *after = space = new (ut_malloc_nokey(*space)) fil_space_t(id, flags, purpose, crypt_data, mode);
      

      The fil_space_t::latch member will need some special care, because outside SUX_LOCK_GENERIC the implementation expects that the object be zero-initialized.

      Attachments

        Issue Links

          Activity

            The initialization of fil_space_t and other refactoring looks good to me. I have some minor comments/suggestion on the patch.

            debarun Debarun Banerjee added a comment - The initialization of fil_space_t and other refactoring looks good to me. I have some minor comments/suggestion on the patch.

            The changes look good to me. Added one comment.

            debarun Debarun Banerjee added a comment - The changes look good to me. Added one comment.

            I filed MDEV-35618 for an unrelated finding.

            marko Marko Mäkelä added a comment - I filed MDEV-35618 for an unrelated finding.

            origin/10.6-MDEV-35494 1a4b97f1b4dc4ad4b71f15f98ae3a4c83cf9e300 2024-12-03T10:12:15+02:00
            performed well in RQG testing. No new problems.

            mleich Matthias Leich added a comment - origin/10.6- MDEV-35494 1a4b97f1b4dc4ad4b71f15f98ae3a4c83cf9e300 2024-12-03T10:12:15+02:00 performed well in RQG testing. No new problems.

            People

              marko Marko Mäkelä
              marko Marko Mäkelä
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.