Tombart
Tombart

Reputation: 32418

NodeJS error initializing V8 on Gentoo AMD64

I managed to compile V8 engine on the machine, however when I type

$ node

FATAL ERROR: v8::Debug::SetDebugMessageDispatchHandler Error initializing V8

I have V8 version 3.6.6.11, the D8 console is working properly. I've tried portage version of nodejs 0.6.6, compiled version from github shows the same error. I guess the problem is with heap of stack allocation

$ ulimit -a

core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 31707
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 31707
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

It is a virtual machine, that might raise some limitations...

Linux 2.6.36-hardened-r9-guest-hardened-01 x86_64 QEMU Virtual CPU version 0.13.0 AuthenticAMD GNU/Linux Any ideas?

Upvotes: 2

Views: 1400

Answers (3)

Tombart
Tombart

Reputation: 32418

after debuggin nodejs with Vyacheslav Egorov we found out, that mmap is failing to allocate memory (Operation not permitted) - this is caused by some Gentoo's security flag (changing it might require to recompile kernel)

Finally I used node v0.6 branch from github

./configure --without-snapshot
make
make install

and

paxctl -m /usr/local/bin/node

which adds MPROTECT flag

- PaX flags: -----m-x-e-- [/usr/local/bin/node]
        MPROTECT is disabled
        RANDEXEC is disabled
        EMUTRAMP is disabled

Note to myself:

when running Rails application on server put to config/boot.rb

ENV['EXECJS_RUNTIME'] = 'Node' if ENV['RAILS_ENV'] == 'production'

Upvotes: 6

Veovis
Veovis

Reputation: 150

This is what I get from /var/log/kern.log when compiling V8 for Android:

Dec 30 11:42:26 stormrage kernel: grsec: From 82.247.154.152: denied RWX mmap of <anonymous mapping> by /mnt/sdb/cyanogen/android/system/out/host/linux-x86/bin/mksnapshot[mksnapshot:32426] uid/euid:1014/1014 gid/egid:1014/1014, parent /usr/bin/gmake[make:28416] uid/euid:1014/1014 gid/egid:1014/1014

I suspect your error is the same as mine (GRSEC issue) and doing

paxctl -m /mnt/sdb/cyanogen/android/system/out/host/linux-x86/bin/mksnapshot

works for me. I'm under Gentoo x64 Hardened as a VMWare ESXi guest. Thanks.

Upvotes: 1

Vyacheslav Egorov
Vyacheslav Egorov

Reputation: 10492

I suspect that this is caused by failure to allocate code range (it is used only in x64 version of V8). In deps/v8/src/heap.cc try changing code_range_size_(512*MB), to code_rage_size_(32*MB), and recompile node.

Upvotes: 1

Related Questions