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

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

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.7.8
    • Affects Version/s: None
    • Component/s: Geo
    • ALL

      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.

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

              Created:
              Updated:
              Resolved: