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

    XMLWordPrintable

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

            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.