Mailing List Archive

Re: [mythtv-users] segfault in libmysqlclient.so.21
On 5/13/20 1:16 PM, Paul Harrison wrote:
> On 13/05/2020 17:34, Peter Bennett wrote:
>
>>
>> On 5/13/20 7:48 AM, Paul Harrison wrote:
>>> For reference someone has reported the bug to Ubuntu.
>>>
>>> https://bugs.launchpad.net/ubuntu/+source/mysql-8.0/+bug/1877504
>>>
>>>
>>> Paul H.
>>
>> Hi Paul
>>
>> The bug was showing as affecting only one person (the reporter Kim
>> Tyler)
>>
>> Please login to ubuntu and click where it says "this bug affects x
>> people. Does it affect you?" .
>>
>> Peter
>>
>>
>
> Hi Peter,
>
>
> Done that and the Status changed to 'Confirmed' because the bug
> affects multiple users.
>
> I also added a simple Qt test app that can be used to easily reproduce
> the bug taking  MythTV out of the equation.
>
> I wonder if they will say it's nothing to do with MySQL since it
> appears to only affect users using MariaDB for the server side of things.
>
> I tried to remove libmysqlclient21 so I could try libmariadb3 but that
> wanted to remove a lot more than just libmysqlclient21 so looks like
> that's not going to work.
>
>
> Paul H.
>
> _______________________________________________
>
Looking at the code, it seems we do not ever delete the mythdb instance.
There is a method MythDB::destroyMythDB() that is never called. I found
that by adding a call to this to the end of each program, at the end of
main() before the return, the segfault goes away.

Is this an oversight? Perhaps we do not clean up the database connection
correctly?

There may be a better place to put the call to MythDB::destroyMythDB().
Otherwise I can add it to each program's main() function to prevent this
seg fault.

Any opinions on this? Should I make this change?

Peter



_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: [mythtv-users] segfault in libmysqlclient.so.21 [ In reply to ]
On 5/13/20 2:42 PM, Peter Bennett wrote:
>
> On 5/13/20 1:16 PM, Paul Harrison wrote:
>> On 13/05/2020 17:34, Peter Bennett wrote:
>>
>>>
>>> On 5/13/20 7:48 AM, Paul Harrison wrote:
>>>> For reference someone has reported the bug to Ubuntu.
>>>>
>>>> https://bugs.launchpad.net/ubuntu/+source/mysql-8.0/+bug/1877504
>>>>
>>>>
>>>> Paul H.
>>>
>>> Hi Paul
>>>
>>> The bug was showing as affecting only one person (the reporter Kim
>>> Tyler)
>>>
>>> Please login to ubuntu and click where it says "this bug affects x
>>> people. Does it affect you?" .
>>>
>>> Peter
>>>
>>>
>>
>> Hi Peter,
>>
>>
>> Done that and the Status changed to 'Confirmed' because the bug
>> affects multiple users.
>>
>> I also added a simple Qt test app that can be used to easily
>> reproduce the bug taking  MythTV out of the equation.
>>
>> I wonder if they will say it's nothing to do with MySQL since it
>> appears to only affect users using MariaDB for the server side of
>> things.
>>
>> I tried to remove libmysqlclient21 so I could try libmariadb3 but
>> that wanted to remove a lot more than just libmysqlclient21 so looks
>> like that's not going to work.
>>
>>
>> Paul H.
>>
>> _______________________________________________
>>
> Looking at the code, it seems we do not ever delete the mythdb
> instance. There is a method MythDB::destroyMythDB() that is never
> called. I found that by adding a call to this to the end of each
> program, at the end of main() before the return, the segfault goes away.
>
> Is this an oversight? Perhaps we do not clean up the database
> connection correctly?
>
> There may be a better place to put the call to
> MythDB::destroyMythDB(). Otherwise I can add it to each program's
> main() function to prevent this seg fault.
>
> Any opinions on this? Should I make this change?
>
> Peter
>
This does not work for mythfilldatabase. It looks like some more
investigation is needed.

Peter

_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: [mythtv-users] segfault in libmysqlclient.so.21 [ In reply to ]
> On 14 May 2020, at 4:42 am, Peter Bennett <pb.mythtv@gmail.com> wrote:

