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

geo_validate.js depends on undefined behaviour (and fails on arm64)

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.7.8
    • Component/s: Geo
    • Labels:
    • Operating System:
      ALL

      Description

      This bit of geo_validate.js fails on arm64:

      assert.commandFailed(db.runCommand({geoNear: coll.getName(),
                                          near: [0,0], spherical: true, num: NaN}));

      Digging shows this to be because of this code in geo_near_cmd.cpp:

                  if (!eNumWanted.eoo()) {
                      uassert(17303, "limit must be number", eNumWanted.isNumber());
                      numWanted = eNumWanted.numberInt();
                      uassert(17302, "limit must be >=0", numWanted >= 0);
                  }

      .numberInt() on a double just casts the double value to an int. Unfortunately, I think casting a NaN to an int is undefined behaviour. On intel you get INT_MIN but on arm64 (and probably other platforms from what I read) you get 0, a perfectly valid value in this context, and so the test fails.

        Attachments

          Activity

            People

            Assignee:
            greg_10gen Greg Studer
            Reporter:
            mwhudson Michael Hudson-Doyle
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: