Test the OOM situation

Peter Leonov gojpeg at gmail.com
Wed May 19 16:01:07 MSD 2010

On 18.05.2010, at 23:26, Maxim Dounin wrote:

> Hello!
> On Tue, May 18, 2010 at 08:25:46PM +0400, Peter Leonov wrote:
>> Hello devels,
>> There is a module that requires a heavy testing in environment with
>> low memory. Especialy it could be good to test how it goes if no
>> more memory is available in the system.
>> So the questions are: is there a way to test such a module without a
>> virtual machines? and are there some tools which might be of help?
> You may tune memory limit for a given process instead of using 
> virtual machine.  Though this won't really help with testing nginx 
> modules as pool allocator will protect most of allocations from 
> seeing errors (while they still can happen with sligtly different 
> config).

You mean that the module will be even left untouched as far
as the main request pool fail to be allocated. Understood.

> Injecting random errors into allocation routines proven to be much 
> more usable.  Just for completeness: attached trivial patch which 
> I used while searching for allocation error handling bugs in nginx 
> itself.

That is near what I was looking for :)

But it gives a very interesting results. For example a crash within the core:

40740 Bus error               (core dumped)

#0  0x0000484b in ngx_destroy_pool (pool=0x3262b0) at src/core/ngx_palloc.c:74
74	    for (p = pool, n = pool->d.next; /* void */; p = n, n = n->d.next) {

#0  0x0000484b in ngx_destroy_pool (pool=0x3262b0) at src/core/ngx_palloc.c:74
#1  0x0002cd16 in ngx_http_close_connection (c=0x879e58) at src/http/ngx_http_request.c:3020
#2  0x0002f56a in ngx_http_set_keepalive [inlined] () at /Users/peter/pro/nginx/src/http/ngx_http_request.c:2559
#3  0x0002f56a in ngx_http_finalize_connection (r=<value temporarily unavailable, due to optimizations>) at src/http/ngx_http_request.c:2121
#4  0x0002ff66 in ngx_http_finalize_request (r=0x807c00, rc=0) at src/http/ngx_http_request.c:2029
#5  0x0003068a in ngx_http_writer (r=0x807c00) at src/http/ngx_http_request.c:2247
#6  0x0002ca70 in ngx_http_run_posted_requests (c=0x879e58) at src/http/ngx_http_request.c:1812
#7  0x0003eb06 in ngx_http_upstream_handler (ev=0x88fe78) at src/http/ngx_http_upstream.c:879
#8  0x00022ebe in ngx_kqueue_process_events (cycle=0x813628, timer=2990, flags=<value temporarily unavailable, due to optimizations>) at src/event/modules/ngx_kqueue_module.c:683
#9  0x00018d85 in ngx_process_events_and_timers (cycle=0x813628) at src/event/ngx_event.c:245
#10 0x0001fb44 in ngx_single_process_cycle (cycle=0x813628) at src/os/unix/ngx_process_cycle.c:306
#11 0x00003c5c in main (argc=7, argv=0xbffff558) at src/core/nginx.c:393

Best regards,

More information about the nginx-devel mailing list