OpenResty on Raspberry Pi

910 views
Skip to first unread message

Bogdan Irimia

unread,
Feb 2, 2015, 10:38:25 AM2/2/15
to openre...@googlegroups.com
Hello all

We are using OpenResty on Raspberry Pi B+, which has been compiled like this:

env PATH=/sbin:$PATH ./configure --prefix=${iprefix} --with-luajit
make

During the making these are some messages (removed the path prefix):

cd /<prefix>/openresty/ngx_openresty-1.7.7.1/build/nginx-1.7.7 && make
make[1]: Entering directory '/<prefix>/openresty/ngx_openresty-1.7.7.1/build/nginx-1.7.7'
make -f objs/Makefile
make[2]: Entering directory '/<prefix>/auth/openresty/ngx_openresty-1.7.7.1/build/nginx-1.7.7'
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -g -I/<prefix>/auth/openresty/ngx_openresty-1.7.7.1/build/luajit-root/<prefix>/luajit/include/luajit-2.1 -O2 -DNDK_SET_VAR -DNDK_UPSTREAM_LIST -DNDK_SET_VAR -DNDK_SET_VAR -DNDK_SET_VAR -DLUA_DEFAULT_PATH='"/<prefix>/lualib/?.lua;/<prefix>/lualib/?/init.lua"' -DLUA_DEFAULT_CPATH='"/<prefix>/lualib/?.so"' -DNDK_SET_VAR -I src/core -I src/event -I src/event/modules -I src/http -I src/http/modules -I src/os/unix -I ../ngx_devel_kit-0.2.19/objs -I objs/addon/ndk -I /<prefix>/auth/openresty/ngx_openresty-1.7.7.1/build/luajit-root/<prefix>/luajit/include/luajit-2.1 -I ../ngx_lua-0.9.13/src/api -I objs \
        -o objs/src/core/nginx.o \
        src/core/nginx.c
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -g -I/<prefix>/auth/openresty/ngx_openresty-1.7.7.1/build/luajit-root/<prefix>/luajit/include/luajit-2.1 -O2 -DNDK_SET_VAR -DNDK_UPSTREAM_LIST -DNDK_SET_VAR -DNDK_SET_VAR -DNDK_SET_VAR -DLUA_DEFAULT_PATH='"/<prefix>/lualib/?.lua;/<prefix>/lualib/?/init.lua"' -DLUA_DEFAULT_CPATH='"/<prefix>/lualib/?.so"' -DNDK_SET_VAR -I src/core -I src/event -I src/event/modules -I src/http -I src/http/modules -I src/os/unix -I ../ngx_devel_kit-0.2.19/objs -I objs/addon/ndk -I /<prefix>/auth/openresty/ngx_openresty-1.7.7.1/build/luajit-root/<prefix>/luajit/include/luajit-2.1 -I ../ngx_lua-0.9.13/src/api -I objs \
        -o objs/src/core/ngx_log.o \
        src/core/ngx_log.c
 
This is some information about the sistem:


# uname -a
Linux analytics 3.12.22+ #691 PREEMPT Wed Jun 18 18:29:58 BST 2014 armv6l GNU/Linux

/etc/os-release:

...
VERSION_ID="7"
VERSION="7 (wheezy)"
ID=raspbian
ID_LIKE=debian
ANSI_COLOR="1;31"
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

In the application I am building a timer like this:

nginx.conf:

http {
    ...

    lua_shared_dict timer_locks 1m;
    init_worker_by_lua_file "../app/timer.lua";

    ...
}

timer.lua:

local check_users_delay = 60  -- in seconds

-- redis connection function is here --

local function check_users(premature)   
    if not premature then
        -- set timer immediatelly to run at exactly the defined interval
        local ok, err = ngx.timer.at(check_users_delay, check_users)
        if not ok then
            ngx.log(ngx.ERR, 'Failed to create "check_users" timer: '..err)
            return
        end
       
        local dict = ngx.shared.timer_locks
        local lock, err = dict:add("lock_users", ngx.worker.pid(), check_users_delay)

        if lock then
            -- check for expired users --
            -- this code uses Redis --
        else
            if err == "exists" then
                return
            else
                ngx.log(ngx.ERR, err)
            end
        end
    end
end

local ok, err = ngx.timer.at(check_users_delay, check_users)
if not ok then
    ngx.log(ngx.ERR, 'Failed to create "check_users" timer: '..err)
    return
end

When the application is started, we get in the nginx error log this:

2015/02/02 14:57:05 [notice] 6456#0: using the "epoll" event method
2015/02/02 14:57:05 [notice] 6456#0: openresty/1.7.7.1
2015/02/02 14:57:05 [notice] 6456#0: built by gcc 4.6.3 (Debian 4.6.3-14+rpi1)
2015/02/02 14:57:05 [notice] 6456#0: OS: Linux 3.12.22+
2015/02/02 14:57:05 [notice] 6456#0: getrlimit(RLIMIT_NOFILE): 1024:4096
2015/02/02 14:57:05 [notice] 6457#0: start worker processes
2015/02/02 14:57:05 [notice] 6457#0: start worker process 6458
...
2015/02/02 14:58:06 [notice] 6457#0: signal 17 (SIGCHLD) received
2015/02/02 14:58:06 [alert] 6457#0: worker process 6458 exited on signal 7
...

The syslog contains this:

