Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

编译错误 #1

Closed
randall05 opened this issue Jun 25, 2010 · 3 comments
Closed

编译错误 #1

randall05 opened this issue Jun 25, 2010 · 3 comments

Comments

@randall05
Copy link

编译时发生如下错误:
ake -f objs/Makefile
make[1]: Entering directory /root/nginx-0.7.65' gcc -c -DNDK -DNDK_SET_VAR -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules -I /root/nginx-module/simpl-it-ngx_devel_kit-7ccc46d -I /root/nginx-module/simpl-it-ngx_devel_kit-7ccc46d/src -I /root/nginx-module/simpl-it-ngx_devel_kit-7ccc46d/src/auto -I src/mail \ -o objs/addon/src/ngx_http_lua_util.o \ /root/nginx-module/lua-nginx-module/src/ngx_http_lua_util.c gcc -c -DNDK -DNDK_SET_VAR -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules -I /root/nginx-module/simpl-it-ngx_devel_kit-7ccc46d -I /root/nginx-module/simpl-it-ngx_devel_kit-7ccc46d/src -I /root/nginx-module/simpl-it-ngx_devel_kit-7ccc46d/src/auto -I src/mail \ -o objs/addon/src/ngx_http_lua_cache.o \ /root/nginx-module/lua-nginx-module/src/ngx_http_lua_cache.c /root/nginx-module/lua-nginx-module/src/ngx_http_lua_util.c: In function ‘ngx_http_lua_var_get’: /root/nginx-module/lua-nginx-module/src/ngx_http_lua_util.c:320: 错误:提供给函数 ‘ngx_http_get_variable’ 的实参太少 make[1]: *** [objs/addon/src/ngx_http_lua_util.o] 错误 1 make[1]: *** 正在等待未完成的任务.... make[1]: Leaving directory/root/nginx-0.7.65'
make: *** [build] 错误 2

环境:
CentOS 5.3
nginx-0.7.65
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
ReadMe文件中所说的三个模块均是从github上下载的最新tar包

@chaoslawful
Copy link
Contributor

nginx接口向前兼容问题,fixing....

@chaoslawful
Copy link
Contributor

fixed,请用HEAD再试一下

@randall05
Copy link
Author

呃……我自己也是临时把第四个参数设成1了,编译可通过。

@Vittly Vittly mentioned this issue Nov 27, 2011
Closed
@IPv6 IPv6 mentioned this issue Sep 3, 2012
@cs0604 cs0604 mentioned this issue Sep 6, 2013
doujiang24 referenced this issue in doujiang24/lua-nginx-module Nov 2, 2015
thibaultcha added a commit to thibaultcha/lua-nginx-module that referenced this issue Feb 15, 2019
This issue appeared in our EC2 test cluster, which compiles Nginx with
`-DNGX_LUA_USE_ASSERT` and `-DNGX_LUA_ABORT_AT_PANIC`.

The lua-resty-redis test:

    === TEST 1: github issue openresty#108: ngx.locaiton.capture + redis.set_keepalive

in t/bugs.t [1] would produce core dumps in the check leak testing mode.

The backtrace for these core dumps was:

    #0  0x00007fd417bee277 in raise () from /lib64/libc.so.6
    openresty#1  0x00007fd417bef968 in abort () from /lib64/libc.so.6
    openresty#2  0x00007fd417be7096 in __assert_fail_base () from /lib64/libc.so.6
    openresty#3  0x00007fd417be7142 in __assert_fail () from /lib64/libc.so.6
    openresty#4  0x000000000050d227 in ngx_http_lua_socket_tcp_resume_conn_op (spool=c/ngx_http_lua_socket_tcp.c:3963
    openresty#5  0x000000000050e51a in ngx_http_lua_socket_tcp_finalize (r=r@entry=0x5628) at ../../src/ngx_http_lua_socket_tcp.c:4195
    openresty#6  0x000000000050e570 in ngx_http_lua_socket_tcp_cleanup (data=0x7fd419p_lua_socket_tcp.c:3755
    openresty#7  0x0000000000463aa5 in ngx_http_free_request (r=r@entry=0xbfaec0, rc=http_request.c:3508
    ...

