missing module context

Anatoli Marinov toli at webforge.bg
Tue Jul 10 08:31:45 UTC 2012


Hello Colleagues,
I am working on a project, that uses nginx as http proxy and I have 
written many nginx modules. For several months till now I am looking for 
a bug in one of my modules but I cannot find it. It appears very rare 
but even so it should be fixed.

I added many log messages to debug the issue. I found that some time the 
module context is null even it has been set before.  I am using context 
functions as usual:
1. In rewrite phase :
ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_my_ctx_t));
ngx_http_set_ctx(r, ctx, ngx_http_my_module);

2. In log phase I am trying to get back my context :
ctx = ngx_http_get_module_ctx(r, ngx_http_my_module);
In this place ctx is NULL.

What is your opinion? Am am using this sequence on many places and it 
works as I expected but in this modules sometimes it fails.
I think there could be a memory corruption issue. There could be a code 
that may write on request's context array and overwrite the context 
pointer. Is there a way to check this? Nginx uses its own memory pool 
system and tools like valgrind is not longer usable.

Please advise me how to find this issue...

All ideas are welcome!
Best Regards

Anatoli Marinov






More information about the nginx-devel mailing list