Crashed in IConnectionPoint::Advise

Lowell Liu 106 Reputation points
2025-11-26T05:56:06.73+00:00

When i use this api named IConnectionPoint::Advise in my app main thread, the app crashed, only once, can not reproduced, why and how to fix it?
here is the stack:

 # Child-SP          RetAddr               : Args to Child                                                           : Call Site
00 00000060`4a6f9eb8 00007fff`f00aef34     : 00000201`b77ddb68 00000201`b5c50b60 00000201`ba3ccfe0 00000000`00000000 : ntdll!NtDelayExecution+0x14
*** WARNING: Unable to verify checksum for KERNELBASE.dll
01 00000060`4a6f9ec0 00007fff`ed313c31     : 00000000`00000000 00000000`00000000 00000000`00000002 00000060`4a401000 : ntdll!RtlDelayExecution+0x34
*** WARNING: Unable to verify checksum for sentry.dll
02 00000060`4a6f9ef0 00007fff`70ab62de     : 00000000`00000000 00000000`00000000 ffffffff`dc3cba00 00000060`4a401000 : KERNELBASE!SleepEx+0x91
03 00000060`4a6f9f80 00007fff`efff2d26     : 00000060`4a6fac00 00000060`00000000 00000000`00000002 00000000`00000000 : sentry!sentry_span_set_data+0x43547
04 00000060`4a6fa0d0 00007fff`efff20f6     : 00000060`4a6fac10 00000000`0d00020f 00000000`00000000 00007fff`70ab3040 : ntdll!RtlpCallVectoredHandlers+0xd6
05 00000060`4a6fa160 00007fff`effea961     : 00000000`00000000 00000060`4a6faa60 00000000`00000000 00000060`4a6fac10 : ntdll!RtlDispatchException+0x206
06 00000060`4a6fa3b0 00007fff`f00f7885     : 00000000`00000021 00000000`c0000374 00000000`00000001 00007fff`f01ad0e0 : ntdll!RtlRaiseException+0x221
07 00000060`4a6fab90 00007fff`f007da69     : 00000060`4a6fdee0 00000000`00000000 00000000`00000000 00007fff`f01ad138 : ntdll!RtlReportFatalFailure+0x9
08 00000060`4a6fabe0 00007fff`f0006742     : 00000060`4a6fada0 00007fff`f01ad0e0 00000000`00000008 00000201`b5bb0000 : ntdll!RtlReportCriticalFailure+0xa9
09 00000060`4a6facd0 00007fff`f00fd9aa     : 00000000`00000008 00000060`4a6faf30 00000201`b5bb0000 00000201`ba44b510 : ntdll!RtlpHeapHandleError+0x12
0a 00000060`4a6fad00 00007fff`efffed2b     : 00000000`00000000 00000201`ba44b4f0 00000201`ba44b500 00000060`4a6fad90 : ntdll!RtlpHpHeapHandleError+0x7a
0b 00000060`4a6fad30 00007fff`f00593ba     : 00000060`4a6fad80 00000060`00000000 00000000`00000000 00000000`00000000 : ntdll!RtlpLogHeapFailure+0x4b
*** WARNING: Unable to verify checksum for ucrtbase.dll
0c 00000060`4a6fad60 00007fff`ed98e0fb     : 00000201`b5bb0000 00000000`00000000 00000201`ba44b500 00000201`ba44b500 : ntdll!RtlFreeHeap+0x6da
*** WARNING: Unable to verify checksum for RingCentralVideoClient.dll
0d 00000060`4a6fae50 00007fff`63bdf1bf     : 00000060`4a6fafe4 00000000`00000000 00000201`bce6c680 00000201`ba44b500 : ucrtbase!free_base+0x1b
*** WARNING: Unable to verify checksum for combase.dll
0e 00000060`4a6fae80 00007fff`ededae75     : 00000201`ba44b500 00007fff`65078268 00000060`4a6faf30 00000201`bce6c698 : RingCentralVideoClient!NetworkConnectionEventsImpl::Release+0x5f [D:\jenkins\workspace\PRM-RCV-SDK-3rd-Party-Deps-Windows\src\network\network_connection_events.cpp @ 58] 
0f (Inline Function) --------`--------     : --------`-------- --------`-------- --------`-------- --------`-------- : combase!Microsoft::WRL::ComPtr<IUnknown>::InternalRelease+0xf (Inline Function @ 00007fff`ededae75) [onecore\external\sdk\inc\wrl\client.h @ 235] 
10 (Inline Function) --------`--------     : --------`-------- --------`-------- --------`-------- --------`-------- : combase!Microsoft::WRL::ComPtr<IUnknown>::{dtor}+0xf (Inline Function @ 00007fff`ededae75) [onecore\external\sdk\inc\wrl\client.h @ 290] 
11 00000060`4a6faeb0 00007fff`ededb8e4     : 00000000`00000000 00000000`00000000 00007fff`dd9588e8 00000000`00000001 : combase!CGIPTable::RegisterInterfaceInGlobalHlp+0x345 [onecore\com\combase\dcomrem\giptbl.cxx @ 921] 
*** WARNING: Unable to verify checksum for netprofm.dll
12 00000060`4a6faf70 00007fff`dd93165a     : 00000000`0000000f 00000000`0000000b 00000201`ba44b500 00000000`00000006 : combase!CGIPTable::RegisterInterfaceInGlobal+0x14 [onecore\com\combase\dcomrem\giptbl.cxx @ 783] 
13 00000060`4a6fafb0 00007fff`63bddba9     : 00000201`ba44b510 00000201`ba3d6230 37313437`3431322d 00000201`ba3d6220 : netprofm!PublicNetworkListManager::NetworkConnectionEventsAdvise+0x9a
Developer technologies | C++
Developer technologies | C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Q&A Assist
    2025-11-26T05:56:18.11+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    The crash you experienced while using IConnectionPoint::Advise could be due to several factors, including memory management issues or improper handling of COM interfaces. Here are some potential causes and solutions:

    1. Memory Management: Ensure that the sink object you are passing to Advise is valid and has not been released or corrupted before the call. If the sink object is deleted or goes out of scope, it can lead to crashes when the connection point tries to call back.
    2. Thread Safety: Since you mentioned that the crash occurred on the main thread, ensure that the Advise call is not being made from multiple threads simultaneously without proper synchronization. COM objects are not inherently thread-safe unless explicitly designed to be.
    3. Exception Handling: Implement robust exception handling around your Advise call. If an exception is thrown and not caught, it can lead to application instability.
    4. Debugging Tools: Utilize debugging tools like DebugDiag or WinDbg to analyze the crash dump. This can provide insights into the state of the application at the time of the crash and help identify the root cause.
    5. Check for Valid Pointers: Ensure that all pointers passed to Advise are valid and that the interface you are advising is correctly implemented and registered.
    6. Review Stack Trace: Analyze the stack trace you provided for any specific patterns or recurring issues that might indicate a problem with the way Advise is being called or how the sink is being managed.

    If the issue persists, consider logging additional information before and after the Advise call to capture the state of your application, which may help in diagnosing the problem further.

    0 comments No comments

  2. Adiba Khan 1,440 Reputation points Microsoft External Staff
    2025-11-26T08:22:40.0633333+00:00

    Thank you for reaching out. Based on the crash information you shared, the issue occurred inside the COM API IConnectionPoint::Advise, specifically triggered through:

    netprofm!PublicNetworkListManager::NetworkConnectionEventsAdvise
    combase!CGIPTable::RegisterInterfaceInGlobal
    

    This indicates that the failure happened during a COM event subscription-most likely due to a race condition, premature COM object release or an unexpected thread apartment mismatch.

    Why the crash occurred

    Although the crash only happened once and is not reproducible, the stack trace suggests one of the following causes:

    1. COM object lifetime issue (most common) If the COM interface pointer being passed into advise() is
      1. Already released
      2. Not AddRef’ed properly
      3. Or destroyed during event registration it may intermittently cause a crash inside COMBASE.DLL.
    2. Threading apartment mismatch IConnectionPoint::Advise requires that:
      1. The caller is running in a STA (Single-Threaded Apartment) when subscribing to events.
      2. The COM server may be MTA or STA, depending on implementation.
      Calling Advise() from the wrong apartment can occasionally trigger a crash
    3. COM event sink not implementing the interface correctly If your event sink does not fully implement the required COM interface and vtable layout, COM may access invalid memory.
    4. A transient internal failure inside Netprofm (NetworkListManager) Since the crash originates in :
         netprofm.dll -> PublicNetworkListManager::NetworkConnectionEventsAdvise
      
      This indicates the Windows Network List Manager COM component was involved. Rare timing issues may occur during system network state changes (adapter update, network reset, VPN connect/disconnect)

    Recommended Fixes:

    1. Ensure COM is initialized correctly Before calling advise:
         CoIntializeEx(NULL, COINT_APARTMENTTHREADED); //STA required
      
      If your main thread is MTA, more advise to an STA thread.
    2. Validate COM object lifetime Ensure:
      1. Your event sink object stays alive until you call Unadvise().
      2. You call AddRef() appropriately inside your sink’s QueryInterface implementation
      3. You do not release the connection point container prematurely.
    3. Wrap advice with error checking
         CCOMPtr<IConnectionPoint> cp;
         HRESULT hr = connPtContainer -> FindConnectionPoint(__uuidof(INetworkConnectionEvents), &cp);
         if (SUCCEEDED(hr))
         {
         	hr = cp->Advise(pEventSink, &cookie);
         	if (FAILED(hr))
         	{
         		// Log or handle failure
         	}
      
    4. Ensure Unadvise() is always called Missing or late unadvised calls can cause internal state corruption.
    5. Add defensive try/catch around event handling Unexpected exception inside the event sink callback can propagate back into COM

    Please let us know if you require any further assistance we’re happy to help. If you found this information useful, kindly mark this as "Accept Answer".


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.