[194098.387842] Alignment trap: not handling instruction ed930b01 at [<000af6a0>]
[194098.387872] Unhandled fault: alignment exception (0x011) at 0xb5fb703e
[194125.024729] Alignment trap: not handling instruction ed930b01 at [<000af6a0>]
[194125.024762] Unhandled fault: alignment exception (0x011) at 0xb692103e
[194159.418768] Alignment trap: not handling instruction ed930b01 at [<000af6a0>]
[194159.418799] Unhandled fault: alignment exception (0x011) at 0xb5fb703e
[194186.129026] Alignment trap: not handling instruction ed930b01 at [<000af6a0>]
[194186.129058] Unhandled fault: alignment exception (0x011) at 0xb692103e
[194220.449771] Alignment trap: not handling instruction ed930b01 at [<000af6a0>]
[194220.449803] Unhandled fault: alignment exception (0x011) at 0xb5fb703e
[194247.210993] Alignment trap: not handling instruction ed930b01 at [<000af6a0>]
[194247.211023] Unhandled fault: alignment exception (0x011) at 0xb692103e
[194281.490700] Alignment trap: not handling instruction ed930b01 at [<000af6a0>]
[194281.490732] Unhandled fault: alignment exception (0x011) at 0xb5fb703e
[194308.316655] Alignment trap: not handling instruction ed930b01 at [<000af6a0>]
[194308.316683] Unhandled fault: alignment exception (0x011) at 0xb692103e
[194342.524616] Alignment trap: not handling instruction ed930b01 at [<000af6a0>]
[194342.524646] Unhandled fault: alignment exception (0x011) at 0xb5fb703e
[194369.418437] Alignment trap: not handling instruction ed930b01 at [<000af6a0>]
[194369.418466] Unhandled fault: alignment exception (0x011) at 0xb692103e
[194403.552363] Alignment trap: not handling instruction ed930b01 at [<000af6a0>]
[194403.552394] Unhandled fault: alignment exception (0x011) at 0xb5fb703e
[194430.519373] Alignment trap: not handling instruction ed930b01 at [<000af6a0>]
[194430.519405] Unhandled fault: alignment exception (0x011) at 0xb692103e
[194464.593247] Alignment trap: not handling instruction ed930b01 at [<000af6a0>]
[194464.593279] Unhandled fault: alignment exception (0x011) at 0xb5fb703e
[194491.623686] Alignment trap: not handling instruction ed930b01 at [<000af6a0>]
[194491.623716] Unhandled fault: alignment exception (0x011) at 0xb692103e
[194525.634283] Alignment trap: not handling instruction ed930b01 at [<000af6a0>]
[194525.634316] Unhandled fault: alignment exception (0x011) at 0xb5fb703e

We believe we hit some kind of a bug related to the architecture OpenResty has been compiled for (Raspberry PI, using an ARM processor).
We found one single blog entry which is in chinese and, when translated with Google translate, seems to suggest we should use the optimization level 0 for nginx when it is compiled:
http://blog.changyy.org/2013/07/nginx-worker-process-exited-on-signal-7.html

I should mention that the application works ok on x86 platforms (FreeBSD and Ubuntu).

How can we solve this? How can we change the option  -O2 to -O0? Could this solve our problem?

Thank you

Lord Nynex

unread,
Feb 2, 2015, 2:08:59 PM2/2/15
to openre...@googlegroups.com
Hello,

./configure --with-cc-opt="-O0" --prefix=${iprefix} --with-luajit

--
You received this message because you are subscribed to the Google Groups "openresty-en" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openresty-en...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Bogdan Irimia

unread,
Feb 4, 2015, 4:02:22 AM2/4/15
to openre...@googlegroups.com
Indeed this seemed to be the problem.
Using -O0 option fixed the issue on Raspberry Pi.

Thank you

Bogdan Irimia

Monday, February 02, 2015 21:08
Hello,

./configure --with-cc-opt="-O0" --prefix=${iprefix} --with-luajit


--
You received this message because you are subscribed to the Google Groups "openresty-en" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openresty-en...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Monday, February 02, 2015 17:38

Lord Nynex

unread,
Feb 4, 2015, 4:00:07 PM2/4/15
to openre...@googlegroups.com
agentzh,

I've created a pull request at https://github.com/openresty/ngx_openresty/pull/84 that changes the default cc-opts for arm platforms on POSIX machines. 

Dmitry Kireev

unread,
Feb 18, 2015, 1:33:39 PM2/18/15
to openre...@googlegroups.com
If anyone is interested, I created an openresty binary deb package for raspberry pi (ARM only) here https://bintray.com/kireevco/deb/openresty.
Here is the build script I used.

Yichun Zhang (agentzh)

unread,
Feb 18, 2015, 2:34:46 PM2/18/15
to openresty-en
Hello!

On Wed, Feb 18, 2015 at 10:33 AM, Dmitry Kireev wrote:
> If anyone is interested, I created an openresty binary deb package for
> raspberry pi (ARM only) here https://bintray.com/kireevco/deb/openresty.
> Here is the build script I used.
>

Please ensure that you are using the latest git master of ngx_lua in
your ARM build because I recently fixed some data alignment bugs in
ngx_lua's shared dict implementation which affects architectures
requiring data alignment, like ARMv6.

FWIW I'm going to release OpenResty 1.7.10.1 RC1 very soon, which will
include the fix.

Regards,
-agentzh
Reply all
Reply to author
Forward
0 new messages