Page 1 of 1

Segmentation fault with zmc and rtsp (ffmpeg)

Posted: Mon Sep 24, 2018 9:21 pm
by jggg
Hi,

I have a problem with new 1.32 (upgrading from 1.30) in ubuntu 14.04 with a rtsp camera with ffmpeg configuration.

The zmc process is in a died-restart loop every few seconds, this is my debug log:

https://www.dropbox.com/s/n2uot73nyo2jo ... 5.txt?dl=0

I have tested with last 1.32 version in repo for ubuntu trusty and one .deb make by me with last master version using do_debian_package.sh script.

Thanks for your support! Regards

Re: Segmentation fault with zmc and rtsp (ffmpeg)

Posted: Tue Sep 25, 2018 2:16 pm
by jggg
I would like to add that i don't have any problem with other ffmpeg cameras (foscam) but the problem is with an unknown camera ... could i do an ffmpeg proxy or something similar for re-encoding video or something like this?

EDIT:

- With 1.30 and same setup (for ffmpeg) this camera worked without problem
- With VLC and ffmpeg, i can connect to the camera (rtsp url) and stream video/audio without problems.

Thanks!

Re: Segmentation fault with zmc and rtsp (ffmpeg)

Posted: Wed Sep 26, 2018 11:57 am
by jggg
Another test with ffmpeg and this rtsp stream ...

With ffplay -rtsp_transport udp rtsp://192.168..../onvif1 (this camera only stream un rtsp UDP) the streams works well (Doesn't restart or pause) but i get sometimes this message in terminal from ffplay: "rtsp "Too short data for FU-A H.2264 RTP packet0" so ... i think that tere is a problem with some packets that make zoneminder crash ....

Re: Segmentation fault with zmc and rtsp (ffmpeg)

Posted: Wed Sep 26, 2018 3:59 pm
by jggg
I have some progress with problem resolution ....

1) I have found "one bug" in zm_ffmpeg_camera.cpp with rtsp UDP, for transport configuration isn't the option for rtpUni:

Code: Select all

  // Set transport method as specified by method field, rtpUni is default
  const std::string method = Method();
  if ( method == "rtpMulti" ) {
    ret = av_dict_set(&opts, "rtsp_transport", "udp_multicast", 0);
  } else if ( method == "rtpRtsp" ) {
    ret = av_dict_set(&opts, "rtsp_transport", "tcp", 0);
  } else if ( method == "rtpRtspHttp" ) {
    ret = av_dict_set(&opts, "rtsp_transport", "http", 0);
  } else if ( method == "rtpUni" ) {
    ret = av_dict_set(&opts, "rtsp_transport", "udp", 0);
  } else {
    Warning("Unknown method (%s)", method.c_str() );
  }
2) The problem because the cam is "connection" every few seconds is because zmwatch is restarting the camera:

09/26/2018 17:55:24.061981 zmwatch[64958].ERR [ZoneMinder::Memory::Mapped:95] [Memory map file '/dev/shm/zm.mmap.21' should have been 1168 but was instead 0]
09/26/2018 17:55:24.062058 zmwatch[64958].INF [main:136] [Restarting capture daemon for Monitor-21, shared data not valid]
09/26/2018 17:56:04.426094 zmwatch[64958].ERR [ZoneMinder::Memory::Mapped:95] [Memory map file '/dev/shm/zm.mmap.21' should have been 1168 but was instead 0]
09/26/2018 17:56:04.426167 zmwatch[64958].INF [main:136] [Restarting capture daemon for Monitor-21, shared data not valid]

I need to investigate what is the problem with memory map file ... because i have other ffmpeg rtsp (but TCP) cameras working without problem ...

Re: Segmentation fault with zmc and rtsp (ffmpeg)

Posted: Wed Sep 26, 2018 5:39 pm
by jggg
More tests ... my problem is only with Video Writer enable, in passtrhough or encode, the result is the same ... zmc restarted every 30 sec aprox.

Re: Segmentation fault with zmc and rtsp (ffmpeg)

Posted: Wed Sep 26, 2018 8:25 pm
by iconnor
I was able to reproduce this crash and so was able to fix it. Also fixed a memleak. Please test current master.

Re: Segmentation fault with zmc and rtsp (ffmpeg)

Posted: Wed Sep 26, 2018 11:41 pm
by jggg
Thanks Isaac for your support.

I have tested with last version in master branch and the results:

1) With Storage in H264 Camera Passthrough:
Is recording events with 2 minutes of duration, but video (mp4 file) is only 20 seconds.

