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

errnoWithDescription always returns "Unknown error" on Linux

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 4.0.0
    • Fix Version/s: 4.1.13, 4.0.11
    • Component/s: Internal Code
    • Labels:
      None
    • Environment:
      Linux
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Requested:
      v4.0
    • Sprint:
      Sharding 2019-05-20, Sharding 2019-06-03

      Description

      Discovered on SERVER-40953, introduced on SERVER-34006, partial (incomplete) fixes on SERVER-39604, SERVER-38935, SERVER-37435, reduced diagnostics on SERVER-40693, SERVER-36809, SERVER-36600, SERVER-38633, SERVER-31081 and probably others.

      The cause is that #if !(__ANDROID_API__ <= 22) evaluates to false when __ANDROID_API__ isn't defined. This causes errnoWithDescription() to erroneously call the GNU strerror_r() from the code which handles the XSI strerror_r() variant. Since the GNU function always returns a non-NULL char * pointer, but XSI uses 0 for success and non-zero for failure, errnoWithDescription() always ends up returning kUnknownMsg.

      Linux:

      $ HOME=/root /omni/4.0.0/bin/mongo --nodb
      MongoDB shell version v4.0.0
      Welcome to the MongoDB shell.
      For interactive help, type "help".
      For more comprehensive documentation, see
              http://docs.mongodb.org/
      Questions? Try the support group
              http://groups.google.com/group/mongodb-user
      2019-05-06T16:31:28.707+1000 I STORAGE  [main] In File::open(), ::open for '/root/.mongorc.js' failed with Unknown error
      2019-05-06T16:31:28.707+1000 E -        [main] Error loading history file: FileOpenFailed: Unable to fopen() file /root/.dbshell: Unknown error
      >
      bye
      2019-05-06T16:31:29.845+1000 E -        [main] Error saving history file: FileOpenFailed: Unable to open() file /root/.dbshell: Unknown error
      $ HOME=/root /omni/3.6.12/bin/mongo --nodb
      MongoDB shell version v3.6.12
      Welcome to the MongoDB shell.
      For interactive help, type "help".
      For more comprehensive documentation, see
              http://docs.mongodb.org/
      Questions? Try the support group
              http://groups.google.com/group/mongodb-user
      2019-05-06T17:32:44.895+1000 I STORAGE  [main] In File::open(), ::open for '/root/.mongorc.js' failed with Permission denied
      2019-05-06T17:32:44.896+1000 E -        [main] Error loading history file: FileOpenFailed: Unable to fopen() file /root/.dbshell: Permission denied
      >
      bye
      2019-05-06T17:32:46.054+1000 E -        [main] Error saving history file: FileOpenFailed: Unable to open() file /root/.dbshell: Permission denied
      $ 
      

      MacOS:

      $ HOME=/ mongo --nodb
      MongoDB shell version v4.0.6
      Welcome to the MongoDB shell.
      For interactive help, type "help".
      For more comprehensive documentation, see
          http://docs.mongodb.org/
      Questions? Try the support group
          http://groups.google.com/group/mongodb-user
      2019-05-06T15:23:51.115+1000 I STORAGE  [main] In File::open(), ::open for '//.mongorc.js' failed with Permission denied
      >
      bye
      2019-05-06T15:24:13.495+1000 E -        [main] Error saving history file: FileOpenFailed: Unable to open() file //.dbshell: Permission denied
      $ 
      

      Windows:

      C:\>mongo --nodb
      MongoDB shell version v4.0.4
      Welcome to the MongoDB shell.
      For interactive help, type "help".
      For more comprehensive documentation, see
              http://docs.mongodb.org/
      Questions? Try the support group
              http://groups.google.com/group/mongodb-user
      2019-05-06T15:35:05.212+1000 I STORAGE  [main] In File::open(), CreateFileW for 'C:\\.mongorc.js' failed with A required privilege is not held by the client.
      > exit
      bye
      2019-05-06T15:40:48.635+1000 E -        [main] Error saving history file: FileOpenFailed: Unable to fopen() file C:\/.dbshell: A required privilege is not held by the client.
       
      C:\>
      

      $ cat test-cpp-comparison.cpp
      #include <iostream>
       
      int main(int argc, char *argv[]) {
      #if FOOBARBAZ >= 10
              std::cerr << "unsafe: greater than or equal to 10" << std::endl;
      #elif !(FOOBARBAZ >= 10)
              std::cerr << "unsafe: less than 10" << std::endl;
      #else
              std::cerr << "unsafe: neither" << std::endl;
      #endif
      #if defined(FOOBARBAZ) && FOOBARBAZ >= 10
              std::cerr << "safe: greater than or equal to 10" << std::endl;
      #elif defined(FOOBARBAZ) && !(FOOBARBAZ >= 10)
              std::cerr << "safe: less than 10" << std::endl;
      #else
              std::cerr << "safe: neither" << std::endl;
      #endif
              return 0;
      }
      $ g++ -o test-cpp-comparison test-cpp-comparison.cpp
      $ ./test-cpp-comparison
      unsafe: less than 10
      safe: neither
      $
      

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: