Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
server/motion_processor.cpp: fix crash by freeing cv::Mat the right way
This happens when schedule changes from 'M' to 'C'. This is how it looks in the logs: I(1/software): motion_blend_radio is set to 15:1 I(1/software): motion_debug is set to 0 I(1/software): Motion detected E(): Got connection, but failed to accept I(1/software): Switching to new recording schedule 'continuous' BUG: Segment violation at 0x0000000000000366 Call trace: [0x000055db84eb8d5b] @ /usr/sbin/bc-server [0x00007f9949977320] @ /lib/x86_64-linux-gnu/libc.so.6 [0x00007f994a5c77e9] _ZN2cv3Mat7releaseEv+0x00000000 @ /lib/x86_64-linux-gnu/libopencv_core.so.406 [0x000055db84eb8ee4] @ /usr/sbin/bc-server [0x000055db84ebc2d6] @ /usr/sbin/bc-server [0x000055db84ebc8dd] @ /usr/sbin/bc-server [0x00007f99499cea94] @ /lib/x86_64-linux-gnu/libc.so.6 [0x00007f9949a5ba34] __clone+0x00000000 @ /lib/x86_64-linux-gnu/libc.so.6 This is how it looks in the debugger: #0 0x00007f994a5c77e9 in cv::Mat::release() () from /lib/x86_64-linux-gnu/libopencv_core.so.406 #1 0x000055db84eb8ee4 in motion_processor::~motion_processor (this=0x7f993000bbb0, __in_chrg=<optimized out>) at motion_processor.cpp:59 #2 0x000055db84ebc2d6 in motion_processor::~motion_processor (this=0x7f993000bbb0, __in_chrg=<optimized out>) at motion_processor.cpp:42 #3 motion_processor::run (this=0x7f993000bbb0) at motion_processor.cpp:201 #4 0x000055db84ebc8dd in bc_mproc_thread (data=<optimized out>) at motion_processor.cpp:861 #5 0x00007f99499cea94 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:447 #6 0x00007f9949a5ba34 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:100 According to the documentation, cv::Mat automatically derefs and frees data as needed on being destroyed (e.g. delete) https://docs.opencv.org/4.x/d3/d63/classcv_1_1Mat.html#ae48d4913285518e2c21a3457017e716e The bug was introduced by a memory leak fix. Fixes: 089e6de ("motion_processor: release cv::Mat objects")
- Loading branch information