sergey-dryabzhinsky / nginx-rtmp-module

NGINX-based Media Streaming Server
http://nginx-rtmp.blogspot.com
BSD 2-Clause "Simplified" License
1.02k stars 216 forks source link

Infinite loop on ngx_rtmp_relay_create #203

Open sanecz opened 7 years ago

sanecz commented 7 years ago

Hi,

We had the bug #145 and applied the patch found in #148. It seems a little bit better but now we are facing an other infinite loop, keeping the cpu at 100% usage

Thread 1 (Thread 0x7f07e74f8740 (LWP 29600)):
#0  0x000000000041bb00 in memcmp@plt ()
No symbol table info available.
#1  0x0000000000525660 in ngx_rtmp_relay_create (s=s@entry=0x7f07de4d7470, name=name@entry=0x7ffcba8d24d0, target=target@entry=0x7ffcba8d24e0, create_publish_ctx=create_publish_ctx@entry=0x524f60 <ngx_rtmp_relay_create_local_ctx>, create_play_ctx=create_play_ctx@entry=0x525570 <ngx_rtmp_relay_create_remote_ctx>) at /tmp/buildd/nginx-1.8.1/debian/modules/nginx-rtmp-module/ngx_rtmp_relay_module.c:597
        racf = <optimized out>
        publish_ctx = <optimized out>
        play_ctx = 0x7f07dfea7ae0
        cctx = 0x7f07df9bc9b8
        hash = <optimized out>
#2  0x0000000000526ed0 in ngx_rtmp_relay_push (s=s@entry=0x7f07de4d7470, name=name@entry=0x7ffcba8d24d0, target=target@entry=0x7ffcba8d24e0) at /tmp/buildd/nginx-1.8.1/debian/modules/nginx-rtmp-module/ngx_rtmp_relay_module.c:648
No locals.
#3  0x000000000052cf1c in ngx_rtmp_notify_publish_handle (s=0x7f07de4d7470, arg=0x7f07dfea6a70, in=<optimized out>) at /tmp/buildd/nginx-1.8.1/debian/modules/nginx-rtmp-module/ngx_rtmp_notify_module.c:1378
        v = 0x7f07dfea6a70
        rc = 75
        send = <optimized out>
        local_name = {len = 7, data = 0x7f07dfea6a70 "x52pad9"}
        target = {url = {url = {len = 68, data = 0x7ffcba8d2667 "ip/publish/x52pad9?ingest_id=1111111&auth=xxxxxxxxxxxx"}, host = {len = 12, data = 0x7ffcba8d2667 "ip/publish/x52pad9?ingest_id=1111111&auth=xxxxxxxxxxxx"}, port_text = {len = 0, data = 0x0}, uri = {len = 56, data = 0x7ffcba8d2673 "/publish/x52pad9?ingest_id=1111111&auth=xxxxxxxxxxxx"}, port = 1935, default_port = 1935, family = 2, listen = 0, uri_part = 1, no_resolve = 1, one_addr = 0, no_port = 1, wildcard = 0, socklen = 16, sockaddr = "\002\000\a\217\n\276$(", '\000' <repeats 101 times>, addrs = 0x7f07de4d8018, naddrs = 1, err = 0x0}, app = {len = 0, data = 0x0}, name = {len = 0, data = 0x0}, tc_url = {len = 0, data = 0x0}, page_url = {len = 0, data = 0x0}, swf_url = {len = 0, data = 0x0}, flash_ver = {len = 0, data = 0x0}, play_path = {len = 0, data = 0x0}, live = 0, start = 0, stop = 0, tag = 0x0, data = 0x0, counter = 1}
        u = 0x7ffcba8d24e0
        nacf = <optimized out>
        name = "rtmp://ip/publish/x52pad9?ingest_id=1111111&auth=xxxxxxxxxxxx\000\000\000\000\000\360\343\216\336\a\177\000\000\373\000\000\000\000\000\000\000@\345\216\336\a\177\000\000\332\000\000\000\000\000\000\000\240\346\216\336\a\177\000\000\377\000\000\000\000\000\000\000\000\350\216\336\a\177\000\000\366\000\000\000\000\000\000\000`\351\216\336\a\177\000\000l\000\000\000\000\000\000\000\000\222\216\336\a\177\000\000\377\000\000\000\000\000\000\000P\223\216\336\a\177\000\000\377\000\000\000\000\000\000\000\240\224\216\336\a\177\000\000"...
        location = {len = 8, data = 0x55d1bb "location"}
#4  0x0000000000523677 in ngx_rtmp_netcall_close (cc=0x7f07e09ef058) at /tmp/buildd/nginx-1.8.1/debian/modules/nginx-rtmp-module/ngx_rtmp_netcall_module.c:325
        cs = 0x7f07dfea5b28
        css = <optimized out>
        pool = <optimized out>
        s = 0x7f07de4d7470
        ctx = 0x7f07de4d7f60
        b = <optimized out>
