Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build mongo shell 3.2.x on ARM (armv7l/arm64/aarch64) - segmentation fault

Over the past days I tried a lot to get mongo shell running on Ubuntu 16.04 for ARM64 (aarch64) at Linaro cluster. I am currently working on the next release fork for meteorjs on ARM architecture.

TL;DR

While the mongod (DB) is running well after build without seen issues yet, it is not possible to get a running mongo shell [even WITHOUT javascript (mozjs) support] after build.

Simplest build:

mkdir -p /tmp/mongo-build

cd /tmp/mongo-build

git clone --branch "r3.2.6" --depth 1 https://github.com/mongodb/mongo.git

cd mongo

scons --disable-warnings-as-errors --prefix=/tmp/mongo-build/mongo --js-engine=mozjs mongo mongod

Even that this build will be run on all tested platforms and architectures (Linux on armv7l, aarch64, amd64) without issues during compiling, the results in case of running programs differs.

Running mongo command after build on amd64:

Just run mongo shell and try to connect to a non existing instance

./mongo mongodb://localhost:5002/sample

this will give this output:

MongoDB shell version: 3.2.6
connecting to: mongodb://localhost:5002/sample
2016-07-05T14:10:23.772+0200 W NETWORK  [thread1] Failed to connect to 127.0.0.1:5002, reason: errno:111 Connection refused
2016-07-05T14:10:23.772+0200 E QUERY    [thread1] Error: couldn't connect to server localhost:5002, connection attempt failed :
connect@src/mongo/shell/mongo.js:223:14
@(connect):1:6

exception: connect failed

Running mongo command after build on aarch64/armv7l:

Instead of this, the output on ARMs is just:

MongoDB shell version: 3.2.6
Segmentation fault (core dumped)

It seems to me that the TCP connection part might bring up that "SEGMENTATION FAULT" but I can't debug this.

I would be happy about any help to get this run.

Thanks in advance Tom

like image 396
Tom Freudenberg Avatar asked Jul 05 '16 12:07

Tom Freudenberg


2 Answers

After running a lot more tries and compiles, I have changed the branch for mongodb release and work with r3.3.9.

While using the same scons parameters it seems to run without any issue. I have not yet digged into details and changes in the versions but to have a running release is fine to me

mkdir -p /tmp/mongo-build

cd /tmp/mongo-build

git clone --branch "r3.3.9" --depth 1 https://github.com/mongodb/mongo.git

cd mongo

scons --disable-warnings-as-errors --prefix=/tmp/mongo-build/mongo --js-engine=mozjs mongo mongod
like image 107
Tom Freudenberg Avatar answered Nov 15 '22 05:11

Tom Freudenberg


If you issue ./mongo --help the binary still works but the connection has issues dealing with a non existant database. Seg Faulting instead of failing gracefully at the non existant database. Due to a null pointer dereference.

The offending code is in /src/mongo/client/mongo_uri_connect.cpp

    if (!_user.empty()) {
        ret->auth(_makeAuthObjFromOptions(ret->getMaxWireVersion()));
    }
    return ret;
}

It is claimed to be effected from 3.2.8 until 3.3.9 here.

https://jira.mongodb.org/browse/SERVER-23126

On another note if you require sharding add "core" to the scons line. For mongod, mongos and mongo to have them all included with the build.

scons --disable-warnings-as-errors --prefix=/tmp/mongo-build/mongo --js-engine=mozjs core

A good way around this would be to just point it to an existing database instead of a sample database.

like image 32
Keith Smith Avatar answered Nov 15 '22 04:11

Keith Smith