A bug in release_env function

xiaonan <[email protected]> Thu, 25 Jul 2013 17:45:14 +0800 (CST)
Newsgroups gmane.comp.db.unixodbc.devel
Message-ID <[email protected]>
Hi, Nick:


Greetings form me!
I found a issue in release_env function. In this function, the env_lib_list is a local varibale, but it points to a gloabl variable connection -> environment -> env_lib_list. So I think the whole code should be protected like this:


static void release_env( DMHDBC connection )
{
struct env_lib_struct *env_lib_list, *env_lib_prev;
int ret;


if ( connection -> driver_env )
{
mutex_lib_entry();
 
......
 
mutex_lib_exit();
}
}
If not add the mutex in release_env, there will be a thread calls __connect_part_one, which accesses the connection -> environment -> env_lib_list, while the other thread calls release_env, which also accesses the connection -> environment -> env_lib_list. And this will cause unpredictable result, such as core dump.
Please check it, thanks very much!
Best Regards
Nan Xiao

_______________________________________________
unixODBC-dev mailing list
[email protected]
http://mailman.unixodbc.org/mailman/listinfo/unixodbc-dev