Welcome! Log In Create A New Profile

Advanced

Re: nginx + my module crashes only when ignore client abort = on

Maxim Dounin
March 17, 2013 07:54PM
Hello!

On Sun, Mar 17, 2013 at 05:47:24AM -0400, gadh wrote:

Below just couple of comments. Outlined problems are enough to
cause arbitrary segmentation faults, and I haven't looked for
more.

[...]

> ngx_memzero(&sr->headers_in, sizeof(sr->headers_in));

Note: this ruins original request headers. It's enough to cause
anything.

[...]

> // do not inherit rb from parent
> sr->request_body = ngx_palloc(r->pool, sizeof(ngx_http_request_body_t));
> NGX_aaa_CHECK_ALLOC_AND_RETURN(sr->request_body)
>
> // note: always alloc bufs even if ptr is lid - since its garbage from
> former request ! (caused seg fault in mod_proxy !)
> sr->request_body->bufs = ngx_alloc_chain_link(r->pool);
> NGX_aaa_CHECK_ALLOC_AND_RETURN(sr->request_body->bufs)
>
> // post body - re-populate , do not inherit from parent
> sr->request_body->bufs->buf = buf;
> sr->request_body->bufs->next = NULL;
> sr->request_body->buf = buf;

Note: you allocate request body structure and only initialize some
of it's members. E.g. sr->request_body->temp_file remains
uninitialized and will likely be dereferenced, resulting in
segmentation fault.

You have to at least change ngx_palloc() to ngx_pcalloc().

[...]

> BTW, is there any "nginx subrequest coding guide" documentation available ?
> its very confusing and lacks much info on the web, i got it working only
> thru alot of trial-and-error.

Subrequests are dead simple in it's supported form: you just call
ngx_http_subrequest() in a body filter, and the result is added to
the output at the appropriate point. Good sample is available in
ngx_http_addition_filter_module.c.

What you try to do with subrequests isn't really supported (the
fact that it works - is actually a side effect of subrequests
processing rewrite in 0.7.25), hence no guides.

--
Maxim Dounin
http://nginx.org/en/donation.html

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

nginx + my module crashes only when ignore client abort = on

gadh March 14, 2013 11:36AM

Re: nginx + my module crashes only when ignore client abort = on

gadh March 14, 2013 11:58AM

Re: nginx + my module crashes only when ignore client abort = on

Maxim Dounin March 14, 2013 12:34PM

Re: nginx + my module crashes only when ignore client abort = on

gadh March 14, 2013 12:46PM

Re: nginx + my module crashes only when ignore client abort = on

Maxim Dounin March 14, 2013 01:06PM

Re: nginx + my module crashes only when ignore client abort = on

gadh March 17, 2013 05:47AM

Re: nginx + my module crashes only when ignore client abort = on

gadh March 17, 2013 03:00PM

Re: nginx + my module crashes only when ignore client abort = on

Maxim Dounin March 17, 2013 07:54PM

Re: nginx + my module crashes only when ignore client abort = on

gadh March 18, 2013 01:40AM

Re: nginx + my module crashes only when ignore client abort = on

Maxim Dounin March 18, 2013 07:18AM

Re: nginx + my module crashes only when ignore client abort = on

gadh March 18, 2013 07:24AM

Re: nginx + my module crashes only when ignore client abort = on

gadh March 18, 2013 09:45AM

Re: nginx + my module crashes only when ignore client abort = on

gadh April 09, 2013 08:59AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 60
Record Number of Users: 8 on December 15, 2016
Record Number of Guests: 386 on August 02, 2016
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready