{"action":"opened","issue":{"url":"https://api.github.com/repos/Motion-Project/motion/issues/843","repository_url":"https://api.github.com/repos/Motion-Project/motion","labels_url":"https://api.github.com/repos/Motion-Project/motion/issues/843/labels{/name}","comments_url":"https://api.github.com/repos/Motion-Project/motion/issues/843/comments","events_url":"https://api.github.com/repos/Motion-Project/motion/issues/843/events","html_url":"https://github.com/Motion-Project/motion/issues/843","id":381496081,"node_id":"MDU6SXNzdWUzODE0OTYwODE=","number":843,"title":"net cam rtsp passthrouigh SIGSEGV","user":{"login":"PeterHolik","id":43067822,"node_id":"MDQ6VXNlcjQzMDY3ODIy","avatar_url":"https://avatars1.githubusercontent.com/u/43067822?v=4","gravatar_id":"","url":"https://api.github.com/users/PeterHolik","html_url":"https://github.com/PeterHolik","followers_url":"https://api.github.com/users/PeterHolik/followers","following_url":"https://api.github.com/users/PeterHolik/following{/other_user}","gists_url":"https://api.github.com/users/PeterHolik/gists{/gist_id}","starred_url":"https://api.github.com/users/PeterHolik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PeterHolik/subscriptions","organizations_url":"https://api.github.com/users/PeterHolik/orgs","repos_url":"https://api.github.com/users/PeterHolik/repos","events_url":"https://api.github.com/users/PeterHolik/events{/privacy}","received_events_url":"https://api.github.com/users/PeterHolik/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-11-16T08:33:11Z","updated_at":"2018-11-16T08:33:11Z","closed_at":null,"author_association":"NONE","body":"0. Reviewed guide and contributing documents? (Yes/No): no\r\n1. version [x.y.z, hash, other]: 4.2+git\r\n2. installed as a package or compiled from sources [deb, rpm, git, other]: git\r\n3. standalone or part of third party [motion, MotionEyeOS, other]: motion\r\n4. video stream source [V4L (card or USB), net cam (mjpeg, rtsp, other), mmal]: net cam rtsp\r\n5. hardware [x86, ARM, other]:  x86\r\n6. operating system [16.04, Stretch, etc, FreeBSD, other]: ubuntu\r\n\r\nMy Netcam disconnects every hour and sometimes i got a segmentation fault:\r\n\r\nProgram received signal SIGSEGV, Segmentation fault.\r\n[Switching to Thread 0xac5d5b40 (LWP 15036)]\r\n0x08077ec8 in netcam_rtsp_pktarray_add (rtsp_data=0xae3004c8) at netcam_rtsp.c:182\r\n182<--->        rtsp_data->pktarray[indx_next].idnbr = rtsp_data->idnbr;\r\n(gdb) bt\r\n#0  0x08077ec8 in netcam_rtsp_pktarray_add (rtsp_data=0xae3004c8) at netcam_rtsp.c:182\r\n#1  netcam_rtsp_read_image (rtsp_data=rtsp_data@entry=0xae3004c8) at netcam_rtsp.c:654\r\n#2  0x08078e95 in netcam_rtsp_open_context (rtsp_data=0xae3004c8) at netcam_rtsp.c:1247\r\n#3  netcam_rtsp_connect (rtsp_data=rtsp_data@entry=0xae3004c8) at netcam_rtsp.c:1263\r\n#4  0x08079ec3 in netcam_rtsp_handler_reconnect (rtsp_data=rtsp_data@entry=0xae3004c8) at netcam_rtsp.c:1380\r\n#5  0x0807a1b5 in netcam_rtsp_handler (arg=0xae3004c8) at netcam_rtsp.c:1411\r\n#6  0xb5e2cf72 in start_thread () from /lib/i386-linux-gnu/libpthread.so.0\r\n#7  0xb5d6343e in clone () from /lib/i386-linux-gnu/libc.so.6\r\n\r\n(gdb) print rtsp_data->idnbr\r\n$1 = 95\r\n(gdb) print indx_next\r\n$2 = 0\r\n(gdb) print rtsp_data->pktarray[0]\r\nCannot access memory at address 0x0\r\n(gdb) print rtsp_data->pktarray\r\n$3 = (struct packet_item *) 0x0\r\n(gdb) print rtsp_data->pktarray_index\r\n$4 = -1\r\n\r\nTo see where and why this happens i added some logging:\r\n\r\nmotion: [3:nc3:hof] [INF] [NET] netcam_rtsp_copy_stream: Stream copied for pass-through\r\nmotion: [2:ml2:hof] [INF] [NET] netcam_rtsp_pktarray_resize: Normal resolution: Resized packet (nil) to 0xae300668 size 0 to 30\r\nmotion: [3:nc3:hof] [NTC] [NET] netcam_rtsp_connect: Normal resolution: Camera (hof) connected\r\nmotion: [2:ml2:hof] [INF] [NET] netcam_rtsp_pktarray_resize: Normal resolution: Resized packet 0xae300668 to 0xae301690 size 30 to 32\r\nmotion: [2:ml2:hof] [INF] [NET] netcam_rtsp_pktarray_resize: Normal resolution: Resized packet 0xae301690 to 0xae300668 size 32 to 38\r\nmotion: [2:ml2:hof] [INF] [NET] netcam_rtsp_pktarray_resize: Normal resolution: Resized packet 0xae300668 to 0xae302e78 size 38 to 50\r\nmotion: [2:ml2:hof] [INF] [NET] netcam_rtsp_pktarray_resize: Normal resolution: Resized packet 0xae302e78 to 0xae3caee8 size 50 to 60\r\n\r\nmotion: [3:nc3:hof] [INF] [NET] netcam_rtsp_interrupt: Normal resolution: Camera reading (hof) timed out\r\nmotion: [3:nc3:hof] [INF] [NET] netcam_rtsp_read_image: Normal resolution: av_read_frame: Success ,Interrupt: True\r\nmotion: [3:nc3:hof] [INF] [NET] netcam_rtsp_interrupt: Normal resolution: Camera reading (hof) timed out\r\nmotion: [3:nc3:hof] [INF] [NET] netcam_rtsp_close_context: Normal resolution: rtsp_close_context packet 0xae3caee8 array size 60\r\nmotion: [2:ml2:hof] [INF] [NET] netcam_rtsp_pktarray_resize: Normal resolution: Resized packet (nil) to 0xae300668 size 0 to 30\r\nmotion: [3:nc3:hof] [INF] [NET] netcam_rtsp_null_context: Normal resolution: rtsp_null_context packet 0xae300668 array size 30\r\nmotion: [3:nc3:hof] [ERR] [NET] netcam_rtsp_handler_reconnect: Normal resolution: Reconnecting with camera....\r\n\r\nmotion: [3:nc3:hof] [INF] [NET] netcam_rtsp_interrupt: Normal resolution: Camera (hof) timed out\r\nmotion: [3:nc3:hof] [INF] [NET] netcam_rtsp_null_context: Normal resolution: rtsp_null_context packet (nil) array size 30\r\n\r\nmotion: [3:nc3:hof] [INF] [NET] netcam_rtsp_open_context: Normal resolution: Opened camera(hof)\r\n\r\nmotion: [3:nc3:hof] [INF] [NET] netcam_rtsp_copy_stream: Stream copied for pass-through\r\nmotion: [3:nc3:hof] [INF] [NET] netcam_rtsp_pktarray_add: Normal resolution: add packet (nil) array size 30\r\n\r\n\r\nThe relevant lines are:\r\n\r\nmotion: [3:nc3:hof] [INF] [NET] netcam_rtsp_close_context: Normal resolution: rtsp_close_context packet 0xae3caee8 array size 60\r\nmotion: [2:ml2:hof] [INF] [NET] netcam_rtsp_pktarray_resize: Normal resolution: Resized packet (nil) to 0xae300668 size 0 to 30\r\nmotion: [3:nc3:hof] [INF] [NET] netcam_rtsp_null_context: Normal resolution: rtsp_null_context packet 0xae300668 array size 30\r\n\r\n\r\nrtsp_null_context only sets rtsp_data->pktarray  to NULL but not pktarray_size\r\n\r\n\r\nA quick fix is\r\n\r\n--- netcam_rtsp.c.orig\t2018-11-16 09:32:07.128958031 +0100\r\n+++ netcam_rtsp.c.fix\t2018-11-16 09:32:17.299696109 +0100\r\n@@ -72,7 +72,7 @@\r\n     rtsp_data->frame           = NULL;\r\n     rtsp_data->codec_context   = NULL;\r\n     rtsp_data->format_context  = NULL;\r\n-    rtsp_data->pktarray        = NULL;\r\n+    if (rtsp_data->pktarray != NULL) netcam_rtsp_pktarray_free(rtsp_data);\r\n     rtsp_data->transfer_format = NULL;\r\n \r\n }\r\n\r\nBut maybe there are other solutions also.\r\n\r\ncu Peter"}}
{"actor":{"display_login":"PeterHolik"}}