invalid value (nil) at index 285 in table for 'concat'
meisuj815 opened this issue · 7 comments
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)
...
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 $?
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'
...
@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
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.
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.
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'"}
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)