[SERVER-4645] The shell's db.collection.find() command asserts on regexs that the shell can't execute Created: 07/Jan/12  Updated: 05/Jan/18  Resolved: 02/May/17

Status: Closed
Project: Core Server
Component/s: JavaScript, Performance, Shell, Usability
Affects Version/s: 2.0.2
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Tad Marshall Assignee: DO NOT USE - Backlog - Platform Team
Resolution: Duplicate Votes: 3
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by CSHARP-862 Regex Queries /s suffix Closed
Duplicate
duplicates SERVER-27649 Don't error on serialization of $elem... Closed
is duplicated by SERVER-21974 mongo shell can't explain insensible ... Closed
Related
related to SERVER-16542 Shell helper for creating arbitrary B... Closed
Operating System: ALL
Participants:
Case:

 Description   

There is a mismatch between the capabilities of the MongoDB database and the MongoDB shell in handling regular expressions. There are regex specifications that are valid for the database that would not be valid if executed in the shell. This is due to differing abilities between PCRE and SpiderMonkey V8.

The problem comes when using profiling and trying to display the profile collection in the shell. Regular expression queries of the form /(?i)string/ perform a case-insensitive comparison when executed by the database. If these queries are captured in a profile collection, the shell is unable to display them with db.system.profile.find(). An assertion failure is displayed instead.

The find() command, executed in the shell, should not try to validate data that it has been asked to display. It should display the data, and postpone validation until it has been asked to execute something.



 Comments   
Comment by Kelsey Schubert [ 02/May/17 ]

This issue has been resolved in MongoDB 3.4.2 and later as part of SERVER-27649.

Comment by Asya Kamsky [ 20/Mar/17 ]

Fixed by SERVER-27649 I think?

Comment by Asya Kamsky [ 20/Mar/17 ]

3.4.1 has the same error, but 3.5.2 does not.

Was this fixed as a side effect of another ticket?

Comment by Asya Kamsky [ 19/May/16 ]

note that above is with 3.0.x with 3.3.6/master the error is:

db.user.find({username:"dave1",firstname:{$regex:"(?i)dav"}}).sort({firstname:1}).explain()
2016-05-19T12:10:02.411-0700 E QUERY    [thread1] Error: SyntaxError: invalid regexp group @src/mongo/shell/types.js:708:13

Comment by Asya Kamsky [ 19/May/16 ]

This problem can be reproduced in the shell via explain - and therefore should be testable:

db.user.find({username:{$regex:"(?i)dave"}}).sort({lastname:1}).explain()
2016-05-19T12:05:37.083-0700 I -        Assertion: 16686:error converting js type to Utf8Value
2016-05-19T12:05:37.088-0700 I CONTROL
 0x109ac3f99 0x109a7c430 0x109a698da 0x109a383f4 0x109a2128b 0x109a1d419 0x109d01d6d 0x109cfe8ad 0x109d85ee2 0x109ca2152 0x109ca54ba 0x3020f8106362