Which was caused by the following assertion in ngx_http_lua_socket_tcp.c
with `NGX_DEBUG`:

    #if (NGX_DEBUG)
        ngx_http_lua_assert(spool->connections >= 0);

    #else

Thanks to Mozilla's rr, a recorded session showed that
`spool->connections` was `-1`.

Unfortunately, reproducing this case does not seem possible, since the
failure is due to the request cleanup (`ngx_http_free_request`). Here is
an explanation:

    -- thread 1
    local sock = ngx.socket.tcp()
    sock:connect()
    sock:setkeepalive() -- pool created, connections: 1

        -- thread 2
        local sock = ngx.socket.tcp()
        sock:connect() -- from pool, connections: 1

    -- thread 1
    -- sock from thread 1 idle timeout, closes, and calls
    -- ngx_http_lua_socket_tcp_finalize, connections: 0

        -- thread 2
        sock:setkeepalive() -- connections: -1
        -- ngx_http_lua_socket_tcp_resume_conn_op gets called, assertion fails

In order to avoid this race condition, we must determine whether the
socket pool exists or not, not from the
`ngx_http_lua_socket_tcp_upstream` struct, but from the Lua Registry.
This way, when thread 2's socket enters the keepalive state, it will
respect the previous call to `ngx_http_lua_socket_free_pool` (which
unset the pool from the registry).

[1]: https://github.com/openresty/lua-resty-redis/blob/master/t/bugs.t
thibaultcha added a commit to thibaultcha/lua-nginx-module that referenced this issue Feb 16, 2019
This issue appeared in our EC2 test cluster, which compiles Nginx with
`-DNGX_LUA_USE_ASSERT` and `-DNGX_LUA_ABORT_AT_PANIC`.

The lua-resty-redis test:

    === TEST 1: github issue openresty#108: ngx.locaiton.capture + redis.set_keepalive

in t/bugs.t [1] would produce core dumps in the check leak testing mode.

The backtrace for these core dumps was:

    #0  0x00007fd417bee277 in raise () from /lib64/libc.so.6
    openresty#1  0x00007fd417bef968 in abort () from /lib64/libc.so.6
    openresty#2  0x00007fd417be7096 in __assert_fail_base () from /lib64/libc.so.6
    openresty#3  0x00007fd417be7142 in __assert_fail () from /lib64/libc.so.6
    openresty#4  0x000000000050d227 in ngx_http_lua_socket_tcp_resume_conn_op (spool=c/ngx_http_lua_socket_tcp.c:3963
    openresty#5  0x000000000050e51a in ngx_http_lua_socket_tcp_finalize (r=r@entry=0x5628) at ../../src/ngx_http_lua_socket_tcp.c:4195
    openresty#6  0x000000000050e570 in ngx_http_lua_socket_tcp_cleanup (data=0x7fd419p_lua_socket_tcp.c:3755
    openresty#7  0x0000000000463aa5 in ngx_http_free_request (r=r@entry=0xbfaec0, rc=http_request.c:3508
    ...

Which was caused by the following assertion in ngx_http_lua_socket_tcp.c
with `NGX_DEBUG`:

    #if (NGX_DEBUG)
        ngx_http_lua_assert(spool->connections >= 0);

    #else

Thanks to Mozilla's rr, a recorded session showed that
`spool->connections` was `-1`.

Here is a reproducible test case:

    local sock1 = ngx.socket.tcp()
    local sock2 = ngx.socket.tcp()

    sock1:connect()
    sock2:connect()

    sock1:setkeepalive() -- pool created, connections: 1
    sock2:setkeepalive() -- connections: 1

    sock1:connect() -- connections: 1
    sock2:connect() -- connections: 1

    sock1:close() -- connections: 0
    sock2:close() -- connections: -1
    -- ngx_http_lua_socket_tcp_resume_conn_op gets called, assertion fails

