Overview
Features
Download
Documentation
Community
Add-Ons & Services

Error in my_thread_global_end(): 1 threads didn't exit

Please post support and help requests here.

Error in my_thread_global_end(): 1 threads didn't exit

Postby flomll » 22 Feb 2013, 11:24

Hy I implmement a thread that should listen on the database for changes at a table. But If I terminate the application I got this message. Everything runs correct, but I got this message on shutdown.

Error in my_thread_global_end(): 1 threads didn't exit



Code: Select all
Listener::Listener(Poco::NotificationQueue& queue,
                   ushort timeout,
                   ushort delayMin,
                   ushort delayMax) :
        _stop(false),
        _timeout(timeout),
        _requestDelayMin(delayMin),
        _requestDelayMax(delayMax),
        _queue(queue),
        _logger(Logger::get("Notifier.Listener"))
{
}

Listener::~Listener()
{
}

void Listener::run()
{
    try
    {
       Poco::Data::Session * session = new Session(Connector::KEY, dbConnString);

        NS::DB::Task task;

        while (!_stop)
        {
            task.clear();
            (*session << "SELECT .."); // Some SQL syntax

            if(task.id > 0)
            {
                (*session << "UPDATE...); // Some SQL syntax
            }
            Thread::sleep(_requestDelayMin);
        }
    }
    catch(Poco::Exception& e)
    {
        std::cerr << e.displayText();
    }
    delete (session); session = 0;
}

void Listener::stop()
{
    _stop = true;
}




I run it with valgind and got this output:
Code: Select all
Error in my_thread_global_end(): 1 threads didn't exit
Press ENTER to quit.
==2987==
==2987== HEAP SUMMARY:
==2987==     in use at exit: 2,096 bytes in 56 blocks
==2987==   total heap usage: 6,893 allocs, 6,837 frees, 653,362 bytes allocated
==2987==
==2987== 128 bytes in 1 blocks are definitely lost in loss record 52 of 54
==2987==    at 0x402A5E6: calloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==2987==    by 0x4C2AB03: my_thread_init (in /usr/lib/i386-linux-gnu/libmysqlclient.so.18.0.0)
==2987==    by 0x4C02824: mysql_server_init (in /usr/lib/i386-linux-gnu/libmysqlclient.so.18.0.0)
==2987==    by 0x4C09468: mysql_init (in /usr/lib/i386-linux-gnu/libmysqlclient.so.18.0.0)
==2987==    by 0x4647027: Poco::Data::MySQL::SessionHandle::init(st_mysql*) (SessionHandle.cpp:57)
==2987==    by 0x4646FF4: Poco::Data::MySQL::SessionHandle::SessionHandle(st_mysql*) (SessionHandle.cpp:49)
==2987==    by 0x4638FEE: Poco::Data::MySQL::SessionImpl::SessionImpl(std::string const&, unsigned int) (SessionImpl.cpp:73)
==2987==    by 0x4641FD1: Poco::Data::MySQL::Connector::createSession(std::string const&, unsigned int) (Connector.cpp:70)
==2987==    by 0x44AECAA: Poco::Data::SessionFactory::create(std::string const&, std::string const&, unsigned int) (SessionFactory.cpp:92)
==2987==    by 0x44AE3E4: Poco::Data::Session::Session(std::string const&, std::string const&, unsigned int) (Session.cpp:60)
==2987==    by 0x806E3FD: NS::DB::Listener::run() (listener.cpp:67)
==2987==    by 0x41C3202: Poco::ThreadImpl::runnableEntry(void*) (Thread_POSIX.cpp:378)
==2987==
==2987== LEAK SUMMARY:
==2987==    definitely lost: 128 bytes in 1 blocks
==2987==    indirectly lost: 0 bytes in 0 blocks
==2987==      possibly lost: 0 bytes in 0 blocks
==2987==    still reachable: 1,968 bytes in 55 blocks
==2987==         suppressed: 0 bytes in 0 blocks
==2987== Reachable blocks (those to which a pointer was found) are not shown.
==2987== To see them, rerun with: --leak-check=full --show-reachable=yes
==2987==
==2987== For counts of detected and suppressed errors, rerun with: -v
==2987== Use --track-origins=yes to see where uninitialised values come from
==2987== ERROR SUMMARY: 29 errors from 2 contexts (suppressed: 0 from 0)
flomll
 
Posts: 28
Joined: 18 May 2012, 08:58
Location: Austria

Re: Error in my_thread_global_end(): 1 threads didn't exit

Postby flomll » 22 Feb 2013, 11:38

And I use this version of libmysqlclient-dev:
Code: Select all
apt-cache policy libmysqlclient-dev
libmysqlclient-dev:
  Installiert: 5.5.29-0ubuntu0.12.04.1
  Kandidat:    5.5.29-0ubuntu0.12.04.1
  Versionstabelle:
 *** 5.5.29-0ubuntu0.12.04.1 0
        500 http://de.archive.ubuntu.com/ubuntu/ precise-updates/main i386 Packages
        500 http://security.ubuntu.com/ubuntu/ precise-security/main i386 Packages
        100 /var/lib/dpkg/status
     5.5.22-0ubuntu1 0
        500 http://de.archive.ubuntu.com/ubuntu/ precise/main i386 Packages
flomll
 
Posts: 28
Joined: 18 May 2012, 08:58
Location: Austria

Re: Error in my_thread_global_end(): 1 threads didn't exit

Postby flomll » 25 Feb 2013, 11:38

Has anybody an idea? :geek:
flomll
 
Posts: 28
Joined: 18 May 2012, 08:58
Location: Austria

Re: Error in my_thread_global_end(): 1 threads didn't exit

Postby alex » 25 Feb 2013, 18:52

are you joining the thread before exit?
alex
 
Posts: 1044
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: Error in my_thread_global_end(): 1 threads didn't exit

Postby flomll » 08 Mar 2013, 09:20

I start a thread to check the database for changes and if I terminate the application I join the this thread successfully. Following you see the code of the thread:

listener.h:
Code: Select all
class Listener: public Poco::Runnable {
public:
   Listener(Poco::NotificationQueue& queue, ushort timeout, ushort delayMin, ushort delayMax);
   virtual ~Listener();

   void run();

   void stop();

private:
   bool _stop;

   unsigned short _timeout;
   unsigned short _requestDelayMin;
   unsigned short _requestDelayMax;

   Poco::NotificationQueue& _queue;

   Poco::SharedPtr<Poco::Data::Session> _pSession;
   Poco::Logger& _logger;
};


listener.cpp:
Code: Select all
Listener::Listener(Poco::NotificationQueue& queue,
                   ushort timeout,
                   ushort delayMin,
                   ushort delayMax) :
        _stop(false),
        _timeout(timeout),
        _requestDelayMin(delayMin),
        _requestDelayMax(delayMax),
        _queue(queue),
        _logger(Logger::get("Notifier.Listener"))
{
}

Listener::~Listener()
{
   _pSession->close();
}

void Listener::run()
{
    try
    {
       // The _pSession is smartPointer so a delete is not needed.
        _pSession = new Session(Connector::KEY, dbConnString);

        NS::Mediator::ModelTask task;

        while (!_stop)
        {
            task.clear();
            (*_pSession << "SELECT ...",
                                        use(_timeout),
                                        into(task.id),
                                        into(task.param),
                                        into(task.target),
                                        into(task.value),
                                        into(task.group),
                                        into(task.ident),
                                        range(0,1),
                                        now );

            if(task.id > 0)
            {
                (*_pSession << "UPDATE ... ",
                                            use(task.id),
                                            now);
            }
            Thread::sleep(_requestDelayMin);
        }
    }
    catch(Poco::Exception& e)
    {
        std::cerr << e.displayText();
    }
}

void Listener::stop()
{
    _stop = true;
}


And I join the thread with:
Code: Select all
thread_watcher.join();
poco_information(app.logger(), "Listener joined");
flomll
 
Posts: 28
Joined: 18 May 2012, 08:58
Location: Austria

Re: Error in my_thread_global_end(): 1 threads didn't exit

Postby flomll » 08 Mar 2013, 09:40

I found this link http://bugs.mysql.com/bug.php?id=50148

But the entry is from 2010!!
flomll
 
Posts: 28
Joined: 18 May 2012, 08:58
Location: Austria


Return to Support

Who is online

Users browsing this forum: No registered users and 3 guests

cron