jhtong
jhtong

Reputation: 1589

Bus Error on Mongodb MongoClient.connect() for Raspberry Pi ARM

I have tried executing this node script on an x64 computer, and it appears to work fine.

However, the same script reports a bus error when run on the Raspberry Pi. It gives a [6047.715610] Unhandled Fault: alignment exception error, with the error reported on the next line, as a Bus error. It appears that the error stems from MongoClient.connect().

The script utilizes MongoClient and GridStore from the mongodb module. In addition, I have attempted a re-installation from this repository (which appears to do a gyp-rebuild), and it fails.

Is there any compilation option that should be set?

Upvotes: 4

Views: 1331

Answers (1)

jhtong
jhtong

Reputation: 1589

I managed to fix the error by pulling the repo from github, editing bson.h, and doing a node-gyp rebuild on it.

Apparently, the error is caused by a compilation option which is not supported by ARM devices. Just in case anyone is interested:

  1. Git clone repository here: https://github.com/mongodb/node-mongodb-native
  2. Open ./node-mongodb-native/node_modules/bson/ext/bson.h
  3. Change #define USE_MISALIGNED_MEMORY_ACCESS from 1 to 0
  4. do a node-gyp rebuild to recompile the library.

This worked for me.

Upvotes: 3

Related Questions