Bug 26265 - motion segfault durring camera reconnect
Summary: motion segfault durring camera reconnect
Status: NEW
Alias: None
Product: Mageia
Classification: Unclassified
Component: RPM Packages (show other bugs)
Version: 7
Hardware: All Linux
Priority: Normal normal
Target Milestone: ---
Assignee: QA Team
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-02-27 09:52 CET by Zamir Ostroukhov
Modified: 2020-05-23 15:41 CEST (History)
2 users (show)

See Also:
Source RPM: motion
CVE:
Status comment:


Attachments

Description Zamir Ostroukhov 2020-02-27 09:52:45 CET
Description of problem:
motion with mysql DB will segfault durring camera reconnect.

Fully description and WA:
https://github.com/Motion-Project/motion/issues/1075

Version-Release number of selected component:
motion 4.2.2
megeia release 7.1

How reproducible:
Every time.


Steps to Reproduce:
1. urpmi motion mariadb
2. configure motion use mysql/mariadb
3. motion -c motion.conf -n
4. leave it trying to connect and restarting
5. after some loops it will crash
Comment 1 Lewis Smith 2020-02-27 15:55:19 CET
Thank you for the report, and all the work you did on the GIT thread.
 https://github.com/Motion-Project/motion/issues/1075#issuecomment-591493422
> Looks like the database handle is not NULL after thread restart
 https://github.com/Motion-Project/motion/issues/1075#issuecomment-591502929
> Meanwhile on Ubuntu the same values do not cause any issues:
 https://github.com/Motion-Project/motion/issues/1075#issuecomment-591512602
> Explicitly NULL'ing the handle at motion_init resolves the crash on Mageia
> However I'm not sure if this is the correct way and we will not leak the
> handle during shutdown. Maybe, this is rather a bug in the maria db libs
> shipped with Mageia
> For now will mark this as bug and let MrDave to make decision
Note "Maybe, this is rather a bug in the maria db libs shipped with Mageia"
Possible.
Await MrDave's decision before assigning this.

CC: (none) => lewyssmith

Comment 2 Zamir Ostroukhov 2020-05-23 11:14:25 CEST
Hi Team,

I found patch:
https://github.com/Motion-Project/motion/commit/c73d60a8754d49fe6996e626fa5486359b4239e8

I tested version 4.3.1 too.
It working fine.
Comment 3 David GEIGER 2020-05-23 13:23:29 CEST
Assigning to QA,


Advisory:
========================

Our current motion release doesn't work properly as it segfault with current Mariadb. So this updates motion to the latest upstream release and fixes this issue.

For reference:
https://github.com/Motion-Project/motion/issues/1075
https://github.com/Motion-Project/motion/issues/1123

========================

Packages in 7/core/updates_testing:
========================
motion-4.3.1-1.mga7.x86_64.rpm
motion-4.3.1-1.mga7.i586.rpm

Source RPM: 
========================
motion-4.3.1-1.mga7.src.rpm

Assignee: bugsquad => qa-bugs
CC: (none) => geiger.david68210

Comment 4 Lewis Smith 2020-05-23 14:12:14 CEST
(In reply to Zamir Ostroukhov from comment #2)
> I found patch:
> https://github.com/Motion-Project/motion/commit/
> c73d60a8754d49fe6996e626fa5486359b4239e8
> I tested version 4.3.1 too.
> It working fine.
Thank you for this detective work, and your important test.
@QA: believe that. It looks fiddly to test - if you have a camera...
---------
@DavidG : Faster than lightning again! I was about assign the bug to you when I found comment 3.

CC: lewyssmith => (none)

Comment 5 Herman Viaene 2020-05-23 15:00:40 CEST
MGA7-64 Plasma on Lenovo B50
No installation issues.
This laptop has mariadb installed, but not running. The references in Comment 3 are vague about how to handle the configuration for using the database for it.
Found https://www.linux.com/training-tutorials/how-operate-linux-spycams-motion/ and had a go at it (it does not mention anything on the database connection).
This laptop has a camera, so I tried:
$ motion -c motion.conf -n
[0:motion] [ALR] [ALL] conf_load: Configfile motion.conf not found - trying defaults.: No such file or directory
[0:motion] [NTC] [ALL] conf_load: Processing thread 0 - config file /etc/motion/motion.conf
[0:motion] [NTC] [ALL] motion_startup: Logging to syslog
[0:motion] [NTC] [ALL] motion_startup: Motion 4.3.1 Started
[0:motion] [NTC] [ALL] motion_startup: Using default log type (ALL)
[0:motion] [NTC] [ALL] motion_startup: Using log type (ALL) log level (NTC)
[0:motion] [NTC] [STR] webu_start_strm: Starting all camera streams on port 8081
[0:motion] [NTC] [STR] webu_strm_ntc: Started camera 0 stream on port 8081
[0:motion] [NTC] [STR] webu_start_ctrl: Starting webcontrol on port 8080
[0:motion] [NTC] [STR] webu_start_ctrl: Started webcontrol on port 8080
and more....
When I moved a little
[1:ml1] [NTC] [ALL] motion_detected: Motion detected - starting event 1
[1:ml1] [NTC] [ALL] mlp_actions: End of event 1
[1:ml1] [NTC] [EVT] event_newfile: File of type 8 saved to: ./0-02-20200523143309.mkv
Ended the session with Ctrl-C
And tried again:
$ motion
[0:motion] [NTC] [ALL] conf_load: Processing thread 0 - config file /etc/motion/motion.conf
[0:motion] [NTC] [ALL] motion_startup: Logging to syslog
[0:motion] [NTC] [ALL] motion_startup: Motion 4.3.1 Started
[0:motion] [NTC] [ALL] motion_startup: Using default log type (ALL)
[0:motion] [NTC] [ALL] motion_startup: Using log type (ALL) log level (NTC)
[0:motion] [NTC] [STR] webu_start_strm: Starting all camera streams on port 8081
[0:motion] [NTC] [STR] webu_strm_ntc: Started camera 0 stream on port 8081
and so on....
detected moving, stopped again.
Started again and then pointed firefox to localhost:8081 and I saw myself.
That all worked OK.
Continuing research how to handel the connection to mysql.

CC: (none) => herman.viaene

Comment 6 Herman Viaene 2020-05-23 15:41:44 CEST
Found https://www.lavrsen.dk/foswiki/bin/view/Motion/UsingDatabases and https://www.lavrsen.dk/foswiki/bin/view/Motion/ConfigOptionSqlQuery and defined the database in phpmyadmin with the parameters as in https://github.com/Motion-Project/motion/issues/1075
and added the lines
database_type mysql
database_dbname motion
database_host localhost
database_port 3306
database_user motion
database_password motionpass
database_busy_timeout 0
sql_query insert into security(camera,filename,frame,file_type,event_time_stamp,text_event) values ('%t','%f','%q','%n','%Y-%m-%d %T','%C')
into /etc/motion/motion.conf
and started motion again.
Motion registered motions from my camera, but in the CLI i kept getting the feedback:
$ motion
[0:motion] [NTC] [ALL] conf_load: Processing thread 0 - config file /etc/motion/motion.conf
but then further
[1:ml1] [WRN] [DBL] do_sql_query: Ignoring empty sql query
and of course the database table remains empty.
I tried to end the sql string with ; or put the whole string between "", but to no avail.
I get the .mkv files in my home directory, that's OK, and there are no crashes.
Giving up,unless someone else sees where I made a mistake.

Note You need to log in before you can comment on or make changes to this bug.