----- BEGIN BACKTRACE -----
{"backtrace":[{"b":"10990B000","o":"1B8F99","s":"_ZN5mongo15printStackTraceERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEE"},{"b":"10990B000","o":"171430","s":"_ZN5mongo10logContextEPKc"},{"b":"10990B000","o":"15E8DA","s":"_ZN5mongo11msgassertedEiPKc"},{"b":"10990B000","o":"12D3F4","s":"_ZN5mongo11toSTLStringERKN2v86HandleINS0_5ValueEEE"},{"b":"10990B000","o":"11628B","s":"_ZN5mongo7V8Scope16mongoToV8ElementERKNS_11BSONElementEb"},{"b":"10990B000","o":"112419","s":"_ZN5mongoL8namedGetEN2v85LocalINS0_6StringEEERKNS0_12AccessorInfoE"},{"b":"10990B000","o":"3F6D6D","s":"_ZN2v88internal8JSObject26GetPropertyWithInterceptorEPNS0_10JSReceiverEPNS0_6StringEP18PropertyAttributes"},{"b":"10990B000","o":"3F38AD","s":"_ZN2v88internal6Object23GetPropertyWithReceiverEPS1_PNS0_6StringEP18PropertyAttributes"},{"b":"10990B000","o":"47AEE2","s":"_ZN2v88internal7Runtime17GetObjectPropertyEPNS0_7IsolateENS0_6HandleINS0_6ObjectEEES6_"},{"b":"10990B000","o":"397152","s":"_ZN2v88internal11KeyedLoadIC4LoadENS0_16InlineCacheStateENS0_6HandleINS0_6ObjectEEES5_b"},{"b":"10990B000","o":"39A4BA","s":"_ZN2v88internal16KeyedLoadIC_MissENS0_9ArgumentsEPNS0_7IsolateE"},{"b":"0","o":"3020F8106362"}],"processInfo":{ "mongodbVersion" : "3.0.9", "gitVersion" : "20d60d3491908f1ae252fe452300de3978a040c7", "uname" : { "sysname" : "Darwin", "release" : "15.4.0", "version" : "Darwin Kernel Version 15.4.0: Fri Feb 26 22:08:05 PST 2016; root:xnu-3248.40.184~3/RELEASE_X86_64", "machine" : "x86_64" }, "somap" : [ { "path" : "/Users/asya/bins/mongodb-osx-x86_64-3.0.9/bin/mongo", "machType" : 2, "b" : "10990B000", "vmaddr" : "100000000", "buildId" : "446D696D93283526840BE1B505990E99" }, { "path" : "/usr/lib/libSystem.B.dylib", "machType" : 6, "b" : "7FFF8AED4000", "vmaddr" : "7FFF89F8E000", "buildId" : "CD307E99FC5C3575BCCE0C861AA63124" }, { "path" : "/usr/lib/libc++.1.dylib", "machType" : 6, "b" : "7FFF8C969000", "vmaddr" : "7FFF8BA23000", "buildId" : "8FC3D139805534989AC56467CB7F4D14" }, { "path" : "/usr/lib/system/libcache.dylib", "machType" : 6, "b" : "7FFF8D4F0000", "vmaddr" : "7FFF8C5AA000", "buildId" : "9548AAE92AB735259ECEA2A7C4688447" }, { "path" : "/usr/lib/system/libcommonCrypto.dylib", "machType" : 6, "b" : "7FFF82518000", "vmaddr" : "7FFF815D2000", "buildId" : "B9D08EB8FB353F7B8A1C6FCE3F07B7E7" }, { "path" : "/usr/lib/system/libcompiler_rt.dylib", "machType" : 6, "b" : "7FFF83F54000", "vmaddr" : "7FFF8300E000", "buildId" : "A13ECF69F59F38AE86097B731450FBCD" }, { "path" : "/usr/lib/system/libcopyfile.dylib", "machType" : 6, "b" : "7FFF94D0E000", "vmaddr" : "7FFF93DC8000", "buildId" : "A48637BCF3F234F2BB684C65FD012832" }, { "path" : "/usr/lib/system/libcorecrypto.dylib", "machType" : 6, "b" : "7FFF89357000", "vmaddr" : "7FFF88411000", "buildId" : "9D300121CAF838948774DF38FA65F238" }, { "path" : "/usr/lib/system/libdispatch.dylib", "machType" : 6, "b" : "7FFF81B8B000", "vmaddr" : "7FFF80C45000", "buildId" : "C749985761A53D7DA5EA65DCC8C3DF92" }, { "path" : "/usr/lib/system/libdyld.dylib", "machType" : 6, "b" : "7FFF89DD8000", "vmaddr" : "7FFF88E92000", "buildId" : "8390E026F7DE3C3294863DFF6BD131B0" }, { "path" : "/usr/lib/system/libkeymgr.dylib", "machType" : 6, "b" : "7FFF89A2B000", "vmaddr" : "7FFF88AE5000", "buildId" : "8371CE545FDD3CE9B3DFE98C761B6FE0" }, { "path" : "/usr/lib/system/liblaunch.dylib", "machType" : 6, "b" : "10A73A000", "vmaddr" : "0", "buildId" : "1CD7619DAF2E34D18EC68021CF473D9B" }, { "path" : "/usr/lib/system/libmacho.dylib", "machType" : 6, "b" : "7FFF83A87000", "vmaddr" : "7FFF82B41000", "buildId" : "318264FA58F139D882851F6254EE410E" }, { "path" : "/usr/lib/system/libquarantine.dylib", "machType" : 6, "b" : "7FFF92CB0000", "vmaddr" : "7FFF91D6A000", "buildId" : "0F4169F00C843A25B3AEE47B3586D908" }, { "path" : "/usr/lib/system/libremovefile.dylib", "machType" : 6, "b" : "7FFF911F4000", "vmaddr" : "7FFF902AE000", "buildId" : "552EF39E14D7363E90594565AC2F894E" }, { "path" : "/usr/lib/system/libsystem_asl.dylib", "machType" : 6, "b" : "7FFF968D8000", "vmaddr" : "7FFF95992000", "buildId" : "007F9094317A33EAAF62BAEAAB48C0F7" }, { "path" : "/usr/lib/system/libsystem_blocks.dylib", "machType" : 6, "b" : "7FFF8265F000", "vmaddr" : "7FFF81719000", "buildId" : "1244D9D5F6AA35BBB30786851C24B8E5" }, { "path" : "/usr/lib/system/libsystem_c.dylib", "machType" : 6, "b" : "7FFF87859000", "vmaddr" : "7FFF86913000", "buildId" : "CDEBF2BBA57830F5846F96274951C3C5" }, { "path" : "/usr/lib/system/libsystem_configuration.dylib", "machType" : 6, "b" : "7FFF8C579000", "vmaddr" : "7FFF8B633000", "buildId" : "3DEB7DF9680437E1BC830166882FF0FF" }, { "path" : "/usr/lib/system/libsystem_coreservices.dylib", "machType" : 6, "b" : "7FFF91499000", "vmaddr" : "7FFF90553000", "buildId" : "1B3F5AFCFFCD3ECB8B9A5538366FB20D" }, { "path" : "/usr/lib/system/libsystem_coretls.dylib", "machType" : 6, "b" : "7FFF9045E000", "vmaddr" : "7FFF8F518000", "buildId" : "C90DAE384082381CA1852A6A8B677628" }, { "path" : "/usr/lib/system/libsystem_dnssd.dylib", "machType" : 6, "b" : "7FFF92CB3000", "vmaddr" : "7FFF91D6D000", "buildId" : "86A05653DCA03345B29FF320029AA05E" }, { "path" : "/usr/lib/system/libsystem_info.dylib", "machType" : 6, "b" : "7FFF94956000", "vmaddr" : "7FFF93A10000", "buildId" : "6B01C09EA3E53C71B370D0CABD11A436" }, { "path" : "/usr/lib/system/libsystem_kernel.dylib", "machType" : 6, "b" : "7FFF8D588000", "vmaddr" : "7FFF8C642000", "buildId" : "88C17B7F1CD83979A1A9F7BDB4FCE789" }, { "path" : "/usr/lib/system/libsystem_m.dylib", "machType" : 6, "b" : "7FFF96023000", "vmaddr" : "7FFF950DD000", "buildId" : "08E1A4B264483DFEA58CACC7335BE7E4" }, { "path" : "/usr/lib/system/libsystem_malloc.dylib", "machType" : 6, "b" : "7FFF80F69000", "vmaddr" : "7FFF80023000", "buildId" : "5748E8B2F81C34C68B13456213127678" }, { "path" : "/usr/lib/system/libsystem_network.dylib", "machType" : 6, "b" : "7FFF88CEE000", "vmaddr" : "7FFF87DA8000", "buildId" : "269E5ADD692231E28D557B777263AC0D" }, { "path" : "/usr/lib/system/libsystem_networkextension.dylib", "machType" : 6, "b" : "7FFF85584000", "vmaddr" : "7FFF8463E000", "buildId" : "66095DC7653938F295EE458F15F6D014" }, { "path" : "/usr/lib/system/libsystem_notify.dylib", "machType" : 6, "b" : "7FFF8BF8A000", "vmaddr" : "7FFF8B044000", "buildId" : "D48BDE340F7E34CAA0FFC578E39987CC" }, { "path" : "/usr/lib/system/libsystem_platform.dylib", "machType" : 6, "b" : "7FFF9252C000", "vmaddr" : "7FFF915E6000", "buildId" : "29A905EF67773C3382B06C3A88C4BA15" }, { "path" : "/usr/lib/system/libsystem_pthread.dylib", "machType" : 6, "b" : "7FFF91392000", "vmaddr" : "7FFF9044C000", "buildId" : "3DD1EF4C1D1B3ABF8CC6B3B1CEEE9559" }, { "path" : "/usr/lib/system/libsystem_sandbox.dylib", "machType" : 6, "b" : "10A746000", "vmaddr" : "0", "buildId" : "30671DCC265F325AB33D11CD336B3DA3" }, { "path" : "/usr/lib/system/libsystem_secinit.dylib", "machType" : 6, "b" : "7FFF94D18000", "vmaddr" : "7FFF93DD2000", "buildId" : "32B1A8C6DC843F4FB8CE9A52B47C3E6B" }, { "path" : "/usr/lib/system/libsystem_trace.dylib", "machType" : 6, "b" : "7FFF8D766000", "vmaddr" : "7FFF8C820000", "buildId" : "2510454252513E8DB14A9E37207218BC" }, { "path" : "/usr/lib/system/libunc.dylib", "machType" : 6, "b" : "7FFF96053000", "vmaddr" : "7FFF9510D000", "buildId" : "DDB1E947C77533B8B46163E5EB698F0E" }, { "path" : "/usr/lib/system/libunwind.dylib", "machType" : 6, "b" : "7FFF8C748000", "vmaddr" : "7FFF8B802000", "buildId" : "F6EB48E54D12359AAB54C937FBBE9043" }, { "path" : "/usr/lib/system/libxpc.dylib", "machType" : 6, "b" : "10A754000", "vmaddr" : "0", "buildId" : "2CC7CF3666D4301BA6D8EBAE7405B008" }, { "path" : "/usr/lib/libobjc.A.dylib", "machType" : 6, "b" : "7FFF80F86000", "vmaddr" : "7FFF80040000", "buildId" : "7489D2D61EFD3414B18D2AECCCC90286" }, { "path" : "/usr/lib/libauto.dylib", "machType" : 6, "b" : "7FFF82618000", "vmaddr" : "7FFF816D2000", "buildId" : "999E610F41FC32A3ADCA5EC049B65DFB" }, { "path" : "/usr/lib/libc++abi.dylib", "machType" : 6, "b" : "7FFF93F89000", "vmaddr" : "7FFF93043000", "buildId" : "DCCC81773D0935BC97842A04FEC4C71B" }, { "path" : "/usr/lib/libDiagnosticMessagesClient.dylib", "machType" : 6, "b" : "7FFF84F1B000", "vmaddr" : "7FFF83FD5000", "buildId" : "4243B6B421E9355B9C5A95A216233B96" } ] }}
 mongo(_ZN5mongo15printStackTraceERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEE+0x39) [0x109ac3f99]
 mongo(_ZN5mongo10logContextEPKc+0x100) [0x109a7c430]
 mongo(_ZN5mongo11msgassertedEiPKc+0x13A) [0x109a698da]
 mongo(_ZN5mongo11toSTLStringERKN2v86HandleINS0_5ValueEEE+0x54) [0x109a383f4]
 mongo(_ZN5mongo7V8Scope16mongoToV8ElementERKNS_11BSONElementEb+0x145B) [0x109a2128b]
 mongo(_ZN5mongoL8namedGetEN2v85LocalINS0_6StringEEERKNS0_12AccessorInfoE+0x219) [0x109a1d419]
 mongo(_ZN2v88internal8JSObject26GetPropertyWithInterceptorEPNS0_10JSReceiverEPNS0_6StringEP18PropertyAttributes+0x21D) [0x109d01d6d]
 mongo(_ZN2v88internal6Object23GetPropertyWithReceiverEPS1_PNS0_6StringEP18PropertyAttributes+0x7D) [0x109cfe8ad]
 mongo(_ZN2v88internal7Runtime17GetObjectPropertyEPNS0_7IsolateENS0_6HandleINS0_6ObjectEEES6_+0x172) [0x109d85ee2]
 mongo(_ZN2v88internal11KeyedLoadIC4LoadENS0_16InlineCacheStateENS0_6HandleINS0_6ObjectEEES5_b+0x662) [0x109ca2152]
 mongo(_ZN2v88internal16KeyedLoadIC_MissENS0_9ArgumentsEPNS0_7IsolateE+0x19A) [0x109ca54ba]
 ??? [0x3020f8106362]
-----  END BACKTRACE  -----
2016-05-19T12:05:37.091-0700 E QUERY    Error: 16686 error converting js type to Utf8Value
    at tojsonObject (src/mongo/shell/types.js:656:20)
    at tojson (src/mongo/shell/types.js:600:17)
    at tojsonObject (src/mongo/shell/types.js:664:57)
    at tojson (src/mongo/shell/types.js:600:17)
    at tojsonObject (src/mongo/shell/types.js:664:57)
    at tojson (src/mongo/shell/types.js:600:17)
    at shellPrintHelper (src/mongo/shell/utils.js:402:15)
    at (shell2):1:19 at src/mongo/shell/types.js:656

Comment by Tad Marshall [ 07/Jan/12 ]

Core server ticket derived from commercial support ticket.

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