The zmc log is full of messages:
09/27/18 01:33:59.950247 zmc_m18[36874].WAR-zm_videostore.cpp/857 [/mnt/ssd/build_zoneminder2/zoneminder_1.32.0~20180927003559.orig/src/zm_videostore.cpp:857: Writing frame [av_interleaved_write_frame()] failed: Invalid argument(-22) ]
09/27/18 01:34:00.030211 zmc_m18[36874].WAR-zm_videostore.cpp/857 [/mnt/ssd/build_zoneminder2/zoneminder_1.32.0~20180927003559.orig/src/zm_videostore.cpp:857: Writing frame [av_interleaved_write_frame()] failed: Invalid argument(-22) ]

The zmc process doesn't restart, so the problem with this configuration now is only in recording.

2) With encode:

zmc process restart every few seconds by zmwatch:

09/27/2018 01:40:10.055905 zmwatch[15708].ERR [ZoneMinder::Memory:257] [Shared data size conflict in shared_data for monitor Calle, expected 608, got 875967096]
09/27/2018 01:40:10.055967 zmwatch[15708].INF [main:136] [Restarting capture daemon for Calle, shared data not valid]
09/27/2018 01:40:50.464484 zmwatch[15708].ERR [main:164] [Last analyse time for 18 Calle was zero.]
09/27/2018 01:40:50.464550 zmwatch[15708].INF [main:184] [Restarting analysis daemon for 18 Calle]

And this is the zmc log:

09/27/18 01:39:31.084128 zmc_m18[44725].INF-zmc.cpp/223 [Starting Capture version 1.32.0]
09/27/18 01:39:31.084295 zmc_m18[44725].INF-zm_ffmpeg_camera.cpp/163 [Priming capture from rtsp://192.168.1.40:554/onvif1]
09/27/18 01:39:31.521889 zmc_m18[44725].INF-zm_ffmpeg_camera.cpp/378 [Stream open rtsp://192.168.1.40:554/onvif1, parsing streams...]
09/27/18 01:39:36.358486 zmc_m18[44725].INF-zm_monitor.cpp/2473 [Calle: images:1 - Capturing at 100.00 fps, capturing bandwidth 2543bytes/sec]
09/27/18 01:39:37.939564 zmc_m18[44725].ERR-zm_ffmpeg_camera.cpp/240 [Unable to send packet at frame 45: Resource temporarily unavailable, continuing]
09/27/18 01:40:10.323603 zmc_m18[44725].INF-zm_signal.cpp/40 [Got signal 15 (Terminated), exiting]

Re: Segmentation fault with zmc and rtsp (ffmpeg)

Posted: Wed Sep 26, 2018 11:44 pm
by jggg
And I have found another issue (with all cameras, not only with rtsp UDP), in view window:

/zm/index.php?view=watch&mid=XX

Refresh all pages instead of only the image.

Re: Segmentation fault with zmc and rtsp (ffmpeg)

Posted: Thu Sep 27, 2018 3:47 pm
by jggg
More Logs:

Every second (aprox) this line un syslo:

Sep 27 17:46:17 blanco2 kernel: [264942.474392] traps: nph-zms[52985] general protection ip:7f3ca1a567ae sp:b987767e73ba7d63 error:0 in libc-2.19.so[7f3ca1948000+1be000]
Sep 27 17:46:17 blanco2 kernel: [264943.032976] traps: nph-zms[53024] general protection ip:7fed74ac97ae sp:d9c07532cb8a3ab2 error:0 in libc-2.19.so[7fed749bb000+1be000]
Sep 27 17:46:19 blanco2 kernel: [264944.408538] traps: nph-zms[53104] general protection ip:7f04039bd7ae sp:1ca936d97db7723 error:0 in libc-2.19.so[7f04038af000+1be000]
Sep 27 17:46:20 blanco2 kernel: [264945.462648] traps: nph-zms[53175] general protection ip:7fa22b7617ae sp:1c027280bc56e83f error:0 in libc-2.19.so[7fa22b653000+1be000]
Sep 27 17:46:20 blanco2 kernel: [264946.259571] traps: nph-zms[53251] general protection ip:7fb5b1f6a7ae sp:125f2236658132d error:0 in libc-2.19.so[7fb5b1e5c000+1be000]
Sep 27 17:46:22 blanco2 kernel: [264947.469295] traps: nph-zms[53327] general protection ip:7f0d3e3bd7ae sp:3558295b84aba3e3 error:0 in libc-2.19.so[7f0d3e2af000+1be000]
Sep 27 17:46:22 blanco2 kernel: [264948.300454] traps: nph-zms[53378] general protection ip:7f320a3ef7ae sp:2de763e747da50b5 error:0 in libc-2.19.so[7f320a2e1000+1be000]


In /var/log/zm/web_js.log, constant:

09/27/18 17:47:44.044646 web_js[56683].ERR [getStreamCmdResponse stream error: socket_sendto( /var/run/zm/zms-416712s.sock ) failed: Connection refused - checkStreamForErrors()] at ?view=watch line

EDIT: Solved, the issue was out of memory for /var/tmp