J@ArangoDB

{ "subject" : "ArangoDB", "tags": [ "multi-model", "nosql", "database" ] }

Compiling V8 With G++6

With g++ 6 becoming more and more adopted, it’s about time to point out an issue that hit some of us ArangoDB developers and a few of our users that compile ArangoDB from source with g++ 6.

The problem is that when compiling ArangoDB with g++6 with default options, arangod starts and almost immediately segfaults.

A backtrace of the crashed arangod process shows that the segfaults originate from the V8 JavaScript engine that ArangoDB uses internally. The problem seems to have affected other users of V8 as well, indicated by the following error reports:

The reason for the error now popping up is a change in the g++ 6 optimizer as stated in the gcc6 release notes:

Value range propagation now assumes that the this pointer of C++ member functions is non-null. This eliminates common null pointer checks but also breaks some non-conforming code-bases (such as Qt-5, Chromium, KDevelop). As a temporary work-around -fno-delete-null-pointer-checks can be used. Wrong code can be identified by using -fsanitize=undefined.

That means if compiling ArangoDB 2.8 from source with g++ 6 or higher, please be sure to set the environment variables CFLAGS="-fno-delete-null-pointer-checks" and
CXXFLAGS="-fno-delete-null-pointer-checks" before invoking the configure command:

1
2
3
make setup
CFLAGS="-fno-delete-null-pointer-checks" CXXFLAGS="-fno-delete-null-pointer-checks" ./configure
make

The options will then be passed to the sub-make that builds the V8 engine. If you have already built V8 without these options, try removing the file .v8-build-64 from the build directory and run configure and make again.

As a reminder, ArangoDB 2.8 will also emit this big notice at the end of its configure output:

1
2
3
4
5
6
7
8
9
configure: --------------------------------------------------------------------------------
configure:                                                                                 
configure: NOTE: if you are compiling ArangoDB with g++ 6.0 or higher, please make sure to 
configure: set the following environment variables when compiling ArangoDB:                
configure:                                                                                 
configure:   CFLAGS="-fno-delete-null-pointer-checks"                                      
configure:   CXXFLAGS="-fno-delete-null-pointer-checks"                                    
configure:                                                                                 
configure: --------------------------------------------------------------------------------

Users of g++ 5.x do not need to set these flags, neither need users of clang++. And in the ArangoDB 3.0 build the options will be set automatically when compiling V8 if the compiler is g++. They will not be set for compiling any other parts of ArangoDB as it’s only required for building V8.