You are currently viewing Mongo – Illegal Instruction

Mongo – Illegal Instruction

I decided to do a few simple things yesterday, when I ran into this scenario

[root@arch ~]# mongod

Illegal instruction (core dumped)

I had intended to do the following

  1. Download install and setup MongoDB on my web server
  2. Create a script that would log temperature info (remember this!)
  3. Develop something in python to display that info on a web page

So after some quick research on the internet it became clear that this issue affected 32-bit binaries of Mongo, the vast majority of issues were from users of arch linux.  The problem was solved for some by building from source others had the same issue after building from source.

So I downloaded the mongodb source files, unzipped them and install scons to build the binaries.

[root@arch ~]# wget https://fastdl.mongodb.org/src/mongodb-src-r3.0.4.zip

[root@arch ~]# unzip mongodb-src-r3.0.4.zip

[root@arch ~]# cd mongodb-src-r3.0.4

[root@arch ~]# pacman -S scons

So now I started the build again, but soon it failed because a variable is unused in the code.  By default, scons treats all warnings as errors, so I started the build again with options to disable “warnings as errors”.

[root@arch ~]# scons –disable-warnings-as-errors –32 all

As this was running I notice that one of the compile parameters being passed to gcc was -march=nocona.  This is an Intel architecture built around 90nm, that introduced SSE3 instructions, hyper-threading and 64-bit!

According to a quick check of “cat /proc/cpuinfo” my CPU on this server is 32-bit which supports up to SSE2.  So this build was also going to result in “Illegal Instruction” as soon as it ran another SSE3 command.

Cpuinfo

So with that, I issued CTRL+c to stop the build and decided to edit the SConstruct file.  I found the following on line number 1417 and changed nocona to pentium3

if using_gcc() or using_clang():

myenv.Append( CCFLAGS=[‘-march=nocona‘, ‘-mtune=generic’] )

New version:

if using_gcc() or using_clang():

myenv.Append( CCFLAGS=[‘-march=pentium3‘, ‘-mtune=generic’] )

So I started the build again, third time lucky…  I’d love to tell you it resulted in a working binary but my machine hit a CPU temperature of 99C while building and triggered a thermal shutdown.

Thermal-Shutdown

 

So I’ll add some cooling, lock the CPU to its slowest speed and try again later.  OR…. upgrade the server 🙂

Update:

It worked with a bit more tweaking, see this post

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.