[SERVER-21041] db.eval fails mongodb process if called with object parameter Created: 21/Oct/15  Updated: 09/Dec/15  Resolved: 22/Oct/15

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: 3.0.7
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Paul Klimashkin Assignee: Stennie Steneker (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

Hello!
An inexplicable error.

When I do in console on Gentoo (Linux 4.2.3-gentoo x86_64) it is ok

> db.eval(function (p) {return p;}, 1)
WARNING: db.eval is deprecated
1

But when I'm trying to pass object as parameter, it crash mongodb process totally! Wo I need to restart it after it!

> db.eval(function (p) {return p;}, {one: 1})
WARNING: db.eval is deprecated
2015-10-21T03:45:38.515+0000 I NETWORK  DBClientCursor::init call() failed
2015-10-21T03:45:38.515+0000 E QUERY    Error: error doing query: failed
    at DBQuery._exec (src/mongo/shell/query.js:83:36)
    at DBQuery.hasNext (src/mongo/shell/query.js:240:10)
    at DBCollection.findOne (src/mongo/shell/collection.js:187:19)
    at DB.runCommand (src/mongo/shell/db.js:58:41)
    at DB.eval (src/mongo/shell/db.js:461:20)
    at (shell):1:4 at src/mongo/shell/query.js:83

But on MacOS X El Capitan (Darwin 15.0.0 x86_64) it's ok in both cases.

So I am in in bad situation: on developer's machine all works fine, but in production mongodb crashes every time application calling eval through driver (NodeJS 4.1.1, mongoose 4.1.11)



 Comments   
Comment by Paul Klimashkin [ 24/Oct/15 ]

Thank Raamon, gcc 4.8 solved the problem!
But there https://www.mongodb.org/about/contributors/tutorial/build-mongodb-from-source/ is not a word about gcc 5
I think you should add notice about incompatibility with new gcc, otherwise many client will face the problem and will spend many days to find a the solution

Comment by Ramon Fernandez Marina [ 22/Oct/15 ]

klimashkin, if this is a custom build compiled with GCC5 then you should be aware that we don't support any GCC version older than 4.8 at the moment. We're working on adding support for newer compilers, but unfortunately GCC 5 is not on the list of supported compilers just yet.

The server segfault is happening inside V8:

mongod(_ZN2v82V837AdjustAmountOfExternalAllocatedMemoryEl+0x16) [0x11bbd56]

and this is most likely related to the combination of the custom build and the unsupported compiler. I'd recommend you either compile with GCC 4.8 (although this may not fix the issue) or use a stock build – I'm unable to reproduce the behavior you described with a stock 3.0.7, so I'm going to close this ticket.

Cheers,
Ramón.

Comment by Paul Klimashkin [ 22/Oct/15 ]

Hello Stephen!

> gcc --version
gcc (Gentoo 5.2.0 p1.2, pie-0.6.4) 5.2.0
Copyright (C) 2015 Free Software Foundation, Inc.

> db.serverBuildInfo()
{
	"version" : "3.0.7",
	"gitVersion" : "nogitversion",
	"OpenSSLVersion" : "",
	"sysInfo" : "Linux pastvu.com 4.2.3-gentoo #1 SMP Tue Oct 20 03:31:54 UTC 2015 x86_64 BOOST_LIB_VERSION=1_57",
	"versionArray" : [
		3,
		0,
		7,
		0
	],
	"loaderFlags" : "",
	"compilerFlags" : "-pipe -std=c++11 -fPIC -fno-strict-aliasing -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -O3 -Wno-unused-local-typedefs -Wno-unused-function -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-missing-braces -fno-builtin-memcmp -std=c99",
	"allocator" : "tcmalloc",
	"javascriptEngine" : "V8",
	"bits" : 64,
	"debug" : false,
	"maxBsonObjectSize" : 16777216,
	"ok" : 1
}

Comment by Stennie Steneker (Inactive) [ 22/Oct/15 ]

Hi Paul,

Can you please post the output of db.serverBuildInfo() from the mongo shell for your Gentoo environment?

If you built from source, can you also include the output of gcc --version?

Thanks,
Stephen

Comment by Paul Klimashkin [ 22/Oct/15 ]

2015-10-22T00:03:08.692+0000 F - [conn27] Invalid access at address: 0
2015-10-22T00:03:08.696+0000 F - [conn27] Got signal: 11 (Segmentation fault).
 
 0x112f49e 0x112eaf3 0x112f357 0x7fe70c9fb5d0 0x11bbd56 0x108dbfa 0x107f35a 0x10850db 0x1085139 0xa3b952 0xa3c40d 0xa2537c 0xa26358 0xa2726f 0xc6eca8 0xb4c05c 0x7c239c 0x10e3883 0x7fe70c9f2304 0x7fe70ba96c2d
---— BEGIN BACKTRACE —---
{"backtrace":[{"b":"400000","o":"D2F49E"},{"b":"400000","o":"D2EAF3"},{"b":"400000","o":"D2F357"},{"b":"7FE70C9EB000","o":"105D0"},{"b":"400000","o":"DBBD56"},{"b":"400000","o":"C8DBFA"},{"b":"400000","o":"C7F35A"},{"b":"400000","o":"C850DB"},{"b":"400000","o":"C85139"},{"b":"400000","o":"63B952"},{"b":"400000","o":"63C40D"},{"b":"400000","o":"62537C"},{"b":"400000","o":"626358"},{"b":"400000","o":"62726F"},{"b":"400000","o":"86ECA8"},{"b":"400000","o":"74C05C"},{"b":"400000","o":"3C239C"},{"b":"400000","o":"CE3883"},{"b":"7FE70C9EB000","o":"7304"},{"b":"7FE70B9AF000","o":"E7C2D"}],"processInfo":{ "mongodbVersion" : "3.0.7", "gitVersion" : "nogitversion", "uname" : { "sysname" : "Linux", "release" : "4.2.3-gentoo", "version" : "#1 SMP Tue Oct 20 03:31:54 UTC 2015", "machine" : "x86_64" }, "somap" : [ { "elfType" : 2, "b" : "400000" }, { "b" : "7FFC01E43000", "path" : "linux-vdso.so.1", "elfType" : 3, "buildId" : "C6679085F6401FAF3778F6B27E7AF10ED033AA46" }, { "b" : "7FE70DD4C000", "path" : "/usr/lib64/libboost_program_options.so.1.57.0", "elfType" : 3 }, { "b" : "7FE70DB33000", "path" : "/usr/lib64/libboost_filesystem.so.1.57.0", "elfType" : 3 }, { "b" : "7FE70D90C000", "path" : "/usr/lib64/libboost_thread.so.1.57.0", "elfType" : 3 }, { "b" : "7FE70D708000", "path" : "/usr/lib64/libboost_system.so.1.57.0", "elfType" : 3 }, { "b" : "7FE70D501000", "path" : "/usr/lib64/libsnappy.so.1", "elfType" : 3 }, { "b" : "7FE70D281000", "path" : "/usr/lib64/libyaml-cpp.so.0.5", "elfType" : 3 }, { "b" : "7FE70D077000", "path" : "/usr/lib64/libpcrecpp.so.0", "elfType" : 3 }, { "b" : "7FE70CE5A000", "path" : "/usr/lib64/libsasl2.so.3", "elfType" : 3 }, { "b" : "7FE70CC07000", "path" : "/usr/lib64/libstemmer.so.0d", "elfType" : 3 }, { "b" : "7FE70C9EB000", "path" : "/lib64/libpthread.so.0", "elfType" : 3 }, { "b" : "7FE70C7E3000", "path" : "/lib64/librt.so.1", "elfType" : 3 }, { "b" : "7FE70C5DF000", "path" : "/lib64/libdl.so.2", "elfType" : 3 }, { "b" : "7FE70C25C000", "path" : "/usr/lib/gcc/x86_64-pc-linux-gnu/5.2.0/libstdc++.so.6", "elfType" : 3 }, { "b" : "7FE70BF60000", "path" : "/lib64/libm.so.6", "elfType" : 3 }, { "b" : "7FE70BD49000", "path" : "/usr/lib/gcc/x86_64-pc-linux-gnu/5.2.0/libgcc_s.so.1", "elfType" : 3 }, { "b" : "7FE70B9AF000", "path" : "/lib64/libc.so.6", "elfType" : 3 }, { "b" : "7FE70DFCB000", "path" : "/lib64/ld-linux-x86-64.so.2", "elfType" : 3 }, { "b" : "7FE70B73F000", "path" : "/lib64/libpcre.so.1", "elfType" : 3 } ] }}
 mongod(_ZN5mongo15printStackTraceERSo+0x3E) [0x112f49e]
 mongod(+0xD2EAF3) [0x112eaf3]
 mongod(+0xD2F357) [0x112f357]
 libpthread.so.0(+0x105D0) [0x7fe70c9fb5d0]
 mongod(_ZN2v82V837AdjustAmountOfExternalAllocatedMemoryEl+0x16) [0x11bbd56]
 mongod(_ZN5boost6detail17sp_counted_impl_pIN5mongo10BSONHolderEE7disposeEv+0x3A) [0x108dbfa]
 mongod(+0xC7F35A) [0x107f35a]
 mongod(_ZN5mongo7V8ScopeD1Ev+0x34B) [0x10850db]
 mongod(_ZN5mongo7V8ScopeD0Ev+0x9) [0x1085139]
 mongod(+0x63B952) [0xa3b952]
 mongod(+0x63C40D) [0xa3c40d]
 mongod(_ZN5mongo12_execCommandEPNS_16OperationContextEPNS_7CommandERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_7BSONObjEiRS9_RNS_14BSONObjBuilderEb+0x3C) [0xa2537c]
 mongod(_ZN5mongo7Command11execCommandEPNS_16OperationContextEPS0_iPKcRNS_7BSONObjERNS_14BSONObjBuilderEb+0xD38) [0xa26358]
 mongod(_ZN5mongo12_runCommandsEPNS_16OperationContextEPKcRNS_7BSONObjERNS_11_BufBuilderINS_16TrivialAllocatorEEERNS_14BSONObjBuilderEbi+0x5EF) [0xa2726f]
 mongod(_ZN5mongo8runQueryB5cxx11EPNS_16OperationContextERNS_7MessageERNS_12QueryMessageERKNS_15NamespaceStringERNS_5CurOpES3_+0xAE8) [0xc6eca8]
mongod(_ZN5mongo16assembleResponseEPNS_16OperationContextERNS_7MessageERNS_10DbResponseERKNS_11HostAndPortE+0xA5C) [0xb4c05c]
 mongod(_ZN5mongo16MyMessageHandler7processERNS_7MessageEPNS_21AbstractMessagingPortEPNS_9LastErrorE+0xDC) [0x7c239c]
 mongod(_ZN5mongo17PortMessageServer17handleIncomingMsgEPv+0x353) [0x10e3883]
 libpthread.so.0(+0x7304) [0x7fe70c9f2304]
 libc.so.6(clone+0x6D) [0x7fe70ba96c2d]
---— END BACKTRACE —---

Comment by Paul Klimashkin [ 21/Oct/15 ]

I found a simpler way to crash mongo on gentoo from console:

> db.eval( function() { return db.system.js.count({}); });
WARNING: db.eval is deprecated
2015-10-21T17:36:23.415+0000 I NETWORK  DBClientCursor::init call() failed
2015-10-21T17:36:23.416+0000 E QUERY    Error: error doing query: failed
    at DBQuery._exec (src/mongo/shell/query.js:83:36)
    at DBQuery.hasNext (src/mongo/shell/query.js:240:10)
    at DBCollection.findOne (src/mongo/shell/collection.js:187:19)
    at DB.runCommand (src/mongo/shell/db.js:58:41)
    at DB.eval (src/mongo/shell/db.js:461:20)
    at (shell):1:4 at src/mongo/shell/query.js:83

Comment by Paul Klimashkin [ 21/Oct/15 ]

Mongodb 3.0.7 WiredTiger

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