In order to avoid this race condition, we must determine whether the
socket pool exists or not, not from the
`ngx_http_lua_socket_tcp_upstream` struct, but from the Lua Registry.
This way, when thread 2's socket enters the keepalive state, it will
respect the previous call to `ngx_http_lua_socket_free_pool` (which
unset the pool from the registry).

[1]: https://github.com/openresty/lua-resty-redis/blob/master/t/bugs.t
chipitsine added a commit to chipitsine/lua-nginx-module that referenced this issue Sep 17, 2019
…found by coverity

   deref_ptr: Directly dereferencing pointer c.
419    if (c->addr_text.len) {
420        p = ngx_snprintf(buf, len, ", client: %V", &c->addr_text);
421        len -= p - buf;
422        buf = p;
423    }
424
   CID 149837 (openresty#1 of 1): Dereference before null check (REVERSE_INULL)check_after_deref: Null-checking c suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
425    if (c && c->listening && c->listening->addr_text.len) {
426        p = ngx_snprintf(buf, len, ", server: %V", &c->listening->addr_text);
427        /* len -= p - buf; */
428        buf = p;
429    }
rainingmaster pushed a commit that referenced this issue Dec 15, 2020
…found by coverity

   deref_ptr: Directly dereferencing pointer c.
419    if (c->addr_text.len) {
420        p = ngx_snprintf(buf, len, ", client: %V", &c->addr_text);
421        len -= p - buf;
422        buf = p;
423    }
424
   CID 149837 (#1 of 1): Dereference before null check (REVERSE_INULL)check_after_deref: Null-checking c suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
425    if (c && c->listening && c->listening->addr_text.len) {
426        p = ngx_snprintf(buf, len, ", server: %V", &c->listening->addr_text);
427        /* len -= p - buf; */
428        buf = p;
429    }
chipitsine added a commit to chipitsine/lua-nginx-module that referenced this issue Jan 9, 2021
…eference found by Coverity

443    c = log->data;
444
   deref_ptr: Directly dereferencing pointer c.
445    if (c->addr_text.len) {
446        p = ngx_snprintf(buf, len, ", client: %V", &c->addr_text);
447        len -= p - buf;
448        buf = p;
449    }
450
   CID 251611 (openresty#1 of 1): Dereference before null check (REVERSE_INULL)check_after_deref: Null-checking c suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
451    if (c && c->listening && c->listening->addr_text.len) {
452        p = ngx_snprintf(buf, len, ", server: %V", &c->listening->addr_text);
453        buf = p;
454    }
chipitsine added a commit to chipitsine/lua-nginx-module that referenced this issue Jan 9, 2021
…eference found by Coverity

329    c = log->data;
330
   deref_ptr: Directly dereferencing pointer c.
331    if (c->addr_text.len) {
332        p = ngx_snprintf(buf, len, ", client: %V", &c->addr_text);
333        len -= p - buf;
334        buf = p;
335    }
336
   CID 251578 (openresty#1 of 1): Dereference before null check (REVERSE_INULL)check_after_deref: Null-checking c suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
337    if (c && c->listening && c->listening->addr_text.len) {
338        p = ngx_snprintf(buf, len, ", server: %V", &c->listening->addr_text);
339        buf = p;
340    }
341
chipitsine added a commit to chipitsine/lua-nginx-module that referenced this issue Jan 11, 2021
… by Coverity

734    buf = p;
735
   deref_ptr: Directly dereferencing pointer c.
736    if (c->addr_text.len) {
737        p = ngx_snprintf(buf, len, ", client: %V", &c->addr_text);
738        len -= p - buf;
739        buf = p;
740    }
741
   CID 149839 (openresty#1 of 1): Dereference before null check (REVERSE_INULL)check_after_deref: Null-checking c suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
742    if (c && c->listening && c->listening->addr_text.len) {
743        p = ngx_snprintf(buf, len, ", server: %V", &c->listening->addr_text);
744        /* len -= p - buf; */
745        buf = p;
746    }
spacewander pushed a commit that referenced this issue Jan 12, 2021
734    buf = p;
735
   deref_ptr: Directly dereferencing pointer c.
736    if (c->addr_text.len) {
737        p = ngx_snprintf(buf, len, ", client: %V", &c->addr_text);
738        len -= p - buf;
739        buf = p;
740    }
741
   CID 149839 (#1 of 1): Dereference before null check (REVERSE_INULL)check_after_deref: Null-checking c suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
742    if (c && c->listening && c->listening->addr_text.len) {
743        p = ngx_snprintf(buf, len, ", server: %V", &c->listening->addr_text);
744        /* len -= p - buf; */
745        buf = p;
746    }
zhuizhuhaomeng pushed a commit that referenced this issue Oct 19, 2021
==openresty==70603==ERROR: AddressSanitizer: memcpy-param-overlap: memory ranges [0x621000001500,0x621000002181) and [0x62100000187f, 0x621000002500) overlap
    #0 0x7f3db1899ffe  (/lib64/libasan.so.5+0x99ffe)
    #1 0x9da926  (/usr/local/openresty-debug/nginx/sbin/nginx+0x9da926)
    #2 0x9dd1a1  (/usr/local/openresty-debug/nginx/sbin/nginx+0x9dd1a1)
    #3 0x4c89c6  (/usr/local/openresty-debug/nginx/sbin/nginx+0x4c89c6)
    #4 0x5d1e4e  (/usr/local/openresty-debug/nginx/sbin/nginx+0x5d1e4e)
    #5 0x4c89c6  (/usr/local/openresty-debug/nginx/sbin/nginx+0x4c89c6)
    #6 0x5b8583  (/usr/local/openresty-debug/nginx/sbin/nginx+0x5b8583)
    #7 0x4c89c6  (/usr/local/openresty-debug/nginx/sbin/nginx+0x4c89c6)
    #8 0x4b4419  (/usr/local/openresty-debug/nginx/sbin/nginx+0x4b4419)
    #9 0x427f16  (/usr/local/openresty-debug/nginx/sbin/nginx+0x427f16)
    #10 0x7f3daff27554  (/lib64/libc.so.6+0x22554)
    #11 0x42d537  (/usr/local/openresty-debug/nginx/sbin/nginx+0x42d537)
chipitsine added a commit to chipitsine/lua-nginx-module that referenced this issue May 24, 2022
    deref_ptr: Directly dereferencing pointer ctx.
1143    *ctx = ngx_http_get_module_ctx(r, ngx_http_lua_module);
    CID 258020 (openresty#1 of 1): Dereference before null check (REVERSE_INULL)check_after_deref: Null-checking ctx suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
1144    if (ctx == NULL) {
1145        return NGX_HTTP_LUA_FFI_NO_REQ_CTX;
1146    }
zhuizhuhaomeng pushed a commit that referenced this issue May 25, 2022
…2051)

deref_ptr: Directly dereferencing pointer ctx.
1143    *ctx = ngx_http_get_module_ctx(r, ngx_http_lua_module);
    CID 258020 (#1 of 1): Dereference before null check (REVERSE_INULL)check_after_deref: Null-checking ctx suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
1144    if (ctx == NULL) {
1145        return NGX_HTTP_LUA_FFI_NO_REQ_CTX;
1146    }
zhuizhuhaomeng added a commit that referenced this issue May 25, 2022
    } else if (tctx.pool) {
   	
CID 251579 (#1 of 1): Use after free (USE_AFTER_FREE)
18. deref_arg: Calling ngx_destroy_pool dereferences freed pointer tctx.pool.
762        ngx_destroy_pool(tctx.pool);
763    }
764}
xiaocang added a commit to xiaocang/lua-nginx-module that referenced this issue Jul 11, 2024
…t_peer at function end.

Avoid inserting new parameters in the middle of the function to prevent core
dumps when using old lua-resty-core with new lua-nginx-module.

Example stack trace:

```
Message: Process 1414245 (nginx) of user 1000 dumped core.

        Stack trace of thread 1414245:
        #0  0x00007ff596938285 __strlen_avx2 (libc.so.6 + 0x162285)
        openresty#1  0x00007ff596f623d2 lj_cf_ffi_string (libluajit-5.1.so.2 + 0x523d2)
        openresty#2  0x00007ff596f1bb4b lj_BC_FUNCC (libluajit-5.1.so.2 + 0xbb4b)
        openresty#3  0x00007ff596f74223 lua_pcall (libluajit-5.1.so.2 + 0x64223)
        openresty#4  0x00000000005044b7 n/a (/home/jiahao/work/org/lua-resty-core/work/nginx/sbin/nginx + 0x1044b7)
```
xiaocang added a commit to xiaocang/lua-nginx-module that referenced this issue Jul 11, 2024
…t_peer at function end.

Avoid inserting new parameters in the middle of the function to prevent core
dumps when using old lua-resty-core with new lua-nginx-module.

Example stack trace:

```
Message: Process 1414245 (nginx) of user 1000 dumped core.

        Stack trace of thread 1414245:
        #0  0x00007ff596938285 __strlen_avx2 (libc.so.6 + 0x162285)
        openresty#1  0x00007ff596f623d2 lj_cf_ffi_string (libluajit-5.1.so.2 + 0x523d2)
        openresty#2  0x00007ff596f1bb4b lj_BC_FUNCC (libluajit-5.1.so.2 + 0xbb4b)
        openresty#3  0x00007ff596f74223 lua_pcall (libluajit-5.1.so.2 + 0x64223)
        openresty#4  0x00000000005044b7 n/a (/home/jiahao/work/org/lua-resty-core/work/nginx/sbin/nginx + 0x1044b7)
```
xiaocang added a commit to xiaocang/lua-nginx-module that referenced this issue Jul 11, 2024
…t function end.

Avoid inserting new parameters in the middle of the function to prevent core
dumps when using old lua-resty-core with new lua-nginx-module.

Example stack trace:

```
Message: Process 2199905 (nginx) of user 1000 dumped core.

Stack trace of thread 2199905:
    #0  0x00007ffaf1e4b385 in OPENSSL_sk_num (st=st@entry=0xffffffff) at crypto/stack/stack.c:382
    openresty#1  0x0000000000510aba in sk_X509_num (sk=0xffffffff) at /opt/ssl/include/openssl/x509.h:99
    openresty#2  ngx_http_lua_ffi_ssl_verify_client (r=<optimized out>, client_certs=<optimized out>, trusted_certs=0xffffffff, depth=<optimized out>, err=0x0)
        at /home/jiahao/work/org/lua-nginx-module/src/ngx_http_lua_ssl_certby.c:1588
```
xiaocang added a commit to xiaocang/lua-nginx-module that referenced this issue Jul 11, 2024
…t function end.

Avoid inserting new parameters in the middle of the function to prevent core
dumps when using old lua-resty-core with new lua-nginx-module.

Example stack trace:

```
Message: Process 2199905 (nginx) of user 1000 dumped core.

Stack trace of thread 2199905:
    #0  0x00007ffaf1e4b385 in OPENSSL_sk_num (st=st@entry=0xffffffff) at crypto/stack/stack.c:382
    openresty#1  0x0000000000510aba in sk_X509_num (sk=0xffffffff) at /opt/ssl/include/openssl/x509.h:99
    openresty#2  ngx_http_lua_ffi_ssl_verify_client (r=<optimized out>, client_certs=<optimized out>, trusted_certs=0xffffffff, depth=<optimized out>, err=0x0)
        at /home/jiahao/work/org/lua-nginx-module/src/ngx_http_lua_ssl_certby.c:1588
```
zhuizhuhaomeng pushed a commit to xiaocang/lua-nginx-module that referenced this issue Jul 12, 2024
…t_peer at function end.

Avoid inserting new parameters in the middle of the function to prevent core
dumps when using old lua-resty-core with new lua-nginx-module.

Example stack trace:

```
Message: Process 1414245 (nginx) of user 1000 dumped core.

        Stack trace of thread 1414245:
        #0  0x00007ff596938285 __strlen_avx2 (libc.so.6 + 0x162285)
        openresty#1  0x00007ff596f623d2 lj_cf_ffi_string (libluajit-5.1.so.2 + 0x523d2)
        openresty#2  0x00007ff596f1bb4b lj_BC_FUNCC (libluajit-5.1.so.2 + 0xbb4b)
        openresty#3  0x00007ff596f74223 lua_pcall (libluajit-5.1.so.2 + 0x64223)
        openresty#4  0x00000000005044b7 n/a (/home/jiahao/work/org/lua-resty-core/work/nginx/sbin/nginx + 0x1044b7)
```
zhuizhuhaomeng pushed a commit to xiaocang/lua-nginx-module that referenced this issue Jul 12, 2024
…t function end.

Avoid inserting new parameters in the middle of the function to prevent core
dumps when using old lua-resty-core with new lua-nginx-module.

Example stack trace:

```
Message: Process 2199905 (nginx) of user 1000 dumped core.

Stack trace of thread 2199905:
    #0  0x00007ffaf1e4b385 in OPENSSL_sk_num (st=st@entry=0xffffffff) at crypto/stack/stack.c:382
    openresty#1  0x0000000000510aba in sk_X509_num (sk=0xffffffff) at /opt/ssl/include/openssl/x509.h:99
    openresty#2  ngx_http_lua_ffi_ssl_verify_client (r=<optimized out>, client_certs=<optimized out>, trusted_certs=0xffffffff, depth=<optimized out>, err=0x0)
        at /home/jiahao/work/org/lua-nginx-module/src/ngx_http_lua_ssl_certby.c:1588
```
xiaocang added a commit to xiaocang/lua-nginx-module that referenced this issue Jul 15, 2024
…t_peer at function end.

Avoid inserting new parameters in the middle of the function to prevent core
dumps when using old lua-resty-core with new lua-nginx-module.

Example stack trace:

```
Message: Process 1414245 (nginx) of user 1000 dumped core.

        Stack trace of thread 1414245:
        #0  0x00007ff596938285 __strlen_avx2 (libc.so.6 + 0x162285)
        openresty#1  0x00007ff596f623d2 lj_cf_ffi_string (libluajit-5.1.so.2 + 0x523d2)
        openresty#2  0x00007ff596f1bb4b lj_BC_FUNCC (libluajit-5.1.so.2 + 0xbb4b)
        openresty#3  0x00007ff596f74223 lua_pcall (libluajit-5.1.so.2 + 0x64223)
        openresty#4  0x00000000005044b7 n/a (/home/jiahao/work/org/lua-resty-core/work/nginx/sbin/nginx + 0x1044b7)
```
xiaocang added a commit to xiaocang/lua-nginx-module that referenced this issue Jul 15, 2024
…t function end.

Avoid inserting new parameters in the middle of the function to prevent core
dumps when using old lua-resty-core with new lua-nginx-module.

Example stack trace:

```
Message: Process 2199905 (nginx) of user 1000 dumped core.

Stack trace of thread 2199905:
    #0  0x00007ffaf1e4b385 in OPENSSL_sk_num (st=st@entry=0xffffffff) at crypto/stack/stack.c:382
    openresty#1  0x0000000000510aba in sk_X509_num (sk=0xffffffff) at /opt/ssl/include/openssl/x509.h:99
    openresty#2  ngx_http_lua_ffi_ssl_verify_client (r=<optimized out>, client_certs=<optimized out>, trusted_certs=0xffffffff, depth=<optimized out>, err=0x0)
        at /home/jiahao/work/org/lua-nginx-module/src/ngx_http_lua_ssl_certby.c:1588
```
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants