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

dead code in the thr_rwlock.c

    XMLWordPrintable

Details

    Description

      Part of `mysys/thr_rwlock.c` is licensed with a Sun RPC license. We have found this occurrence while converting MariaDB package on Fedora to SPDX style license where we have to check for all licenses contained in the project. The problem with this license is that it is marked as a 'Not-Allowed' license on fedora.

      After further investigation, we have figured out that the licensed code is limited only to these functions:

      int my_rwlock_init
      int my_rwlock_destroy
      int my_rw_rdlock
      int my_rw_wrlock
      int my_rw_unlock
      

      All of them are contained in an if statement in a macro `#if defined(NEED_MY_RW_LOCK)`. Consulting CMake files got us to a conclusion that it is never true on a POSIX systems (and Solaris systems) as it depends on 3 other variables: `USE_MUTEX_INSTEAD_OF_RW_LOCKS`, `HAVE_PTHREAD_RWLOCK_RDLOCK` and `HAVE_RWLOCK_INIT` - all of them have to be undefined to make `NEED_MY_RW_LOCK` defined and make the Sun RPC code end up in resulting binaries. The `HAVE_PTHREAD_RWLOCK_RDLOCK` variable is defined when CMake can find `pthread_rwlock_rdlock` function present in the system. It is a POSIX function AFAIK, hence the code shouldn't really be compiled on POSIX compatible systems like Fedora. Also, it seems that the code isn't really used for Windows either?, so I am not sure on when the code is actually used.

      We have created a downstream patch that removes this piece of code just to be safe, but we thought we should give you a heads-up on whether this is something you would want to keep in future versions of MariaDB. I personally don't know what went into the decision to not allow Sun RPC licenses in Fedora, but maybe the same reasoning might apply to you.

      MySQL also removed this code a while back, in 2014, which was only after the initial fork of MariaDB, so the new code for the file never ended up in MariaDB. https://github.com/mysql/mysql-server/commit/726523bc1280a838bab5c094d44c219c0270ca39 this is the commit that changed the code. It's apparently a whole refactoring of the `rwlock` implementation, so we didn't go the route of applying this as a downstream patch (instead of removing the code), since it does cover over a thousand changes over 47 files.

      Attachments

        Activity

          People

            serg Sergei Golubchik
            anezbeda Ales Nezbeda
            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.