...
> There may be a better place to put the call to MythDB::destroyMythDB().



Haven’t looked al latest source code (in a LONG time :-), but

MythCoreContextPrivate::~MythCoreContextPrivate()

used to have:

GetMythDB()->GetDBManager()->CloseDatabases();

if (m_database) {
DestroyMythDB();
m_database = NULL;
}



I suspect there is now a race condition where the context is not being destructed in time?


--
Nigel Pearson, 02 9792 6998, 0408 66 44 35
nigel.pearson.au@gmail.com
Re: [mythtv-users] segfault in libmysqlclient.so.21 [ In reply to ]
On 5/13/20 5:56 PM, Nigel Pearson wrote:
>
>> On 14 May 2020, at 4:42 am, Peter Bennett <pb.mythtv@gmail.com
>> <mailto:pb.mythtv@gmail.com>> wrote:
>
> ...
>> There may be a better place to put the call to MythDB::destroyMythDB().
>
>
>
> Haven’t looked al latest source code (in a LONG time :-), but
>
> MythCoreContextPrivate::~MythCoreContextPrivate()
>
> used to have:
>
>   GetMythDB()->GetDBManager()->CloseDatabases();
>
>     if (m_database) {
>         DestroyMythDB();
>         m_database = NULL;
>     }
>
>
>
> I suspect there is now a race condition where the context is not being
> destructed in time?
>
>
> --
> Nigel Pearson, 02 9792 6998, 0408 66 44 35
> nigel.pearson.au@gmail.com <mailto:nigel.pearson.au@gmail.com>
>

That code is still there. I don't  know how I missed it.

It looks good, so I am not sure what is going on.  Need to trace it ...

Peter
Re: [mythtv-users] segfault in libmysqlclient.so.21 [ In reply to ]
On 14/05/2020 00:26, Peter Bennett wrote:

>
> On 5/13/20 5:56 PM, Nigel Pearson wrote:
>>
>>> On 14 May 2020, at 4:42 am, Peter Bennett <pb.mythtv@gmail.com
>>> <mailto:pb.mythtv@gmail.com>> wrote:
>>
>> ...
>>> There may be a better place to put the call to MythDB::destroyMythDB().
>>
>>
>>
>> Haven’t looked al latest source code (in a LONG time :-), but
>>
>> MythCoreContextPrivate::~MythCoreContextPrivate()
>>
>> used to have:
>>
>>   GetMythDB()->GetDBManager()->CloseDatabases();
>>
>>     if (m_database) {
>>         DestroyMythDB();
>>         m_database = NULL;
>>     }
>>
>>
>>
>> I suspect there is now a race condition where the context is not
>> being destructed in time?
>>
>>
>> --
>> Nigel Pearson, 02 9792 6998, 0408 66 44 35
>> nigel.pearson.au@gmail.com <mailto:nigel.pearson.au@gmail.com>
>>
>
> That code is still there. I don't  know how I missed it.
>
> It looks good, so I am not sure what is going on.  Need to trace it ...
>
> Peter
>
>

I don't believe this bug is specific to MythTV but more a regression in
libmysqlclient you can easily reproduce it using this simple Qt test app.


#include <QApplication>
#include <QSqlDatabase>
#include <QString>
#include <QDebug>

void cause_segfault()
{
  {
    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    db.setDatabaseName("mythconverg");
    db.setUserName("mythtv");
    db.setHostName("192.168.1.32");
    db.setPassword("xxxxxxxx");
    db.open();
    db.close();
  }
  auto name = QSqlDatabase::database().connectionName();
  qDebug() << "About to remove database";
  QSqlDatabase::removeDatabase(name);
  qDebug() << "Removed database";
}

int main(int argc, char *argv[])
{
  QApplication a(argc, argv);
  cause_segfault();
  return -1;
}

