ubuntu16.04 安装openresty, 启动openresty 报错 illegal instruction

674 views
Skip to first unread message

ping yao

unread,
May 4, 2017, 11:37:53 PM5/4/17
to openresty
完全参考 openresty.org/en/installation.html 里面的步骤
先安装工具
sudo apt-get install libreadline-dev libncurses5-dev libpcre3-dev \
    libssl-dev perl make build-essential curl

./configure --with-pcre-jit --with-ipv6

configure最后输出:
checking for PCRE library ... found
checking for PCRE JIT support ... found
checking for OpenSSL library ... found
checking for zlib library ... found
creating objs/Makefile

Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ using system zlib library

nginx path prefix: "/usr/local/openresty/nginx"
nginx binary file: "/usr/local/openresty/nginx/sbin/nginx"
nginx modules path: "/usr/local/openresty/nginx/modules"
nginx configuration prefix: "/usr/local/openresty/nginx/conf"
nginx configuration file: "/usr/local/openresty/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/openresty/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/openresty/nginx/logs/error.log"
nginx http access log file: "/usr/local/openresty/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"

然后 make 没有报错
sudo make install 也成功

运行报错:
illegal instruction (core dumped)

:~/openresty/openresty-1.11.2.3$ gdb /usr/local/openresty/bin/openresty
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.04) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/local/openresty/bin/openresty...done.
(gdb) r
Starting program: /usr/local/openresty/bin/openresty
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGILL, Illegal instruction.
x64_init_random () at x64/src/lj_str_hash_x64.h:153
153 seed = _mm_crc32_u32(0, getpid());
(gdb) bt
#0 x64_init_random () at x64/src/lj_str_hash_x64.h:153
#1 x64_init_random_constructor () at x64/src/lj_str_hash_x64.h:185
#2 0x00007ffff7de74ea in call_init (l=<optimized out>, argc=argc@entry=1,
argv=argv@entry=0x7fffffffdc98, env=env@entry=0x7fffffffdca8)
at dl-init.c:72
#3 0x00007ffff7de75fb in call_init (env=0x7fffffffdca8, argv=0x7fffffffdc98,
argc=1, l=<optimized out>) at dl-init.c:30
#4 _dl_init (main_map=0x7ffff7ffe168, argc=1, argv=0x7fffffffdc98,
env=0x7fffffffdca8) at dl-init.c:120
#5 0x00007ffff7dd7cfa in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
#6 0x0000000000000001 in ?? ()
#7 0x00007fffffffe078 in ?? ()
#8 0x0000000000000000 in ?? ()
(gdb)



不知道是什么原因,求救


Zexuan Luo

unread,
May 6, 2017, 1:50:15 AM5/6/17
to openresty
看上去像是由于在不支持 SSE4,2 上运行 SSE4.2 指令 _mm_crc32_u32 导致的问题。
但是有趣的是,我看源码里有
#if defined(__SSE4_2__) && defined(__x86_64) && defined(__GNUC__)
在不支持 SSE 4.2 的机器上不应该编译出来才对。

编译 OpenResty 的机器和运行 OpenResty 是否是同一台机器?
能否提供 grep flag /proc/cpuinfo 的输出结果?

在 2017年5月5日星期五 UTC+8上午11:37:53,ping yao写道:

spacewander

unread,
May 6, 2017, 2:36:45 PM5/6/17
to openresty
更正一处错误: 即使平台不支持特定指令集,如果在编译器选项指定使用该指令集,仍然可以编译通过。 http://gcc.gnu.org/ml/gcc-help/2009-08/msg00257.html 对应解决办法: 安装的时候删掉 configure 里面添加 sse4 选项的那段代码,重新运行就不会用到 sse4 指令集。当前的 configure 判断有 bug。
------------------ 原始邮件 ------------------
发件人: "spacewanderlzx"<spacewa...@gmail.com>
发送时间: 2017年5月6日(星期六) 中午1:50
收件人: "openresty"<open...@googlegroups.com>;
主题: [openresty] Re: ubuntu16.04 安装openresty, 启动openresty 报错 illegal instruction
--
--
邮件来自列表“openresty”,专用于技术讨论!
订阅: 请发空白邮件到 openresty...@googlegroups.com
发言: 请发邮件到 open...@googlegroups.com
退订: 请发邮件至 openresty+...@googlegroups.com
归档: http://groups.google.com/group/openresty
官网: http://openresty.org/
仓库: https://github.com/agentzh/ngx_openresty
教程: http://openresty.org/download/agentzh-nginx-tutorials-zhcn.html

ping yao

unread,
May 8, 2017, 4:28:58 AM5/8/17
to openresty
编译 OpenResty 的机器和运行 OpenResty 是同一台机器,机器比较老了,thinkpad t400, 2010年的

grep flag /proc/cpuinfo
flags        : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts nopl aperfmperf eagerfpu pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm tpr_shadow vnmi flexpriority dtherm ida
flags        : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts nopl aperfmperf eagerfpu pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm tpr_shadow vnmi flexpriority dtherm ida

看上去应该是不支持 sse4.2


运行configure,结果中有关sse的部分:
platform: linux (linux)
cp -rp bundle/ build
cd build
cd LuaJIT-2.1-20170405
INFO: found -msse4.2 in cc.
make TARGET_STRIP=@: CCDEBUG=-g XCFLAGS='-DLUAJIT_ENABLE_LUA52COMPAT -msse4.2' CC=cc PREFIX=/usr/local/openresty/luajit
。。。。。
==== Successfully built LuaJIT 2.1.0-beta2 ====
make install TARGET_STRIP=@: CCDEBUG=-g XCFLAGS='-DLUAJIT_ENABLE_LUA52COMPAT -msse4.2' CC=cc PREFIX=/usr/local/openresty/luajit DESTDIR=/home/will/openresty/openresty-1.11.2.3/build/luajit-root/
。。。。

是不是因为只是发现编译器支持sse4.2,没有考虑机器是否支持sse4.2,导致编译成功但运行错误



在 2017年5月6日星期六 UTC+8下午1:50:15,Zexuan Luo写道:
看上去像是由于在不支持 SSE4,2 上运行 SSE4.2 指令 _mm_crc32_u32 导致的问题。
但是有趣的是,我看源码里有
#if defined(__SSE4_2__) && defined(__x86_64) && defined(__GNUC__)
在不支持 SSE 4.2 的机器上不应该编译出来才对。

编译 OpenResty 的机器和运行 OpenResty 是否是同一台机器?
能否提供 grep flag /proc/cpuinfo 的输出结果?

在 2017年5月5日星期五 UTC+8上午11:37:53,ping yao写道:
完全参考 openresty.org/en/installation.html 里面的步骤
先安装工具
sudo apt-get install libreadline-dev libncurses5-dev libpcre3-dev \
    libssl-dev perl make build-essential curl

./configure

ping yao

unread,
May 8, 2017, 5:02:15 AM5/8/17
to openresty
参考 gcc.gnu.org/ml/gcc-help/2009-08/msg00257.html

我将configure里面的

$luajit_xcflags .= " -msse4.2";

改成了

$luajit_xcflags .= " -msse4a";

然后重新configure,make,make install

现在可以正确运行了 看来是编译选项与运行机器不匹配导致的。

非常感谢^_^

在 2017年5月8日星期一 UTC+8下午4:28:58,ping yao写道:
Reply all
Reply to author
Forward
0 new messages