List:MySQL++« Previous MessageNext Message »
From:KiberGus Date:March 30 2011 8:49pm
Subject:Re: thread_start() should ALWAYS be called after mysql_init()
View as plain text  
2011/3/30 Jonathan Wakely <mysql@stripped>:
> On 30 March 2011 14:03, KiberGus wrote:
>> Today I've stucked in quite a veird bug. My application was written according to
>> http://tangentsoft.net/mysql++/doc/html/userman/threads.html
>> And
>> mysqlpp::Connection::thread_start();
>> was called before grabbing connection from connection pool.
>> thread_start was called before mysql_init on a first call. As a result
>> pthread_getspecific() was called with an unallocated pthread key as an
>> argument. This bug is especially hard to find because thread key has 0
>> value by default and would recieve 0 value on first call to
>> pthread_key_create. So you would never notice this if you don't use
>> thread specific pointers anywhere else beside mysql.
>> But i have used libmysql which uses it too.
>
> Isn't this a bug in mysql_thread_init, as calling that is all that
> Connection::thread_start does?
>

MySQL documentation does not warn much about allowed order of calls.
But ducumentation for my_init
http://dev.mysql.com/doc/refman/5.5/en/my-init.html
states:
However, my_init() is automatically called by mysql_init(),
mysql_library_init(), mysql_server_init(), and mysql_connect(). If you
ensure that your program invokes one of those functions before any
other MySQL calls, there is no need to invoke my_init() explicitly.

I tend to interpret it as a requirement that application MUST start
it's work with library with call to  mysql_init(),
mysql_library_init(), mysql_server_init(), mysql_connect() or
my_init(). And then it is documented feature of mysql library and bug
is in mysql++ rather than in mysql_thread_init.
Thread
thread_start() should ALWAYS be called after mysql_init()KiberGus30 Mar
  • Re: thread_start() should ALWAYS be called after mysql_init()Jonathan Wakely30 Mar
    • Re: thread_start() should ALWAYS be called after mysql_init()KiberGus30 Mar
      • Re: thread_start() should ALWAYS be called after mysql_init()Warren Young31 Mar
Re: thread_start() should ALWAYS be called after mysql_init()KiberGus4 Apr
  • Re: thread_start() should ALWAYS be called after mysql_init()KiberGus4 Apr
  • Re: thread_start() should ALWAYS be called after mysql_init()Warren Young4 Apr
    • Re: thread_start() should ALWAYS be called after mysql_init()Warren Young4 Apr
Re: thread_start() should ALWAYS be called after mysql_init()Raymond Boettcher5 Apr