Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-48116

init-order bug inside pcrecpp

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.7.0
    • Component/s: Internal Code
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Requested:
      v4.4
    • Sprint:
      Service arch 2020-05-18, Service arch 2020-06-01
    • Linked BF Score:
      50

      Description

      The fiasco is within pcrecpp.

      If we make an RE object too soon, it will reference some internal global state in the RE::Init pseudo-constructor, which might not yet be initialized. This benchmark is getting ProcessInfo at static init time, which gathers a lot of process metadata.

      BENCHMARK_REGISTER_F(CacheLatencyTest, BM_CacheLatency)
          ->RangeMultiplier(2 * 1024)
          // Loop over arrays of different sizes to test the L2, L3, and RAM latency.
          ->Range(256 * 1024, 4096 * 1024)
          ->ThreadRange(1, ProcessInfo::getNumAvailableCores());
      

      This call to getNumAvailableCores is the culprit. That function isn't currently safe at static init time.
      It incidentally causes an RE to be made for parsing the /proc/mountinfo file, before RE's static default_options object is initialized.
      This is a pcrecpp internal bug, and a fix should be upstreamed.

      https://github.com/vmg/pcre/blob/master/pcrecpp.cc#L86

      static RE_Options default_options;
      

      referring to this in a static initializer is an init-order fiasco trigger.

        Attachments

          Activity

            People

            Assignee:
            billy.donahue Billy Donahue
            Reporter:
            billy.donahue Billy Donahue
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: