CM_PROB_DRIVER_FAILED_LOAD only when built in free build environment

Hi,

I’m facing a surprising problem: my NDIS driver failed to load when built in the free build environment but there is no problem when built in the checked build environment.
The error is the following:
#I163 Device not started: Device has problem: 0x27: CM_PROB_DRIVER_FAILED_LOAD.

After many tries, I’ve found 2 lines of code:

IndicateWorkItemContext *iwic = MEMALLOC_S(context->handles.adapter, IndicateWorkItemContext);

if (iwic != NULL)
{
iwic->item = IoAllocateWorkItem (pdo); // FAILED

if (iwic->item != NULL)
{
/* setup the context and queue allocated work item */
iwic->adapter = context->handles.adapter;
iwic->lock = &context->indicate.lock;
iwic->packet = packet;

DBGPRINT(DL_LOG8, " queueing work item %p, context %p", iwic->item, iwic);

IoQueueWorkItem (iwic->item, indicateWorkItemRoutine, DelayedWorkQueue, iwic); // FAILED

DBGFRETP(NDIS_STATUS, NDIS_STATUS_PENDING);
}
else
{
/* error */
DBGPRINT(DL_ERROR, " could not allocate work item");
MEMFREE_S(iwic);
}
}
else
{
/* error */
DBGPRINT(DL_ERROR, " could not allocate memory for work item context");
DBGFRETP(NDIS_STATUS, NDIS_STATUS_RESOURCES);
}

If these 2 lines (marked with FAILED) are present in the free build, the driver can’t load. If they are not compiled in the free build, the driver loads without problem.
In the checked build, the driver loads with these two lines compiled.

Note that these lines are part of a function that is *NOT* called (I’ve suppressed as much code as possible, including the function calling this function with those lines).
It’s just their presence, not their execution, that is causing the problem.

I’ve tried to disable compiler optimisation in the free build (by setting MSC_OPTIMIZATION value to /Od /Oi in the sources file) without success.

Any idea ?

Thank you,

Arnaud

What is your target OS you are trying to load on? You can always run depends.exe on the target OS and it will tell you the missing exports

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Thursday, March 31, 2011 12:00 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] CM_PROB_DRIVER_FAILED_LOAD only when built in free build environment

Hi,

I’m facing a surprising problem: my NDIS driver failed to load when built in the free build environment but there is no problem when built in the checked build environment.
The error is the following:
#I163 Device not started: Device has problem: 0x27: CM_PROB_DRIVER_FAILED_LOAD.

After many tries, I’ve found 2 lines of code:

IndicateWorkItemContext *iwic = MEMALLOC_S(context->handles.adapter, IndicateWorkItemContext);

if (iwic != NULL)
{
iwic->item = IoAllocateWorkItem (pdo); // FAILED

if (iwic->item != NULL)
{
/* setup the context and queue allocated work item */
iwic->adapter = context->handles.adapter;
iwic->lock = &context->indicate.lock;
iwic->packet = packet;

DBGPRINT(DL_LOG8, " queueing work item %p, context %p", iwic->item, iwic);

IoQueueWorkItem (iwic->item, indicateWorkItemRoutine, DelayedWorkQueue, iwic); // FAILED

DBGFRETP(NDIS_STATUS, NDIS_STATUS_PENDING);
}
else
{
/* error */
DBGPRINT(DL_ERROR, " could not allocate work item");
MEMFREE_S(iwic);
}
}
else
{
/* error */
DBGPRINT(DL_ERROR, " could not allocate memory for work item context");
DBGFRETP(NDIS_STATUS, NDIS_STATUS_RESOURCES);
}

If these 2 lines (marked with FAILED) are present in the free build, the driver can’t load. If they are not compiled in the free build, the driver loads without problem.
In the checked build, the driver loads with these two lines compiled.

Note that these lines are part of a function that is *NOT* called (I’ve suppressed as much code as possible, including the function calling this function with those lines).
It’s just their presence, not their execution, that is causing the problem.

I’ve tried to disable compiler optimisation in the free build (by setting MSC_OPTIMIZATION value to /Od /Oi in the sources file) without success.

Any idea ?

Thank you,

Arnaud


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

The target OS is Windows XP SP3.
depends (I’ve ran if on the .sys driver file) does not show any missing export (as far a I can see). IoAllocateWorkItem and IoQueueWorkItem are exported by the NTOSKRNL.EXE module and flagged as “C export function that resides in the selected module.”, according to the depends documentation.

Arnaud