[SERVER-8030] mongo shell crashes with missing host Created: 26/Dec/12  Updated: 11/Jul/16  Resolved: 13/Mar/13

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: 2.2.1
Fix Version/s: 2.4.6, 2.5.0

Type: Bug Priority: Major - P3
Reporter: Roy Smith Assignee: Tad Marshall
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Ubuntu Precise

Linux dev1.songza.com 2.6.32-347-ec2 #52-Ubuntu SMP Fri Jul 27 14:38:36 UTC 2012 x86_64 GNU/Linux


Issue Links:
Related
related to SERVER-10244 Fail gracefully on invalid port number Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

Run "mongo /anything".

Participants:

 Description   

$ mongo /songza
MongoDB shell version: 2.2.1
connecting to: /songza
Wed Dec 26 04:14:09 Assertion: 13110:HostAndPort: host is empty
0x6073f1 0x5d1aa9 0x4e7a79 0x5b6262 0x6aa5ac 0x6aaec8 0x69e4e7 0x6aa13f 0x668e46 0x668ec2 0x66a2ce 0x5cbcc4 0x4b5e09 0x5b09ad 0x4a406b 0x4a67e6 0x7ff9a08f7c4d 0x49f669
mongo(_ZN5mongo15printStackTraceERSo+0x21) [0x6073f1]
mongo(_ZN5mongo11msgassertedEiPKc+0x99) [0x5d1aa9]
mongo(_ZN5mongo16ConnectionString5parseERKSsRSs+0x3c9) [0x4e7a79]
mongo(ZN5mongo26mongo_external_constructorEP9JSContextP8JSObjectjPlS4+0x132) [0x5b6262]
mongo(js_Invoke+0x40c) [0x6aa5ac]
mongo(js_InvokeConstructor+0x108) [0x6aaec8]
mongo(js_Interpret+0x37c7) [0x69e4e7]
mongo(js_Execute+0x36f) [0x6aa13f]
mongo(JS_EvaluateUCScriptForPrincipals+0x66) [0x668e46]
mongo(JS_EvaluateUCScript+0x22) [0x668ec2]
mongo(JS_EvaluateScript+0x6e) [0x66a2ce]
mongo(_ZN5mongo7SMScope4execERKNS_10StringDataERKSsbbbi+0x144) [0x5cbcc4]
mongo(_ZN5mongo11shell_utils9initScopeERNS_5ScopeE+0x1e9) [0x4b5e09]
mongo(_ZN5mongo12ScriptEngine8newScopeEv+0x2d) [0x5b09ad]
mongo(_Z5_mainiPPc+0x1d1b) [0x4a406b]
mongo(main+0x26) [0x4a67e6]
/lib/libc.so.6(__libc_start_main+0xfd) [0x7ff9a08f7c4d]
mongo(__gxx_personality_v0+0x2a1) [0x49f669]
Wed Dec 26 04:14:09 Error: HostAndPort: host is empty src/mongo/shell/mongo.js:93
exception: connect failed



 Comments   
Comment by auto [ 29/Jul/13 ]

Author:

{u'username': u'tadmarshall', u'name': u'Tad Marshall', u'email': u'tad@10gen.com'}

Message: SERVER-8030 Add IPv6 version of jstest
Branch: v2.4
https://github.com/mongodb/mongo/commit/47d1066c0bc4feef089193995b23d5899eb2eee1

Comment by auto [ 29/Jul/13 ]

Author:

{u'username': u'tadmarshall', u'name': u'Tad Marshall', u'email': u'tad@10gen.com'}

Message: SERVER-8030 Validate connection string in JavaScript connect() function

Validate that the "URL" passed to the connect() function matches one of the
accepted formats (host:port/database, host/database or database) before trying
to use it to connect to a server. Change a uassert in HostAndPort::init() to
an massert to match the massert four lines above it. Add jstest for connect()
validation.
Branch: v2.4
https://github.com/mongodb/mongo/commit/031daa05328127af84a0625ab9165a531678fe5d

Comment by auto [ 13/Mar/13 ]

Author:

{u'date': u'2013-03-13T13:50:02Z', u'name': u'Tad Marshall', u'email': u'tad@10gen.com'}

Message: SERVER-8030 Add IPv6 version of jstest
Branch: master
https://github.com/mongodb/mongo/commit/6309c19d489c97f54570436b89469432c60953ab

Comment by Tad Marshall [ 11/Mar/13 ]

The jstests/connection_string_validation.js test checks two "bad" IPv6 connection strings, but no "good" (working) ones, so I'll add another test to verify that we can validate and use valid IPv6 connection strings.

Comment by auto [ 11/Mar/13 ]

Author:

{u'date': u'2013-03-10T17:34:11Z', u'name': u'Tad Marshall', u'email': u'tad@10gen.com'}

Message: SERVER-8030 Validate connection string in JavaScript connect() function

Validate that the "URL" passed to the connect() function matches one of the
accepted formats (host:port/database, host/database or database) before trying
to use it to connect to a server. Change a uassert in HostAndPort::init() to
an massert to match the massert four lines above it. Add jstest for connect()
validation.
Branch: master
https://github.com/mongodb/mongo/commit/c40533e151407c0cc48cc0d514ec6fa2d600d374

Comment by Tad Marshall [ 09/Mar/13 ]

The massert producing the stack trace is from commit 421a6fbd20c96f28db154ac10354523aedd610c5 .

Comment by Tad Marshall [ 26/Dec/12 ]

The code issues a uassert if the port is bad, but issues an massert if the entire host string is empty (which it is because the slash is interpreted as a separator between the host:port and the database name). It should issue a uassert on an empty host string instead of an massert since this is user-provided data and not a program error.

Generated at Thu Feb 08 03:16:22 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.