On 23.07.2018 18:21, Adriano dos Santos Fernandes wrote:
May be has nothing to do with Mark's problem, but inet.cpp/alloc_port
seems to have a race problem:

----------
if (!INET_initialized)
{
     MutexLockGuard guard(init_mutex, FB_FUNCTION);
     if (!INET_initialized)
     {
         ...

         INET_initialized = true;

         // This should go AFTER 'INET_initialized = true' to avoid recursion
         inet_async_receive = alloc_port(0);
         inet_async_receive->port_flags |= PORT_server;
     }
}

...

port->port_async_receive = inet_async_receive;
----------

Someone may pass the if (!INET_initialized) with INET_initialized ==
true, but inet_async_receive still being NULL.

This looks bad but luckily not so awful in fact. Async receive is used only by network server and I see no way for it to allocate secondary ports until completion of master port init. May be adding comment is good idea...




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to