Paul H.
Re: [mythtv-users] segfault in libmysqlclient.so.21 [ In reply to ]
On 5/13/20 7:34 PM, Paul Harrison wrote:
>
> On 14/05/2020 00:26, Peter Bennett wrote:
>
>>
>> On 5/13/20 5:56 PM, Nigel Pearson wrote:
>>>
>>>> On 14 May 2020, at 4:42 am, Peter Bennett <pb.mythtv@gmail.com
>>>> <mailto:pb.mythtv@gmail.com>> wrote:
>>>
>>> ...
>>>> There may be a better place to put the call to MythDB::destroyMythDB().
>>>
>>>
>>>
>>> Haven’t looked al latest source code (in a LONG time :-), but
>>>
>>> MythCoreContextPrivate::~MythCoreContextPrivate()
>>>
>>> used to have:
>>>
>>>   GetMythDB()->GetDBManager()->CloseDatabases();
>>>
>>>     if (m_database) {
>>>         DestroyMythDB();
>>>         m_database = NULL;
>>>     }
>>>
>>>
>>>
>>> I suspect there is now a race condition where the context is not
>>> being destructed in time?
>>>
>>>
>>> --
>>> Nigel Pearson, 02 9792 6998, 0408 66 44 35
>>> nigel.pearson.au@gmail.com <mailto:nigel.pearson.au@gmail.com>
>>>
>>
>> That code is still there. I don't  know how I missed it.
>>
>> It looks good, so I am not sure what is going on.  Need to trace it ...
>>
>> Peter
>>
>>
>
> I don't believe this bug is specific to MythTV but more a regression
> in libmysqlclient you can easily reproduce it using this simple Qt
> test app.
>
>
> #include <QApplication>
> #include <QSqlDatabase>
> #include <QString>
> #include <QDebug>
>
> void cause_segfault()
> {
>   {
>     QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
>     db.setDatabaseName("mythconverg");
>     db.setUserName("mythtv");
>     db.setHostName("192.168.1.32");
>     db.setPassword("xxxxxxxx");
>     db.open();
>     db.close();
>   }
>   auto name = QSqlDatabase::database().connectionName();
>   qDebug() << "About to remove database";
>   QSqlDatabase::removeDatabase(name);
>   qDebug() << "Removed database";
> }
>
> int main(int argc, char *argv[])
> {
>   QApplication a(argc, argv);
>   cause_segfault();
>   return -1;
> }
>
> Paul H.
>
>
>
I tested installing the prior version of libmysqlclient21. That resolves
the issue, as is mentioned in the ticket.

https://vitux.com/how-to-downgrade-packages-on-ubuntu/

Also libmysqlclientdev needs to be downgraded, if building from source.

Peter
Re: [mythtv-users] segfault in libmysqlclient.so.21 [ In reply to ]
On 14/05/2020 20:58, Peter Bennett wrote:

> On 5/13/20 7:34 PM, Paul Harrison wrote:
>
>> I don't believe this bug is specific to MythTV but more a regression
>> in libmysqlclient you can easily reproduce it using this simple Qt
>> test app.
>>
>>
>> #include <QApplication>
>> #include <QSqlDatabase>
>> #include <QString>
>> #include <QDebug>
>>
>> void cause_segfault()
>> {
>>   {
>>     QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
>>     db.setDatabaseName("mythconverg");
>>     db.setUserName("mythtv");
>>     db.setHostName("192.168.1.32");
>>     db.setPassword("xxxxxxxx");
>>     db.open();
>>     db.close();
>>   }
>>   auto name = QSqlDatabase::database().connectionName();
>>   qDebug() << "About to remove database";
>>   QSqlDatabase::removeDatabase(name);
>>   qDebug() << "Removed database";
>> }
>>
>> int main(int argc, char *argv[])
>> {
>>   QApplication a(argc, argv);
>>   cause_segfault();
>>   return -1;
>> }
>>
>> Paul H.
>>
>>
>>
> I tested installing the prior version of libmysqlclient21. That
> resolves the issue, as is mentioned in the ticket.
>
> https://vitux.com/how-to-downgrade-packages-on-ubuntu/
>
> Also libmysqlclientdev needs to be downgraded, if building from source.
>
> Peter
>
>

It's also possible to reproduce the crash using just libmysqlclient
directly without using Qt.

https://bugs.launchpad.net/ubuntu/+source/mysql-8.0/+bug/1877504/comments/10


Paul H.

_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org