Win7: verifier stops with 0xD1 after KeAcquireSpinLock

I have strange behavior of my driver in windows7 with driver verifier. It traps with DRIVER_IRQL_NOT_LESS_OR_EQUAL every time at next instruction after raising irql with the KeAcquireSpinLock even in DriverEntry. All memory is allocated in nonpaged pool. Without DriverVerifier it works well, and even with verifier but in earlier versions of Windows, such XP. Only Win7 + verifier gives such behavior. Sample code:

void func()
{ // <- traps here!
// do_something
}

void test()
{
KSPIN_LOCK m_lock;
KIRQL m_oldIrql;

KeInitializeSpinLock(&m_lock);
KeAcquireSpinLock(m_lock, &m_oldIrql);
func();
KeReleaseSpinLock(m_lock, m_oldIrql);
}

Hi. You’ve probably

#pragma alloc_text( PAGE, func )

hanging around somewhere in your code?

You should be passing the address of the spin lock to the acquire and
release calls.

Bill Wandel

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@gmail.com
Sent: Friday, September 23, 2011 12:42 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Win7: verifier stops with 0xD1 after KeAcquireSpinLock

I have strange behavior of my driver in windows7 with driver verifier. It
traps with DRIVER_IRQL_NOT_LESS_OR_EQUAL every time at next instruction
after raising irql with the KeAcquireSpinLock even in DriverEntry. All
memory is allocated in nonpaged pool. Without DriverVerifier it works well,
and even with verifier but in earlier versions of Windows, such XP. Only
Win7 + verifier gives such behavior. Sample code:

void func()
{ // <- traps here!
// do_something
}

void test()
{
KSPIN_LOCK m_lock;
KIRQL m_oldIrql;

KeInitializeSpinLock(&m_lock);
KeAcquireSpinLock(m_lock, &m_oldIrql);
func();
KeReleaseSpinLock(m_lock, m_oldIrql);
}


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

Nor alloc_text, not code_seg pragma directives is not used in my code.
Of cource, I passing address instead object, it is a misprint - I wrote example of code instead copy\paste :slight_smile:

I found the bug.

header (ktest.h):

class A
{
void test_func();
};

template
class B : public A
{

}

implementation (ktest.cpp)

void A::test_func()
{
// something to do
}

If I create class B object and call func() in dispatch_level, it traps because all functions from ktest.cpp are in paged code. When I moved it into header file, it was healed.
Such this:

header (ktest.h)

class A
{
void func()
{
// siomething to do
}
};

And this is one of the reasons why previous to the win8 WDK, c++ was use at your own risk

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Monday, September 26, 2011 9:02 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Win7: verifier stops with 0xD1 after KeAcquireSpinLock

I found the bug.

header (ktest.h):

class A
{
void test_func();
};

template
class B : public A
{

}

implementation (ktest.cpp)

void A::test_func()
{
// something to do
}

If I create class B object and call func() in dispatch_level, it traps because all functions from ktest.cpp are in paged code. When I moved it into header file, it was healed.
Such this:

header (ktest.h)

class A
{
void func()
{
// siomething to do
}
};


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

> -----Original Message-----

