nodejs-0.4.2 启动时出现段错误(在 v 0.4.5 中修复)
您好,为了节省您的时间,此错误已在 v0.4.5 中修复 我今天在安装 Node.js 时遇到了一个相当奇怪的问题,并筛选了邮件档案,但无法完全确定它!所以我将问题发布到nodejs这里
只是一个提示我将 snapshot='snapshot=on'
从 wscript 更改为 节点到 snapshot=''
。 我这样做是因为在这样做之前我遇到了以下情况 make 期间出错:
scons: *** [obj/release/snapshot.cc] 错误 -11
现在介绍我遵循的步骤。
*以 root 身份登录
---配置开始
adil-X:/usr/local/nodejs/node-v0.4.2 # ./configure --prefix=/usr/local/nodejs
Checking for program g++ or c++ : /usr/bin/g++
Checking for program cpp : /usr/bin/cpp
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for g++ : ok
Checking for program gcc or cc : /usr/bin/gcc
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for gcc : ok
Checking for library dl : yes
Checking for openssl : yes
Checking for library util : yes
Checking for library rt : yes
--- libeio ---
Checking for library pthread : yes
Checking for function pthread_create : yes
Checking for function pthread_atfork : yes
Checking for futimes(2) : yes
Checking for readahead(2) : yes
Checking for fdatasync(2) : yes
Checking for pread(2) and pwrite(2) : yes
Checking for sendfile(2) : yes
Checking for sync_file_range(2) : yes
--- libev ---
Checking for header sys/inotify.h : yes
Checking for function inotify_init : yes
Checking for header sys/epoll.h : yes
Checking for function epoll_ctl : yes
Checking for header port.h : not found
Checking for header poll.h : yes
Checking for function poll : yes
Checking for header sys/event.h : not found
Checking for header sys/queue.h : yes
Checking for function kqueue : not found
Checking for header sys/select.h : yes
Checking for function select : yes
Checking for header sys/eventfd.h : yes
Checking for function eventfd : yes
Checking for SYS_clock_gettime : yes
Checking for library rt : yes
Checking for function clock_gettime : yes
Checking for function nanosleep : yes
Checking for function ceil : yes
Checking for fdatasync(2) with c++ : yes
'configure' finished successfully (2.239s)
----配置结束
----make 开始(编译良好!)
[为简洁起见,省略 make 输出]
Waf: 离开目录 /usr/local /nodejs/node-v0.4.2/build'
'build' 成功完成(21.853s)
-----make 结束
-----make 测试开始
/usr/bin/python "/usr/local/nodejs/node-v0.4.2/tools/scons/scons.py" -
j 2 -C "/usr/local/nodejs/node-v0.4.2/build/default/" -Y "/usr/local/
nodejs/node-v0.4.2/deps/v8" visibility=default mode=release arch=ia32
toolchain=gcc library=static
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: `library' is up to date.
scons: done building targets.
DEST_OS: linux
DEST_CPU: ia32
Parallel Jobs: 2
Product type: program
python tools/test.py --mode=release simple message
[00:00|% 0|+ 0|- 0]: release test-pipe-
head === release test-
pipe-head ===
Path: simple/test-pipe-head
Command: build/default/node /usr/local/nodejs/node-v0.4.2/test/simple/
test-pipe-head.js
--- CRASHED ---
.. 。 所有后续测试都以类似的方式失败。
-----make test结束
-----make install开始(前几次我没有执行make test,后来才使用)
adil-X:/usr/local/nodejs/node-v0.4.2 # make install
Waf: Entering directory `/usr/local/nodejs/node-v0.4.2/build'
DEST_OS: linux
DEST_CPU: ia32
Parallel Jobs: 2
Product type: program
* installing build/default/config.h as /usr/local/nodejs/include/node/
config.h
* installing build/default/tools/nodejs.pc as /usr/local/nodejs/lib/
pkgconfig/nodejs.pc
* installing build/default/node as /usr/local/nodejs/bin/node
* installing build/default/src/node_config.h as /usr/local/nodejs/
include/node/node_config.h
Waf: Leaving directory `/usr/local/nodejs/node-v0.4.2/build'
'install' finished successfully (0.122s)
-----make install结束
I更新了 PATH
变量以包含 nodejs bin。
现在,nodejs 在启动时
adil-X:/usr/local/nodejs/node-v0.4.2 # node example.js
node.js:0
Segmentation fault
仍然崩溃并出现以下错误,我可以看到 node.js 版本
adil-X:~ # node -v
v0.4.2
OS/Arch 信息:
adil-X:~ # cat /etc/*release
LSB_VERSION="core-2.0-noarch:core-3.2-noarch:core-4.0-noarch:core-2.0-
ia32:core-3.2-ia32:core-4.0-ia32"
openSUSE 11.3 (i586)
adil-X:~ # cat /proc/cpuinfo
vendor_id :GenuineIntel
cpu family : 6
model : 23
model name : Intel(R) Core(TM)2 Duo CPU T6500 @ 2.10GHz
stepping : 10
cpu MHz : 1200.000
cache size : 2048 KB
从源代码构建时没有错误,我无法 找出问题所在。 我错过了一些明显的东西吗?谢谢。
Greetings, to save your time this bug was fixed in v0.4.5
I ran into a rather weird problem while installing node.js today and sifted through the mail archives but couldn't quite pin it!. so I posted the problem to nodejs here
just a heads up that I changed snapshot='snapshot=on'
from wscript in
Node to snapshot=''
.
I did this because prior to doing this I encountered the following
error during make:
scons: *** [obj/release/snapshot.cc] Error -11
Now to the steps I followed.
*logged in as root
---Start of configure
adil-X:/usr/local/nodejs/node-v0.4.2 # ./configure --prefix=/usr/local/nodejs
Checking for program g++ or c++ : /usr/bin/g++
Checking for program cpp : /usr/bin/cpp
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for g++ : ok
Checking for program gcc or cc : /usr/bin/gcc
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for gcc : ok
Checking for library dl : yes
Checking for openssl : yes
Checking for library util : yes
Checking for library rt : yes
--- libeio ---
Checking for library pthread : yes
Checking for function pthread_create : yes
Checking for function pthread_atfork : yes
Checking for futimes(2) : yes
Checking for readahead(2) : yes
Checking for fdatasync(2) : yes
Checking for pread(2) and pwrite(2) : yes
Checking for sendfile(2) : yes
Checking for sync_file_range(2) : yes
--- libev ---
Checking for header sys/inotify.h : yes
Checking for function inotify_init : yes
Checking for header sys/epoll.h : yes
Checking for function epoll_ctl : yes
Checking for header port.h : not found
Checking for header poll.h : yes
Checking for function poll : yes
Checking for header sys/event.h : not found
Checking for header sys/queue.h : yes
Checking for function kqueue : not found
Checking for header sys/select.h : yes
Checking for function select : yes
Checking for header sys/eventfd.h : yes
Checking for function eventfd : yes
Checking for SYS_clock_gettime : yes
Checking for library rt : yes
Checking for function clock_gettime : yes
Checking for function nanosleep : yes
Checking for function ceil : yes
Checking for fdatasync(2) with c++ : yes
'configure' finished successfully (2.239s)
----End of configure
----Start of make(this compiles fine!!)
[make output omitted for brevity]
Waf: Leaving directory /usr/local/nodejs/node-v0.4.2/build'
'build' finished successfully (21.853s)
-----End of make
-----Start of make test
/usr/bin/python "/usr/local/nodejs/node-v0.4.2/tools/scons/scons.py" -
j 2 -C "/usr/local/nodejs/node-v0.4.2/build/default/" -Y "/usr/local/
nodejs/node-v0.4.2/deps/v8" visibility=default mode=release arch=ia32
toolchain=gcc library=static
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: `library' is up to date.
scons: done building targets.
DEST_OS: linux
DEST_CPU: ia32
Parallel Jobs: 2
Product type: program
python tools/test.py --mode=release simple message
[00:00|% 0|+ 0|- 0]: release test-pipe-
head === release test-
pipe-head ===
Path: simple/test-pipe-head
Command: build/default/node /usr/local/nodejs/node-v0.4.2/test/simple/
test-pipe-head.js
--- CRASHED ---
...
All of the subsequent tests fail in a similar fashion.
-----End of make test
-----Start of make install (I did not execute make test on the first few tries.it was only later that I used it)
adil-X:/usr/local/nodejs/node-v0.4.2 # make install
Waf: Entering directory `/usr/local/nodejs/node-v0.4.2/build'
DEST_OS: linux
DEST_CPU: ia32
Parallel Jobs: 2
Product type: program
* installing build/default/config.h as /usr/local/nodejs/include/node/
config.h
* installing build/default/tools/nodejs.pc as /usr/local/nodejs/lib/
pkgconfig/nodejs.pc
* installing build/default/node as /usr/local/nodejs/bin/node
* installing build/default/src/node_config.h as /usr/local/nodejs/
include/node/node_config.h
Waf: Leaving directory `/usr/local/nodejs/node-v0.4.2/build'
'install' finished successfully (0.122s)
-----End of make install
I updated the PATH
variable to include the nodejs bin.
Now nodejs crashes with following error on startup
adil-X:/usr/local/nodejs/node-v0.4.2 # node example.js
node.js:0
Segmentation fault
still, I can see the node.js version
adil-X:~ # node -v
v0.4.2
OS/Arch info:
adil-X:~ # cat /etc/*release
LSB_VERSION="core-2.0-noarch:core-3.2-noarch:core-4.0-noarch:core-2.0-
ia32:core-3.2-ia32:core-4.0-ia32"
openSUSE 11.3 (i586)
adil-X:~ # cat /proc/cpuinfo
vendor_id :GenuineIntel
cpu family : 6
model : 23
model name : Intel(R) Core(TM)2 Duo CPU T6500 @ 2.10GHz
stepping : 10
cpu MHz : 1200.000
cache size : 2048 KB
With no errors on the way when building from source, I am unable to
figure out the problem.
am I missing something obvious? thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我可以建议一些机制来尝试追踪这个问题。
首先,在
nodejs
上使用strace(1)
和ltrace(1)
:然后查看
/tmp/node.*< /code> 文件来发现它在崩溃前一刻正在做什么。 编辑:
strace(1)
报告程序进行的系统调用;由于程序通过系统调用与外界交互,因此它通常是查找错误的最快机制。ltrace(1)
报告动态库调用,这通常是有关程序内部工作的更多信息。两者都有用。其次,运行 dmesg > /tmp/dmesg 并查看 dmesg 输出中的段错误信息,它看起来像这样:
That's an Adobe Flash crash;将地址与程序上的
readelf -s
输出进行比较,您可能能够猜测到函数发生段错误的程度,这在阅读源代码时可能会有所帮助。 (通过地址猜测您进入函数的程度是一个很长的机会,但我发现知道是否应该查看函数的开头或结尾附近很有用。)第三,您可以使用
valgrind(1)
:Valgrind 是一个令人印象深刻的工具,可能需要大量的学习才能真正了解。我使用它的时间很少,给我留下了深刻的印象,但我无法像其他更简单的工具那样提供像样的指南。
第四,您可以在
gdb
下运行nodejs
:当它死掉时,运行
bt
来获取回溯。gdb
也是一个令人印象深刻的程序,您可能会找到使用它失败的确切行,但也需要大量的学习才能真正知道。我很幸运,回溯通常足以找到错误。如果幸运的话,您将被指向失败的确切函数,并且
ltrace(1)
将为您提供该函数的参数。这有望足以追踪特定的错误。There's a few mechanisms I can suggest to try to track down this problem.
First, use
strace(1)
andltrace(1)
onnodejs
:Then look through the
/tmp/node.*
files to discover what it was doing moments before it crashed. Edit:strace(1)
reports the system calls that the program makes; as programs interact with the outside world via system calls, it's often the fastest mechanism to finding bugs.ltrace(1)
reports dynamic library calls, which is frequently a lot more information about the internal workings of the program. Both are useful.Second, run
dmesg > /tmp/dmesg
and look through thedmesg
output for the segfault information, it'll look like this:That's an Adobe Flash crash; comparing the addresses against
readelf -s
output on the program, you might be able to guess how far into the function the segfault is occurring, which might help when reading the source code. (It's a long shot to guess by address how far you are into a function, but I've found it useful to know if I should look near the start or end of a function.)Third, you could run the program with
valgrind(1)
:Valgrind is an impressive tool that might require a fair amount of learning to really know. The little I've used it, I've been impressed, but I can't give as decent a guide as the other simpler tools.
Fourth, you could run
nodejs
undergdb
:When it dies, run
bt
to get a backtrace.gdb
is also an impressive program, and you could probably find the exact line that fails using it, but it too takes a fair amount of learning to really know. I've been lucky enough that backtraces were usually enough to find the fault.With luck you'll be pointed to the exact function that failed, and
ltrace(1)
will give you the arguments of that function. This'll hopefully be enough to track down the specific bug.问题已在 nodejs-v0.4.5 中解决。完全没有麻烦。也许 nodejs-v0.4.2 确实存在错误。
problem fixed in nodejs-v0.4.5.no hassle at all. Maybe there was really a bug in nodejs-v0.4.2 afterall.