locked
DatagramSocket::GetEndpointPairsAsync crashes the app

    Question

  • The following code:

    auto res = task< Collections::IVectorView<EndpointPair^>^ >(
    				DatagramSocket::GetEndpointPairsAsync(ref new HostName(ref new Platform::String(L"google.com")), ref new Platform::String(L"80"))).get();
    
    			for (unsigned int i = 0; i < res->Size; ++i)
    			{				
    				std::wstring lip = res->GetAt(i)->LocalHostName->RawName->Data();
    				std::wstring lserv = res->GetAt(i)->LocalServiceName->Data();
    				std::wstring ip = res->GetAt(i)->RemoteHostName->RawName->Data();
    				std::wstring serv = res->GetAt(i)->RemoteServiceName->Data();
    
    				std::wostringstream os;
    
    				os << lip << L":" << lserv << " - ";
    				os << ip << L":" << serv << "\n";
    
    				OutputDebugString(os.str().c_str());
    			}

    Prints:

    192.168.115.130:0 - 74.125.71.102:80
    192.168.115.130:0 - 74.125.71.113:80
    192.168.115.130:0 - 74.125.71.138:80

    And crashes with unhandled exception:

    Unhandled exception at 0x77f19227 in TestApp.exe: 0xC000070E: After a callback to 0x%p(0x%p), an completion call to FreeLibrary(%p) failed with status 0x.

    Why ? Is this a bug ? How to workaround ?

    Friday, March 02, 2012 1:55 PM

Answers

  • You can skip posting the callstack. I eventually hit the exception you reported. I was mostly encountering a pageheap error using this code, but eventually encountered the 0xC000070E exception.

    For reference, this is the pageheap error:

    HEAP[samplecpp.exe]: HEAP: Free Heap block 3462078 modified at 34620e8 after it was freed
    SampleCPP.exe has triggered a breakpoint.

    I created a bug for this scenario today.

    Thanks,

    -David

    Monday, March 05, 2012 10:26 PM
    Moderator

All replies

  • The code is called in a separate thread in MTA, so task<T>.get() is completely legal
    Friday, March 02, 2012 1:56 PM
  • Nice find Shephph! Could you post the callstack for your exception please? I'm needing to determine if this bug needs reported to either the Windows or Visual Studio team.

    Thanks,

    -David

    Monday, March 05, 2012 8:36 PM
    Moderator
  • You can skip posting the callstack. I eventually hit the exception you reported. I was mostly encountering a pageheap error using this code, but eventually encountered the 0xC000070E exception.

    For reference, this is the pageheap error:

    HEAP[samplecpp.exe]: HEAP: Free Heap block 3462078 modified at 34620e8 after it was freed
    SampleCPP.exe has triggered a breakpoint.

    I created a bug for this scenario today.

    Thanks,

    -David

    Monday, March 05, 2012 10:26 PM
    Moderator
  • Dear DavidLamb,

            For this bug, do you have any progress?

    I also meet this problem.

    Thanks,

    Best Regards.

    Vincent Chou

    Thursday, August 16, 2012 10:22 AM
  • Hi All,

    Is there any update on DatagramSocket::GetEndpointPairsAsync?  I'm getting a crash in the code below.  After some google searching I'm unsure if its the same issue mentioned here or I'm doing something wrong.

    Thanks,

    Red

    IAsyncOperation<IVectorView<EndpointPair^>^>^ asyncOp = DatagramSocket::GetEndpointPairsAsync(ref new HostName("example.com"), "caldavs");
    auto getEndpointsTask = create_task(asyncOp);
    getEndpointsTask.then([this](IVectorView<EndpointPair^>^ endpointList)
    {
    for (unsigned int i = 0; i < endpointList->Size; i++)
    {
    // Doing stuff here...
    }
    });
    Wednesday, January 15, 2014 7:25 PM