[ace-users] ACE_Service_Config: ACE_Stream_Type ignores gobblers for dynamic streams.

manjak4s at ukr.net manjak4s at ukr.net
Thu Feb 14 08:03:26 CST 2019


ACE VERSION: 6.5.3
HOST MACHINE and OPERATING SYSTEM:

    Windows 10  Enterprise N Edition (v10.0 Build 10240). Winsock 2

COMPILER NAME AND VERSION (AND PATCHLEVEL): 
    MS VS 2015 version 14.0.25431.01 Update 3

$ACE_ROOT/ace/config.h:
    config-win32.h"

AREA/CLASS/EXAMPLE AFFECTED:
    ACE_Service_Config framework.

DOES THE PROBLEM AFFECT:
    EXECUTION

    Affects both sides.

SYNOPSIS:

ACE_Stream_Type class ignores a gobbler function pointer returned by the stream factory.


DESCRIPTION:

I'm loading a conf file with a single dynamic stream created by a factory method from my dll:

stream dynamic Test STREAM * shared:make_stream() active
{
}

1) While tracing the code, I've noticed that ACE_Stream_Type constructor ignores the gobbler 
   function. This leads to two problems:
     - the stream object destructor will not be called at shutdown;
     - the memory itself is released as a raw buffer via operator delete from ACE.dll, though 
       it was allocated by a different module. It does not crash until CRT is shared...

2) I've tried the same with XML config, but stumbled upon this line:
   $ACE_ROOT/ACEXML/apps/svcconf/Svcconf_Handler.cpp:84

   long temp_ptr =
       reinterpret_cast<uintptr_t> (svc_dll.symbol (active_info->init_func ()));
   func = reinterpret_cast<void *(*)(ACE_Service_Object_Exterminator *)> (temp_ptr);

   It maims the factory pointer and crashes at the call.

My questions are: 
1) was it intentional or lost in config format evolution?
2) should I post it as a bug too or the project is dead?

REPEAT BY:

export a simple factory:
ACE_Stream<ACE_SYNCH> * make_stream ( ACE_Service_Object_Exterminator * gobbler )
{ 
    *gobbler = &delete_stream;
    return new ACE_Stream<ACE_SYNCH>;
}

void delete_stream ( void * stream )
{
    delete static_cast<ACE_Stream<ACE_SYNCH> *>(stream);
}

Open and close the svc.conf mentioned above:

int ACE_TMAIN ( int argc, ACE_TCHAR *argv[] )
{
    if (ACE_Service_Config::open(argc, argv, nullptr, false) == -1)
    {
        return -1;
    }

    ACE_Service_Config::close();
    return 0;
}

SAMPLE FIX/WORKAROUND:

1) Add gobbler parameter to the ACE_Stream_Type constructor.
2) Use uintptr_t.




More information about the ace-users mailing list