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

mongo shell crashes if the OS name cannot be determined

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Shell
    • None
    • Fully Compatible
    • ALL
    • Hide

      Run mongo in an environment where none of the files listed in the strace extract above exist.

      Show
      Run mongo in an environment where none of the files listed in the strace extract above exist.

      The mongo command will crash if the OS name cannot be determined.

      → mongo localhost:57017MongoDB shell version v3.4.4connecting to: localhost:570172017-08-23T09:07:03.105+0100 I -        [thread1] Invariant failure !driverName.empty() && !driverVersion.empty() && !osType.empty() && !osName.empty() && !osArchitecture.empty() && !osVersion.empty() src/mongo/rpc/metadata/client_metadata.cpp 3502017-08-23T09:07:03.105+0100 I -        [thread1] ***aborting after invariant() failure2017-08-23T09:07:03.112+0100 F -        [thread1] Got signal: 6 (Aborted). 0xd64e7afa41 0xd64e7aeb59 0xd64e7af03d 0x7f86db6fca80 0x7f86db37f2c4 0x7f86db38072a 0xd64e448c8a 0xd64e6764bd 0xd64e676810 0xd64e4ebdf1 0xd64e4ec6f5 0xd64e4dd86d 0xd64e51c041 0xd64e6c9032 0xd64e6bc003 0xd64ede08ff 0xd64eddc5da 0xd64ede0303 0xd64ede6dff 0xd64ede6f81 0xd64ec8f32a 0xd64ec8f3d0 0xd64e6b7581 0xd64e7180bd 0xd64e6ba458 0xd64e6e69f2 0xd64e69bd0c 0x7f86dbee84a0 0x7f86db6f2454 0x7f86db4347bf----- BEGIN BACKTRACE -----{"backtrace":[{"b":"D64DFC2000","o":"7EDA41","s":"_ZN5mongo15printStackTraceERSo"},{"b":"D64DFC2000","o":"7ECB59"},{"b":"D64DFC2000","o":"7ED03D"},{"b":"7F86DB6EB000","o":"11A80"},{"b":"7F86DB34C000","o":"332C4","s":"gsignal"},{"b":"7F86DB34C000","o":"3472A","s":"abort"},{"b":"D64DFC2000","o":"486C8A","s":"_ZN5mongo17invariantOKFailedEPKcRKNS_6StatusES1_j"},{"b":"D64DFC2000","o":"6B44BD","s":"_ZN5mongo14ClientMetadata16serializePrivateENS_10StringDataES1_S1_S1_S1_S1_S1_PNS_14BSONObjBuilderE"},{"b":"D64DFC2000","o":"6B4810","s":"_ZN5mongo14ClientMetadata9serializeENS_10StringDataES1_S1_PNS_14BSONObjBuilderE"},{"b":"D64DFC2000","o":"529DF1","s":"_ZN5mongo18DBClientConnection7connectERKNS_11HostAndPortENS_10StringDataE"},{"b":"D64DFC2000","o":"52A6F5","s":"_ZN5mongo18DBClientConnection7connectERKNS_11HostAndPortENS_10StringDataERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE"},{"b":"D64DFC2000","o":"51B86D","s":"_ZNK5mongo16ConnectionString7connectENS_10StringDataERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEdPKNS_8MongoURIE"},{"b":"D64DFC2000","o":"55A041","s":"_ZNK5mongo8MongoURI7connectENS_10StringDataERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN5boost8optionalIdEE"},{"b":"D64DFC2000","o":"707032","s":"_ZN5mongo5mozjs17MongoExternalInfo9constructEP9JSContextN2JS8CallArgsE"},{"b":"D64DFC2000","o":"6FA003","s":"_ZN5mongo5mozjs7smUtils9constructINS0_17MongoExternalInfoEEEbP9JSContextjPN2JS5ValueE"},{"b":"D64DFC2000","o":"E1E8FF"},{"b":"D64DFC2000","o":"E1A5DA"},{"b":"D64DFC2000","o":"E1E303","s":"_ZN2js9RunScriptEP9JSContextRNS_8RunStateE"},{"b":"D64DFC2000","o":"E24DFF","s":"_ZN2js13ExecuteKernelEP9JSContextN2JS6HandleIP8JSScriptEER8JSObjectRKNS2_5ValueENS_11ExecuteTypeENS_16AbstractFramePtrEPS9_"},{"b":"D64DFC2000","o":"E24F81","s":"_ZN2js7ExecuteEP9JSContextN2JS6HandleIP8JSScriptEER8JSObjectPNS2_5ValueE"},{"b":"D64DFC2000","o":"CCD32A"},{"b":"D64DFC2000","o":"CCD3D0","s":"_Z16JS_ExecuteScriptP9JSContextN2JS6HandleIP8JSScriptEENS1_13MutableHandleINS1_5ValueEEE"},{"b":"D64DFC2000","o":"6F5581","s":"_ZN5mongo5mozjs14MozJSImplScope4execENS_10StringDataERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbbbi"},{"b":"D64DFC2000","o":"7560BD","s":"_ZN5mongo11shell_utils9initScopeERNS_5ScopeE"},{"b":"D64DFC2000","o":"6F8458","s":"_ZN5mongo5mozjs14MozJSImplScopeC1EPNS0_17MozJSScriptEngineE"},{"b":"D64DFC2000","o":"7249F2","s":"_ZN5mongo5mozjs15MozJSProxyScope10implThreadEPv"},{"b":"D64DFC2000","o":"6D9D0C","s":"_ZN4nspr6Thread13ThreadRoutineEPv"},{"b":"7F86DBE32000","o":"B64A0"},{"b":"7F86DB6EB000","o":"7454"},{"b":"7F86DB34C000","o":"E87BF","s":"clone"}],"processInfo":{ "mongodbVersion" : "3.4.4", "gitVersion" : "nogitversion", "compiledModules" : [], "uname" : { "sysname" : "Linux", "release" : "4.9.44-gnu", "version" : "#1 SMP 1", "machine" : "x86_64" }, "somap" : [ { "b" : "D64DFC2000", "elfType" : 3, "buildId" : "64938EB328B5F2600C09750DAEB910E82DB2DC10" }, { "b" : "7FFD82BCA000", "path" : "linux-vdso.so.1", "elfType" : 3, "buildId" : "883DD2FCEED79AD31D8B0B74D24FDBCDFBE6CE33" }, { "b" : "7F86DC3B0000", "path" : "/gnu/store/rmjlycdgiq8pfy5hfi42qhw3k7p6kdav-glibc-2.25/lib/librt.so.1", "elfType" : 3 }, { "b" : "7F86DC1AC000", "path" : "/gnu/store/rmjlycdgiq8pfy5hfi42qhw3k7p6kdav-glibc-2.25/lib/libdl.so.2", "elfType" : 3 }, { "b" : "7F86DBE32000", "path" : "/gnu/store/dhc2iy059hi91fk55dcv79z09kp6500y-gcc-5.4.0-lib/lib/libstdc++.so.6", "elfType" : 3 }, { "b" : "7F86DBB20000", "path" : "/gnu/store/rmjlycdgiq8pfy5hfi42qhw3k7p6kdav-glibc-2.25/lib/libm.so.6", "elfType" : 3 }, { "b" : "7F86DB909000", "path" : "/gnu/store/dhc2iy059hi91fk55dcv79z09kp6500y-gcc-5.4.0-lib/lib/libgcc_s.so.1", "elfType" : 3 }, { "b" : "7F86DB6EB000", "path" : "/gnu/store/rmjlycdgiq8pfy5hfi42qhw3k7p6kdav-glibc-2.25/lib/libpthread.so.0", "elfType" : 3 }, { "b" : "7F86DB34C000", "path" : "/gnu/store/rmjlycdgiq8pfy5hfi42qhw3k7p6kdav-glibc-2.25/lib/libc.so.6", "elfType" : 3 }, { "b" : "7F86DC5B8000", "path" : "/gnu/store/rmjlycdgiq8pfy5hfi42qhw3k7p6kdav-glibc-2.25/lib/ld-linux-x86-64.so.2", "elfType" : 3 } ] }} mongo(_ZN5mongo15printStackTraceERSo+0x41) [0xd64e7afa41] mongo(+0x7ECB59) [0xd64e7aeb59] mongo(+0x7ED03D) [0xd64e7af03d] libpthread.so.0(+0x11A80) [0x7f86db6fca80] libc.so.6(gsignal+0x104) [0x7f86db37f2c4] libc.so.6(abort+0x16A) [0x7f86db38072a] mongo(_ZN5mongo17invariantOKFailedEPKcRKNS_6StatusES1_j+0x0) [0xd64e448c8a] mongo(_ZN5mongo14ClientMetadata16serializePrivateENS_10StringDataES1_S1_S1_S1_S1_S1_PNS_14BSONObjBuilderE+0x22AD) [0xd64e6764bd] mongo(_ZN5mongo14ClientMetadata9serializeENS_10StringDataES1_S1_PNS_14BSONObjBuilderE+0xA0) [0xd64e676810] mongo(_ZN5mongo18DBClientConnection7connectERKNS_11HostAndPortENS_10StringDataE+0x2F1) [0xd64e4ebdf1] mongo(_ZN5mongo18DBClientConnection7connectERKNS_11HostAndPortENS_10StringDataERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x35) [0xd64e4ec6f5] mongo(_ZNK5mongo16ConnectionString7connectENS_10StringDataERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEdPKNS_8MongoURIE+0xBBD) [0xd64e4dd86d] mongo(_ZNK5mongo8MongoURI7connectENS_10StringDataERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN5boost8optionalIdEE+0xC1) [0xd64e51c041] mongo(_ZN5mongo5mozjs17MongoExternalInfo9constructEP9JSContextN2JS8CallArgsE+0x6A2) [0xd64e6c9032] mongo(_ZN5mongo5mozjs7smUtils9constructINS0_17MongoExternalInfoEEEbP9JSContextjPN2JS5ValueE+0x33) [0xd64e6bc003] mongo(+0xE1E8FF) [0xd64ede08ff] mongo(+0xE1A5DA) [0xd64eddc5da] mongo(_ZN2js9RunScriptEP9JSContextRNS_8RunStateE+0x113) [0xd64ede0303] mongo(_ZN2js13ExecuteKernelEP9JSContextN2JS6HandleIP8JSScriptEER8JSObjectRKNS2_5ValueENS_11ExecuteTypeENS_16AbstractFramePtrEPS9_+0xCF) [0xd64ede6dff] mongo(_ZN2js7ExecuteEP9JSContextN2JS6HandleIP8JSScriptEER8JSObjectPNS2_5ValueE+0xB1) [0xd64ede6f81] mongo(+0xCCD32A) [0xd64ec8f32a] mongo(_Z16JS_ExecuteScriptP9JSContextN2JS6HandleIP8JSScriptEENS1_13MutableHandleINS1_5ValueEEE+0x60) [0xd64ec8f3d0] mongo(_ZN5mongo5mozjs14MozJSImplScope4execENS_10StringDataERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbbbi+0x181) [0xd64e6b7581] mongo(_ZN5mongo11shell_utils9initScopeERNS_5ScopeE+0x4BD) [0xd64e7180bd] mongo(_ZN5mongo5mozjs14MozJSImplScopeC1EPNS0_17MozJSScriptEngineE+0x1968) [0xd64e6ba458] mongo(_ZN5mongo5mozjs15MozJSProxyScope10implThreadEPv+0x92) [0xd64e6e69f2] mongo(_ZN4nspr6Thread13ThreadRoutineEPv+0x1C) [0xd64e69bd0c] libstdc++.so.6(+0xB64A0) [0x7f86dbee84a0] libpthread.so.0(+0x7454) [0x7f86db6f2454] libc.so.6(clone+0x3F) [0x7f86db4347bf]-----  END BACKTRACE  -----Aborted
      

      Using strace shows that it attempts to find out the information from the filesystem, but fails:

      stat("/etc/lsb-release", 0x7fffa09702d0) = -1 ENOENT (No such file or directory)
      stat("/etc/system-release", 0x7fffa09702d0) = -1 ENOENT (No such file or directory)
      stat("/etc/redhat-release", 0x7fffa09702d0) = -1 ENOENT (No such file or directory)
      stat("/etc/gentoo-release", 0x7fffa09702d0) = -1 ENOENT (No such file or directory)
      stat("/etc/novell-release", 0x7fffa09702d0) = -1 ENOENT (No such file or directory)
      stat("/etc/gentoo-release", 0x7fffa09702d0) = -1 ENOENT (No such file or directory)
      stat("/etc/SuSE-release", 0x7fffa09702d0) = -1 ENOENT (No such file or directory)
      stat("/etc/SUSE-release", 0x7fffa09702d0) = -1 ENOENT (No such file or directory)
      stat("/etc/sles-release", 0x7fffa09702d0) = -1 ENOENT (No such file or directory)
      stat("/etc/debian_release", 0x7fffa09702d0) = -1 ENOENT (No such file or directory)
      stat("/etc/slackware-version", 0x7fffa09702d0) = -1 ENOENT (No such file or directory)
      stat("/etc/centos-release", 0x7fffa09702d0) = -1 ENOENT (No such file or directory)
      stat("/etc/os-release", 0x7fffa09702d0) = -1 ENOENT (No such file or directory)
      

      Using GDB confirms that the osName is empty:

      MongoDB shell version v3.4.9[New Thread 0x7ffff4b88700 (LWP 19019)][New Thread 0x7ffff4387700 (LWP 19020)]connecting to: mongodb://127.0.0.1:57017/2017-09-15T17:54:41.540+0100 I -        [thread1] Invariant failure !driverName.empty() && !driverVersion.empty() && !osType.empty() && !osName.empty() && !osArchitecture.empty() && !osVersion.empty() src/mongo/rpc/metadata/client_metadata.cpp 350Thread 3 "thread1" received signal SIGTRAP, Trace/breakpoint trap.[Switching to Thread 0x7ffff4387700 (LWP 19020)]raise (sig=<optimized out>) at ../sysdeps/unix/sysv/linux/raise.c:5151    ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.(gdb) bt full 4#0  raise (sig=<optimized out>) at ../sysdeps/unix/sysv/linux/raise.c:51        set = {__val = {0, 0, 0, 0, 0, 0, 0, 0, 0, 268435456, 18355225682008095280, 140737259776256, 0, 0, 140737290713408, 93825017283081}}        pid = <optimized out>        tid = <optimized out>#1  0x0000555556980386 in mongo::breakpoint () at src/mongo/util/debugger.cpp:68No locals.#2  0x0000555556973b73 in mongo::invariantFailed (    expr=0x55555771ba50 "!driverName.empty() && !driverVersion.empty() && !osType.empty() && !osName.empty() && !osArchitecture.empty() && !osVersion.empty()",     file=0x55555771ba20 "src/mongo/rpc/metadata/client_metadata.cpp", line=350) at src/mongo/util/assert_util.cpp:152No locals.#3  0x000055555687d47c in mongo::ClientMetadata::serializePrivate (driverName=..., driverVersion=..., osType=..., osName=..., osArchitecture=..., osVersion=..., appName=...,     builder=0x7ffff4383f50) at src/mongo/rpc/metadata/client_metadata.cpp:350No locals.(More stack frames follow...)(gdb) info argsdriverName = {_data = 0x5555576f1413 "MongoDB Internal Client", _size = 23}driverVersion = {_data = 0x5555577d6610 "3.4.9", _size = 5}osType = {_data = 0x7ffff4fe4b30 "Linux", _size = 5}osName = {_data = 0x7ffff4fe4b50 "", _size = 0}osArchitecture = {_data = 0x7ffff4fe4bb0 "x86_64", _size = 6}osVersion = {_data = 0x7ffff4fe4b70 "", _size = 0}appName = {_data = 0x7ffff27dd718 "MongoDB Shell", _size = 13}builder = 0x7ffff4383f50
      

            Assignee:
            mark.agarunov Mark Agarunov
            Reporter:
            cbaines Christopher Baines
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: