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

Clang with --link-model=dynamic produces binaries that behave incorrectly with respect to decimal128

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.7.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Fully Compatible
    • ALL
    • Dev Platform 2020-07-27

      I have a checkout of master at 0b2b705b0de0e0f7f8ba28604dc5585a5dc5ba0b and the enterprise modules 2c965327da25f25e974e3402c891ddca82b096ef. I am building on Ubuntu 18.04 with the v3 mongodbtoolchain version of clang. This produces build artifacts which fail a number of basic tests which all seem to be related to decimal128. Here's how I'm building:

      $ cat ~/.scons/site_scons/mongo_custom_variables.py
      # We these for short_describe below.
      import os
      import subprocess
      
      CCACHE="ccache"
      ICECC="icecc"
      
      # A little function that gives me a real mongo version, but without the git hash.
      def short_describe():
          import os
          import subprocess
          with open(os.devnull, "r+") as devnull:
              proc = subprocess.Popen("git describe --abbrev=0",
                  stdout=subprocess.PIPE,
                  stderr=devnull,
                  stdin=devnull,
                  shell=True)
              return proc.communicate()[0].decode('utf-8').strip()[1:]
      
      MONGO_VERSION=short_describe()
      MONGO_GIT_HASH="unknown"
      
      CC="/opt/mongodbtoolchain/v3/bin/clang"
      CXX="/opt/mongodbtoolchain/v3/bin/clang++"
      
      $ python3 buildscripts/scons.py --link-model=dynamic --ninja generate-ninja
      $ ninja -j 500 build/install/bin/bson_test
      

      The resulting bson_test fails like so:

      $ build/install/bin/bson_test
      ...
      {"t":{"$date":"2020-07-08T19:43:27.946Z"},"s":"I",  "c":"TEST",     "id":23068,   "ctx":"main","msg":"FAILURE","attr":{"failedTestsCount":4,"failedSuitesCount":2,"failedTests":["BSONElementIntegerParseTest/ParseIntegerElementToNonNegativeLongRejectsNonIntegralDecimal","BSONElementIntegerParseTest/ParseIntegerElementToLongRejectsNonIntegralDecimal","BSONElementIntegerParseTest/ParseIntegerElementToLongRejectsLargestDecimal","BSONObjCompare/NumberDecimalCompareDoubleNoDoubleRepresentation"]}}
      

      These are the two failing assertions:

      I haven't checked whether the problem still repros without ninja or without icecream. I do know that it does not repro with static linking and it does not repro with gcc.

            Assignee:
            andrew.morrow@mongodb.com Andrew Morrow (Inactive)
            Reporter:
            david.storch@mongodb.com David Storch
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: