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

invalid value (nil) at index 285 in table for 'concat' #19

Open
meisuj815 opened this issue Aug 4, 2021 · 7 comments
Open

invalid value (nil) at index 285 in table for 'concat' #19

meisuj815 opened this issue Aug 4, 2021 · 7 comments

Comments

@meisuj815
Copy link

error:

 [error] 6280#6280: *962711 lua entry thread aborted: runtime error: /usr/local/openresty/lualib/resty/shell.lua:136: invalid value (nil) at index 2 in table for 'concat'
stack traceback:
coroutine 0:
        [C]: in function 'concat'
        /usr/local/openresty/lualib/resty/shell.lua:139: in function 'run'

code:

        local shell = require "resty.shell"

        local stdin = nil
        local timeout = 10000  -- ms
        local max_size = 40960  -- byte

        local ok, stdout, stderr, reason, status =
            shell.run([[curl https://blockchain.info/q/getreceivedbyaddress/123]], stdin, timeout, max_size)

since that is a error output(ok == nil) now I just edit the stdout and stderr to nil in shell.lua;

...
136         local stdout = nil
137         release_tab(tab_pool_tag, stdout_tab)
138
139         local stderr = nil
140         release_tab(tab_pool_tag, stderr_tab)
...
@xiaocang
Copy link
Contributor

xiaocang commented Aug 4, 2021

Hi @meisuj815 , I've tried to reproduce this error using your use case but it did not work on my computer.

Would you mind also providing the following information:

  • The version of openresty you are using
  • The exit code of your command, and the output, like:
$ curl https://blockchain.info/q/getreceivedbyaddress/123
$ echo $?

@meisuj815
Copy link
Author

meisuj815 commented Aug 4, 2021

Hi @xiaocang
I am using lor web framework 0.3.4
OpenResty version:

resty 0.27
nginx version: openresty/1.19.3.2
built with OpenSSL 1.1.1k  25 Mar 2021

I don't know the exactly exit code, since this error happens rate is 1/100, but I guess that is timeout error, both stdout and stderr had this problem. The output I guess sometime is empty content.

This code also error:

    local shell = require "resty.shell"

    local stdin = nil
    local timeout = 10000  -- ms
    local max_size = 40960  -- byte
    local command = 'curl -U ""user:pass"" --proxy http://13.52.235.251:80  --url http://api.ipify.org'

    for i = 1, 1000 do
        local ok, stdout, stderr, reason, status =
            shell.run(command, stdin, timeout, max_size)
        if status ~= 0 then
            ngx.say(status)
            ngx.say(reason)
        end
    end

response:

nil
failed to wait for process: timeout
internal error, please check the log.

log:

...
[error] 22362#22362: *4 [lua] server.lua:56: func(): /usr/local/openresty/lualib/resty/shell.lua:136: invalid value (nil) at index 2 in table for 'concat'
stack traceback:
        /usr/local/lor/lor/lib/router/router.lua:204: in function </usr/local/lor/lor/lib/router/router.lua:194>
        [C]: in function 'concat'
        /usr/local/openresty/lualib/resty/shell.lua:136: in function 'run'
...

@xiaocang
Copy link
Contributor

xiaocang commented Aug 5, 2021

@meisuj815
Weird, I can't reproduce this problem using the same version of openresty, using the same code
Reading the code, I don't think this is possible either

@meisuj815
Copy link
Author

meisuj815 commented Aug 8, 2021

Hi @xiaocang
I have one more thing wanna to ask with, when I using curl to send a multipart/form-data request, it always return error in response, is there possible to not use "/bin/sh -c", just simply curl ..., because I am always getting error but when I send it directly via terminal is all fine, or is there have alternative way to send multipart/form-data request using other tools/library

thank again with your help

Upadte:
I find out a solution for this problem:
change it from:
{"/bin/sh", "-c", "echo 'hello, world'"}
to:
{"/bin/bash", "-c", "echo 'hello, world'"}

Then the problem will solve.

@meisuj815
Copy link
Author

Hi @xiaocang
Sorry for bothering you, since the new update of OpenResty is coming, this bug is happen again, I need to edit it again to stop the error, is there any news of the bug? the vps is still working you can login to check the bug, thanks again for your help.

@xiaocang
Copy link
Contributor

Hi @meisuj815
Thank you for your trust, we do not recommend exposing the server's public address username and password in issue, for security reasons, we suggest you delete the corresponding information.

And I'll take the time to try to reproduce the problem with your minimize use case:

{"/bin/sh", "-c", "echo 'hello, world'"}

@meisuj815
Copy link
Author

Hi @xiaocang
well I didn't hit the bug when using that code: {"/bin/sh", "-c", "echo 'hello, world'"}

but I did hit the bug in first code: #19 (comment)

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