#5  0x00000000004408c9 in ngx_epoll_process_events (cycle=0x7f07e74184b0, timer=<optimized out>, flags=<optimized out>) at src/event/modules/ngx_epoll_module.c:822
        events = <optimized out>
        revents = 8193
        instance = <optimized out>
        i = 0
        level = <optimized out>
        err = <optimized out>
        rev = 0x7f07e0807588
        wev = <optimized out>
        queue = <optimized out>
        c = 0x7f07e09ef058
#6  0x0000000000437627 in ngx_process_events_and_timers (cycle=cycle@entry=0x7f07e74184b0) at src/event/ngx_event.c:248
        flags = <optimized out>
        timer = <optimized out>
        delta = 1480578940034
#7  0x000000000043e28f in ngx_worker_process_cycle (cycle=cycle@entry=0x7f07e74184b0, data=data@entry=0x0) at src/os/unix/ngx_process_cycle.c:767
        worker = 0
        i = <optimized out>
        c = <optimized out>
#8  0x000000000043cc70 in ngx_spawn_process (cycle=cycle@entry=0x7f07e74184b0, proc=proc@entry=0x43e1d0 <ngx_worker_process_cycle>, data=data@entry=0x0, name=name@entry=0x54b87e "worker process", respawn=respawn@entry=-3) at src/os/unix/ngx_process.c:198
        on = 1
        pid = 0
        s = 0
#9  0x000000000043e4e4 in ngx_start_worker_processes (cycle=cycle@entry=0x7f07e74184b0, n=1, type=type@entry=-3) at src/os/unix/ngx_process_cycle.c:357
        i = 0
        ch = {command = 1, pid = 0, slot = 0, fd = 0}
#10 0x000000000043f21f in ngx_master_process_cycle (cycle=cycle@entry=0x7f07e74184b0) at src/os/unix/ngx_process_cycle.c:129
        title = 0x7f07e747a8cc "master process /usr/sbin/nginx -g daemon on; master_process on;"
        p = <optimized out>
        size = <optimized out>
        i = <optimized out>
        n = <optimized out>
        sigio = <optimized out>
        set = {__val = {0 <repeats 16 times>}}
        itv = {it_interval = {tv_sec = 139671921334820, tv_usec = 0}, it_value = {tv_sec = 0, tv_usec = 0}}
        live = <optimized out>
        delay = <optimized out>
        ls = <optimized out>
        ccf = 0x7f07e7419700
#11 0x000000000041cadf in main (argc=<optimized out>, argv=<optimized out>) at src/core/nginx.c:419
        i = <optimized out>
        log = 0x7c5340
        cycle = 0x7f07e74184b0
        init_cycle = {conf_ctx = 0x0, pool = 0x7f07e7417ea0, log = 0x7c5340, new_log = {log_level = 0, file = 0x0, connection = 0, disk_full_time = 0, handler = 0x0, data = 0x0, writer = 0x0, wdata = 0x0, action = 0x0, next = 0x0}, log_use_stderr = 0, files = 0x0, free_connections = 0x0, free_connection_n = 0, reusable_connections_queue = {prev = 0x0, next = 0x0}, listening = {elts = 0x0, nelts = 0, size = 0, nalloc = 0, pool = 0x0}, paths = {elts = 0x0, nelts = 0, size = 0, nalloc = 0, pool = 0x0}, open_files = {last = 0x0, part = {elts = 0x0, nelts = 0, next = 0x0}, size = 0, nalloc = 0, pool = 0x0}, shared_memory = {last = 0x0, part = {elts = 0x0, nelts = 0, next = 0x0}, size = 0, nalloc = 0, pool = 0x0}, connection_n = 0, files_n = 0, connections = 0x0, read_events = 0x0, write_events = 0x0, old_cycle = 0x0, conf_file = {len = 21, data = 0x54781a "/etc/nginx/nginx.conf"}, conf_param = {len = 29, data = 0x7ffcba8d3f53 "ss"}, conf_prefix = {len = 11, data = 0x54781a "/etc/nginx/nginx.conf"}, prefix = {len = 11, data = 0x54780e "/etc/nginx/"}, lock_file = {len = 0, data = 0x0}, hostname = {len = 0, data = 0x0}}
        ccf = <optimized out>

It seems to be in https://github.com/sergey-dryabzhinsky/nginx-rtmp-module/blob/dev/ngx_rtmp_relay_module.c#L595, name->data does not exists in any element of cctx and as a result, no element is found. The list also seems to be cyclc so the end condition *(cctx) is never null

Thanks.

notmark commented 7 years ago

+1 constantly facing this issue under load

Update: This no longer appears to happen to me after doing a fresh pull/build.