Search

GetAdaptersAddresses API incorrectly returns no adapters for a process with high memory consumption by Roman Ryltsov

Closed
as External Help for as External

3
0
Sign in
to vote
Type: Bug
ID: 665383
Opened: 4/28/2011 12:55:07 AM
Access Restriction: Public
0
Workaround(s)
3
User(s) can reproduce this bug
I noticed a problem with severe impact on our application, which is coming from GetAdaptersAddresses API (also applies to GetAdaptersInfo).

The problem is that a Win32 application calling this API receives correct results except servers where our process is set up to process a lot of data.

At some point, GetAdaptersAddresses/GetAdaptersInfo which previously reported good results, starts returning zero adapeters. As soon as I replaced GetAdaptersInfo call with a newer GetAdaptersAddresses I started seeing 998 ERROR_NOACCESS error code.

As a clue, it is taking place around going over 2GB on Private Bytes and Virtual Size. Our application is 32-bit marked as aware of large addresses, so it can receive 3 or 4GB of virtual address space depending on OS and configuration.

Note that when I turned off some activity on the same process to make it free some memory, and retried GetAdaptersAddresses - I could again obtain the list of adapters. It took place without restarting a process. At the same time other processes receive adapter list without problems.

I thought it might be a bug in Windows component which is failing to see valid memory pointer in higher 2GB address space.

I am providing code snippet below to indicate API usage:

ULONG nAdapterAddressesSize = 16 << 10; // 16K
ATLENSURE_THROW(pAdaptersAddresses.AllocateBytes(nAdapterAddressesSize), E_OUTOFMEMORY);
static const DWORD g_nFlags = GAA_FLAG_INCLUDE_PREFIX | GAA_FLAG_INCLUDE_GATEWAYS | GAA_FLAG_INCLUDE_ALL_INTERFACES;
HRESULT nResult = HRESULT_FROM_WIN32(GetAdaptersAddresses(AF_INET, g_nFlags, NULL, pAdaptersAddresses, &nAdapterAddressesSize));
// *** Here we go with ERROR_NOACCESS ***
if(nResult == HRESULT_FROM_WIN32(ERROR_BUFFER_OVERFLOW))
{
    nAdapterAddressesSize += 4 << 10; // 4K
    pAdaptersAddresses.Free();
    ATLENSURE_THROW(pAdaptersAddresses.AllocateBytes(nAdapterAddressesSize), E_OUTOFMEMORY);
    nResult = HRESULT_FROM_WIN32(GetAdaptersAddresses(AF_INET, g_nFlags, NULL, pAdaptersAddresses, &nAdapterAddressesSize));
}
ATLENSURE_SUCCEEDED(nResult);
Details (expand)

Visual Studio/Silverlight/Tooling version

Visual Studio 2010 SP1

What category (if any) best represents this feedback?

Reliability

Steps to reproduce

Please see Description above

Product Language

English

Operating System

Windows 7

Operating System Language

English

Actual results

API failure

Expected results

API success
File Attachments
File Name Submitted By Submitted On File Size  
Image001.png 4/28/2011 6 KB
GetAdaptersAddressesTest.zip 4/29/2011 227 KB
Sign in to post a comment.
Posted by Microsoft on 11/18/2011 at 2:05 AM
Thank you for your bug submission. The issue you reported appears to be on a released Windows Product. If this issue is severe, causing critical business situations or blocking your product development or deployment, please go to http://support.microsoft.com or call 1-800-MICROSOFT for assistance. For Microsoft premier customers, please contact your administrator, your Technical Account Manager, or your Microsoft premier account representative.
Other Support links - http://support.microsoft.com/ph/14019#tab13
Posted by ChuckDes on 7/19/2011 at 7:02 AM
Hi.

We are witnessing the same problem here. Error code 998 when trying to retrieve the AdaptersAddresses when the process (a 32-bit app) running on a 64-bits Win7 goes over the 2GB limit with LARGE_ADDRESS_AWARE enabled...

Charles
Posted by Microsoft on 5/11/2011 at 8:09 PM
Thank you for attaching the project to help us reproduce this issue. Your issue has been routed to the appropriate VS development team for review. We will contact you if we require any additional information.
Posted by Roman Ryltsov on 4/29/2011 at 1:09 AM
A few more comments:

1. The project is ATL service, so you need to run "GetAdaptersAddressesTest /regserver" once prior to the test itself.

2. I tried yesterday on Windows 7 32-bit, with /3GB tuning and I could not reproduce the problem there. It still takes place consistently on various 64-bit systems.

Attached is the project.
Posted by Microsoft on 4/29/2011 at 1:00 AM
Hi Roman,

It seems that the test project cannot be download integrally for us. Could you please attach it to this bug?

Thanks!
Posted by Roman Ryltsov on 4/28/2011 at 2:29 AM
OK, I can provide you test code to show the problem.

Here is template ATL C++ Project with perhaps extra 100 lines of code:

http://www.assembla.com/code/roatl-utilities/subversion/nodes/trunk/GetAdaptersAddressesTest

It allocates 2+ GB of memory and starts doing GetAdaptersInfo, soon it fails (not on the first call!). See attached screenshot.
Posted by Microsoft on 4/28/2011 at 1:14 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.