[ace-bugs] ACE Core: weird failure of ACE_OS::thr_keycreate_native causes stack overflow

Harper, Paul J. c_pharpe at qti.qualcomm.com
Tue Mar 15 15:21:14 CDT 2016


    ACE VERSION: 6.1.4

    HOST MACHINE and OPERATING SYSTEM:
        Windows 7 Enterprise Service Pack 1
        Lenovo T430

    COMPILER NAME AND VERSION (AND PATCHLEVEL):
        Microsoft Visual Studio 2010
        version 10.0.40219.1 SP1Rel

    THE $ACE_ROOT/ace/config.h FILE 

        // These wrappers should not be place. ACE wont compile.
        // #ifndef ACE_CONFIG_H
        // #define ACE_CONFIG_H

        // Use ACE as a static library with static MSVC run time libraries.
        // These defines are recommended in the ACE install notes.
        #ifdef ACE_HAS_DLL
        #  undef ACE_HAS_DLL
        #  define ACE_HAS_DLL 0
        #endif

        #ifndef ACE_NO_INLINE
        #  define ACE_NO_INLINE
        #endif

        #define ACE_HAS_STANDARD_CPP_LIBRARY 1

        // Define ACE_HAS_IPV6 to enable ACE IPv6 support
        #define ACE_HAS_IPV6

        #include <ace/config-win32.h>

        // #endif // ACE_CONFIG_H





    AREA/CLASS/EXAMPLE AFFECTED:
        ACE_OS::thr_keycreate_native fails in a non standard way, only on one 
        machine

    DOES THE PROBLEM AFFECT:
        EXECUTION
        App dies with stack overflow (in debug mode) during initialization 
          phase before getting to main
        Release mode just hangs

    SYNOPSIS:

    Return from call TlsAlloc in line 4769 in OS_NS_Thread.cpp is 0x0011abba 
    (in debug mode) instead of normal value (on other machines like 11 or 20).
    This weird value is not the ACE_SYSCALL_FAILED value of 0xFFFFFFFF so the 
    check for a bad return fails. Offending code is below:

        *key = ::TlsAlloc ();
        if (*key == ACE_SYSCALL_FAILED)
          ACE_FAIL_RETURN (-1);
        return 0;

    Further on in ACE initialization, ACE tries to log an anomaly caused by
    the failure, and produces a stack overflow (See snippet below), as the log
    functions try again to get thread local storage. This failure to log is an
    area where ACE could maybe be improved.



    DESCRIPTION:

    Not sure if this is even an ACE bug but it shows up in ACE, and only on one machine.

    Only on one machine!

    Currently I only have one machine where this happens (a relatively new
    corporate laptop). If I build the exe on the laptop, a copy of the exe runs
    fine on other machines. Conversely if I build on another machine then run
    the build from the other machine on the laptop, I get the same crash.

    Even 5 year old builds affected

    I have now tried running older versions of the offending software (back to
    versions from 2011) and some fail silently, some fail with message
    "ACE_Thread::keycreate() failed!"" and some run fine. These older versions
    of the software have been running fine on many other machines (including
    customer sites)

    Even More data:

    I have built a small test program that initializes and calls the same ACE
    library, then also does an independent call to tlsAlloc, everything is
    fine. So it must be something in my own c++ initializers (or ACE) on just this one machine that is screwing with my stack or memory somehow?

    Stack Trace of Stack Overflow:


    .. and so on till stack is exhausted
    MyApp.exe!__ace_assert(const char * file, int line, const char *
       expression)  Line 14 + 0x5 bytes    C++
    MyApp.exe!ACE_TSS_Cleanup::insert(unsigned long key, void (void *)*
       destructor)  Line 817 + 0x23 bytes   C++
    MyApp.exe!ACE_OS::thr_keycreate(unsigned long * key, void (void *)* dest)
       Line 4820 + 0x19 bytes    C++
    MyApp.exe!ACE_Thread::keycreate(unsigned long * keyp, void (void *)*
       destructor)  Line 23 + 0xd bytes    C++
    MyApp.exe!ACE_Log_Msg::instance()  Line 309 + 0x10 bytes C++
    MyApp.exe!__ace_assert(const char * file, int line, const char *
       expression)  Line 14 + 0x5 bytes    C++
    MyApp.exe!ACE_TSS_Cleanup::insert(unsigned long key, void (void *)*
       destructor)  Line 817 + 0x23 bytes   C++
    MyApp.exe!ACE_OS::thr_keycreate(unsigned long * key, void (void *)* dest)
       Line 4820 + 0x19 bytes    C++
    MyApp.exe!ACE_Thread::keycreate(unsigned long * keyp, void (void *)*
       destructor)  Line 23 + 0xd bytes    C++
    MyApp.exe!ACE_Log_Msg::instance()  Line 309 + 0x10 bytes C++
    MyApp.exe!__ace_assert(const char * file, int line, const char *
       expression)  Line 14 + 0x5 bytes    C++
    MyApp.exe!ACE_TSS_Cleanup::insert(unsigned long key, void (void *)*
       destructor)  Line 817 + 0x23 bytes   C++
    MyApp.exe!ACE_OS::thr_keycreate(unsigned long * key, void (void *)* dest)
       Line 4820 + 0x19 bytes    C++
    MyApp.exe!ACE_Thread::keycreate(unsigned long * keyp, void (void *)*
       destructor)  Line 23 + 0xd bytes    C++
    MyApp.exe!ACE_Threading_Helper<ACE_Thread_Mutex>::ACE_Threading_Helper
       <ACE_Thread_Mutex>()  Line 43 + 0xb bytes  C++
    MyApp.exe!ACE_Service_Config::ACE_Service_Config(bool ignore_static_svcs,
       unsigned int size, int signum)  Line 372 + 0x6c bytes  C++
    MyApp.exe!ACE_Singleton<ACE_Service_Config,
       ACE_Recursive_Thread_Mutex>::ACE_Singleton<ACE_Service_Config,
       ACE_Recursive_Thread_Mutex>()  Line 15  C++
    MyApp.exe!ACE_Unmanaged_Singleton<ACE_Service_Config,
       ACE_Recursive_Thread_Mutex>::ACE_Unmanaged_Singleton<ACE_Service_Config,
       ACE_Recursive_Thread_Mutex>()  Line 19 + 0x2b bytes C++
    MyApp.exe!ACE_Unmanaged_Singleton<ACE_Service_Config,
       ACE_Recursive_Thread_Mutex>::instance()  Line 184 + 0x30 bytes  C++
    MyApp.exe!ACE_Service_Config::singleton()  Line 327  C++
    MyApp.exe!ACE_Service_Config::current()  Line 424 + 0x5 bytes    C++
    MyApp.exe!ACE_Service_Config::static_svcs()  Line 101    C++
    MyApp.exe!ACE_Object_Manager_Preallocations::ACE_Object_Manager_Preallocati
       ons()  Line 145 + 0x9 bytes   C++
    MyApp.exe!ACE_Object_Manager::init()  Line 327 + 0x30 bytes  C++
    MyApp.exe!ACE_Object_Manager::ACE_Object_Manager()  Line 409 C++
    MyApp.exe!ACE_Object_Manager::instance()  Line 430 + 0x30 bytes  C++
    MyApp.exe!ACE::init()  Line 19 + 0x5 bytes   C++
    MyApp.exe!ACE_Main_Base::ACE_Main_Base()  Line 79    C++
    MyApp.exe!ACE_Main::ACE_Main()  + 0x2b bytes C++
    MyApp.exe!main(int argc, char * * argv)  Line 207 + 0x45 bytes   C++
    MyApp.exe!__tmainCRTStartup()  Line 278 + 0x19 bytes C
    MyApp.exe!mainCRTStartup()  Line 189 C
    kernel32.dll!@BaseThreadInitThunk at 12()  + 0x12 bytes    
    ntdll.dll!___RtlUserThreadStart at 8()  + 0x27 bytes   
    ntdll.dll!__RtlUserThreadStart at 8()  + 0x1b bytes    



    REPEAT BY:

    Always fails on this one laptop. everything else runs fine on the laptop.
    Any ideas or suggestions?

    SAMPLE FIX/WORKAROUND:

      Be aware that things can fail in unexpected ways, even system calls.


More information about the ace-bugs mailing list