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

setting a variable from $echo_it results to crashing #2

Open
ovh opened this issue May 2, 2012 · 2 comments
Open

setting a variable from $echo_it results to crashing #2

ovh opened this issue May 2, 2012 · 2 comments

Comments

@ovh
Copy link

ovh commented May 2, 2012

set $var $echo_it;

results to nginx crashing:
2012/05/02 12:30:13 [notice] 22517#0: signal 17 (SIGCHLD) received
2012/05/02 12:30:13 [alert] 22517#0: worker process 22518 exited on signal 11
2012/05/02 12:30:13 [notice] 22517#0: start worker process 22535
2012/05/02 12:30:13 [notice] 22517#0: signal 29 (SIGIO) received

conf:
location = /getFile {
echo_foreach_split ',' $filelist
set $file $echo_it;
echo_subrequest GET '/getFile' -q 'sha256=$file' ;
echo_end;
}

agentzh added a commit to openresty/echo-nginx-module that referenced this issue May 2, 2012
…ted in memory invalid reads and hence segfaults; now it is evaluates to the special "not found" value. thanks baqs for reporting this in agentzh/old-openresty#2.
@agentzh
Copy link
Owner

agentzh commented May 2, 2012

On Wed, May 2, 2012 at 6:31 PM, baqs
[email protected]
wrote:

set $var $echo_it;

results to nginx crashing:
2012/05/02 12:30:13 [notice] 22517#0: signal 17 (SIGCHLD) received
2012/05/02 12:30:13 [alert] 22517#0: worker process 22518 exited on signal 11
2012/05/02 12:30:13 [notice] 22517#0: start worker process 22535
2012/05/02 12:30:13 [notice] 22517#0: signal 29 (SIGIO) received

You're using the $echo_it variable at rewrite phase (because
ngx_rewrite's set directive runs at the rewrite phase) and it indeed
leads to a segfault. I've committed a patch to ngx_echo's git
repository to make it evaluate to empty (or "not found", to be more
accurate):

openresty/echo-nginx-module@08d36f31

conf:
location = /getFile {
echo_foreach_split ',' $filelist
set $file $echo_it;
echo_subrequest GET '/getFile' -q 'sha256=$file' ;
echo_end;
}

Your directives in location = /getFile will not run in the order as
they are written, because the "set" directive always runs in the
rewrite processing phase of nginx while those ngx_echo directives
always run in a later phase, i.e., the content phase. So your
directives will actually run in the order like below:

set $file $echo_it;
echo_foreach_split ',' $filelist;
echo_subrequest GET '/getFile' -q 'sha256=$file';
echo_end;

This is surely not what you want (but still it should not crash in any
event). For more details regarding nginx processing phases, please
read our nginx tutorials here:

http://agentzh.org/misc/nginx/agentzh-nginx-tutorials-enuk.html

Thanks!
-agentzh

@ovh
Copy link
Author

ovh commented May 2, 2012

On 02/mai - 06:09, agentzh (章亦春) wrote:

On Wed, May 2, 2012 at 6:31 PM, baqs
[email protected]
wrote:

set $var $echo_it;

results to nginx crashing:
2012/05/02 12:30:13 [notice] 22517#0: signal 17 (SIGCHLD) received
2012/05/02 12:30:13 [alert] 22517#0: worker process 22518 exited on signal 11
2012/05/02 12:30:13 [notice] 22517#0: start worker process 22535
2012/05/02 12:30:13 [notice] 22517#0: signal 29 (SIGIO) received

You're using the $echo_it variable at rewrite phase (because
ngx_rewrite's set directive runs at the rewrite phase) and it indeed
leads to a segfault. I've committed a patch to ngx_echo's git
repository to make it evaluate to empty (or "not found", to be more
accurate):

openresty/echo-nginx-module@08d36f31
ok thx

conf:
location = /getFile {
echo_foreach_split ',' $filelist
set $file $echo_it;
echo_subrequest GET '/getFile' -q 'sha256=$file' ;
echo_end;
}

Your directives in location = /getFile will not run in the order as
they are written, because the "set" directive always runs in the
rewrite processing phase of nginx while those ngx_echo directives
always run in a later phase, i.e., the content phase. So your
directives will actually run in the order like below:

set $file $echo_it;
echo_foreach_split ',' $filelist;
echo_subrequest GET '/getFile' -q 'sha256=$file';
echo_end;

This is surely not what you want (but still it should not crash in any
event). For more details regarding nginx processing phases, please
read our nginx tutorials here:

thanks a lot for your explanations, I'll try to work-around that.

http://agentzh.org/misc/nginx/agentzh-nginx-tutorials-enuk.html

Thanks!
-agentzh


Reply to this email directly or view it on GitHub:
#2 (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

1 participant