From: xxxxx@lists.osr.com [mailto:bounce-476385-
xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Monday, September 26, 2011 10:20 PM
To: Windows System Software Devs Interest List
Subject: RE: RE:[ntdev] Win7: verifier stops with 0xD1 after
KeAcquireSpinLock

And this is one of the reasons why previous to the win8 WDK, c++ was use
at your own risk

Am I reading too much into this, or did you just say that C++ will be an
officially supported language for kernel development in the win8 WDK?

Phil

Philip D. Barila

Is there any KB, notes, blogs etc. to stress this point … that I can look at? Also for C#

Would be interesting to try some.

Sorry, but for me —

lim f(t) == 0, where f(t) = explore_c++_ or_ c++ in_win_krnl (t )
t->infinity

-pro

On Sep 26, 2011, at 9:19 PM, Doron Holan wrote:

And this is one of the reasons why previous to the win8 WDK, c++ was use at your own risk

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Monday, September 26, 2011 9:02 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Win7: verifier stops with 0xD1 after KeAcquireSpinLock

I found the bug.

header (ktest.h):

class A
{
void test_func();
};

template
> class B : public A
> {
>
> }
>
> implementation (ktest.cpp)
>
> void A::test_func()
> {
> // something to do
> }
>
>
> If I create class B object and call func() in dispatch_level, it traps because all functions from ktest.cpp are in paged code. When I moved it into header file, it was healed.
> Such this:
>
> header (ktest.h)
>
> class A
> {
> void func()
> {
> // siomething to do
> }
> };
>
> —
> 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
>
>
> —
> 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

Um, no C#

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Prokash Sinha
Sent: Monday, September 26, 2011 9:45 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Win7: verifier stops with 0xD1 after KeAcquireSpinLock

Is there any KB, notes, blogs etc. to stress this point … that I can look at? Also for C#

Would be interesting to try some.

Sorry, but for me —

lim f(t) == 0, where f(t) = explore_c++_ or_ c++ in_win_krnl (t )
t->infinity

-pro

On Sep 26, 2011, at 9:19 PM, Doron Holan wrote:

And this is one of the reasons why previous to the win8 WDK, c++ was use at your own risk

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Monday, September 26, 2011 9:02 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Win7: verifier stops with 0xD1 after KeAcquireSpinLock

I found the bug.

header (ktest.h):

class A
{
void test_func();
};

template
> class B : public A
> {
>
> }
>
> implementation (ktest.cpp)
>
> void A::test_func()
> {
> // something to do
> }
>
>
> If I create class B object and call func() in dispatch_level, it traps because all functions from ktest.cpp are in paged code. When I moved it into header file, it was healed.
> Such this:
>
> header (ktest.h)
>
> class A
> {
> void func()
> {
> // siomething to do
> }
> };
>
> —
> 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
>
>
> —
> 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


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

++ would be fine, I’m not that # anyway :slight_smile:

-pro

On Sep 26, 2011, at 9:51 PM, Doron Holan wrote:

Um, no C#

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Prokash Sinha
Sent: Monday, September 26, 2011 9:45 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Win7: verifier stops with 0xD1 after KeAcquireSpinLock

Is there any KB, notes, blogs etc. to stress this point … that I can look at? Also for C#

Would be interesting to try some.

Sorry, but for me —

lim f(t) == 0, where f(t) = explore_c++_ or_ c++ in_win_krnl (t )
t->infinity

-pro

On Sep 26, 2011, at 9:19 PM, Doron Holan wrote:

> And this is one of the reasons why previous to the win8 WDK, c++ was use at your own risk
>
> d
>
> -----Original Message-----
> From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
> Sent: Monday, September 26, 2011 9:02 PM
> To: Windows System Software Devs Interest List
> Subject: RE:[ntdev] Win7: verifier stops with 0xD1 after KeAcquireSpinLock
>
> I found the bug.
>
> header (ktest.h):
>
> class A
> {
> void test_func();
> };
>
> template
>> class B : public A
>> {
>>
>> }
>>
>> implementation (ktest.cpp)
>>
>> void A::test_func()
>> {
>> // something to do
>> }
>>
>>
>> If I create class B object and call func() in dispatch_level, it traps because all functions from ktest.cpp are in paged code. When I moved it into header file, it was healed.
>> Such this:
>>
>> header (ktest.h)
>>
>> class A
>> {
>> void func()
>> {
>> // siomething to do
>> }
>> };
>>
>> —
>> 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
>>
>>
>> —
>> 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
>
>
> —
> 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
>
>
> —
> 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

Yes, you read that correctly. We announced that a limited subset of C++ will be supported by the dev11 compiler. We explicitly fail the usage of native EH and RTTI. This will include new syntax that will allow you to control the section for an entire class, methods within a class and to partially specialize templates with a section name (which enables a pageable MyListOfStuff and a non pageable MyListOfStuff in a manageable way)

Documentation is being worked on right now

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Philip D. Barila
Sent: Monday, September 26, 2011 9:39 PM
To: Windows System Software Devs Interest List
Subject: RE: RE:[ntdev] Win7: verifier stops with 0xD1 after KeAcquireSpinLock

> -----Original Message-----
> From: xxxxx@lists.osr.com [mailto:bounce-476385-
> xxxxx@lists.osr.com] On Behalf Of Doron Holan
> Sent: Monday, September 26, 2011 10:20 PM
> To: Windows System Software Devs Interest List
> Subject: RE: RE:[ntdev] Win7: verifier stops with 0xD1 after
> KeAcquireSpinLock
>
> And this is one of the reasons why previous to the win8 WDK, c++ was
> use at your own risk

Am I reading too much into this, or did you just say that C++ will be an officially supported language for kernel development in the win8 WDK?

Phil

Philip D. Barila


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

> template class B : public A

Correct, templates are poorly supported in the kernel due to exactly this reason.

You can either get rid of templates or get rid of all PAGED_CODE stuff in all your code.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

Doron
Could the code complied by using Win8 WDK build work on previous version of Windows?

Igor Sharovar

All of the c++ support is in the compiler and linker, not at runtime. We are not adding any new runtime support (ie globally constructed objects still need runtime support provided elsewhere ). That means a sys file built in the w8 wdk using /kernel will run downlevel

d

debt from my phone

-----Original Message-----
From: xxxxx@hotmail.com
Sent: Tuesday, September 27, 2011 9:15 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Win7: verifier stops with 0xD1 after KeAcquireSpinLock

Doron
Could the code complied by using Win8 WDK build work on previous version of Windows?

Igor Sharovar


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