Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTDEV

Before Posting...

Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


Problem with DbgPrint for W2K

OSR_Community_UserOSR_Community_User Member Posts: 110,217
Hi All,

I have a NDIS driver for Windows 2000. It works fine unless any DbgPrint is
present. If I put any DbgPrint, it crashes with Bug check code 0x50
(PAGE_FAULT_IN_NONPAGED_AREA).
Also if I build my driver with checked environment, I experience the same. I
am using the W2K Beta version of the Debug build. Can it be the cause? Can
anyone please clarify?
The configuration is :-
Windows 2000 Professional
Checked/Debug build, Beta 3
Release Candidate 1 (x86), Build 2000

Regards,
Abhijit

Comments

  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    Hi abhijit,
    I faced the similar problem.It's surprising that the DbgPrints can cause the crash....
    and It took me a One full day to determine that.
    Ajitabh

    -----Original Message-----
    From: Abhijit Mirajkar [SMTP:[email protected]]
    Sent: Thursday, May 11, 2000 10:09 AM
    To: NT Developers Interest List
    Subject: [ntdev] Problem with DbgPrint for W2K

    Hi All,

    I have a NDIS driver for Windows 2000. It works fine unless any DbgPrint is
    present. If I put any DbgPrint, it crashes with Bug check code 0x50
    (PAGE_FAULT_IN_NONPAGED_AREA).
    Also if I build my driver with checked environment, I experience the same. I
    am using the W2K Beta version of the Debug build. Can it be the cause? Can
    anyone please clarify?
    The configuration is :-
    Windows 2000 Professional
    Checked/Debug build, Beta 3
    Release Candidate 1 (x86), Build 2000

    Regards,
    Abhijit


    ---
    You are currently subscribed to ntdev as: [email protected]
    To unsubscribe send a blank email to $subst('Email.Unsub')
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    First question: Is there a reason you're using RC1?

    What you may have is a stack overflow issue.

    We've seen problems in the 9x world where we had a stack overflow issue that
    occurred more frequently in the checked build of the driver. The reason for
    this was the DbgPrint's in the checked build.

    Daniel

    -----Original Message-----
    From: Ajitabh Prakash [mailto:[email protected]]
    Sent: Wednesday, May 10, 2000 9:45 PM
    To: NT Developers Interest List
    Subject: [ntdev] RE: Problem with DbgPrint for W2K


    Hi abhijit,
    I faced the similar problem.It's surprising that the DbgPrints can
    cause the crash....
    and It took me a One full day to determine that.
    Ajitabh

    -----Original Message-----
    From: Abhijit Mirajkar [SMTP:[email protected]]
    Sent: Thursday, May 11, 2000 10:09 AM
    To: NT Developers Interest List
    Subject: [ntdev] Problem with DbgPrint for W2K

    Hi All,

    I have a NDIS driver for Windows 2000. It works fine unless any DbgPrint is
    present. If I put any DbgPrint, it crashes with Bug check code 0x50
    (PAGE_FAULT_IN_NONPAGED_AREA).
    Also if I build my driver with checked environment, I experience the same. I
    am using the W2K Beta version of the Debug build. Can it be the cause? Can
    anyone please clarify?
    The configuration is :-
    Windows 2000 Professional
    Checked/Debug build, Beta 3
    Release Candidate 1 (x86), Build 2000

    Regards,
    Abhijit


    ---
    You are currently subscribed to ntdev as: [email protected]
    To unsubscribe send a blank email to $subst('Email.Unsub')


    ---
    You are currently subscribed to ntdev as: [email protected]
    To unsubscribe send a blank email to $subst('Email.Unsub')
  • OSR_Community_User-48OSR_Community_User-48 Member Posts: 74
    The problem, as I understand it, is that the UNICODE<->ANSI traslation
    tables are in pageable memory. So if you are doing a DbgPrint that
    needs access the tables and you are running at an elevated IRQL, then
    you will bugcheck if the translation tables you need are paged out.

    -----Original Message-----
    From: Ajitabh Prakash [mailto:[email protected]]
    Sent: Wednesday, May 10, 2000 9:45 PM
    To: NT Developers Interest List
    Subject: [ntdev] RE: Problem with DbgPrint for W2K


    Hi abhijit,
    I faced the similar problem.It's surprising that the DbgPrints
    can cause the crash....
    and It took me a One full day to determine that.
    Ajitabh

    -----Original Message-----
    From: Abhijit Mirajkar [SMTP:[email protected]]
    Sent: Thursday, May 11, 2000 10:09 AM
    To: NT Developers Interest List
    Subject: [ntdev] Problem with DbgPrint for W2K

    Hi All,

    I have a NDIS driver for Windows 2000. It works fine unless any DbgPrint
    is
    present. If I put any DbgPrint, it crashes with Bug check code 0x50
    (PAGE_FAULT_IN_NONPAGED_AREA).
    Also if I build my driver with checked environment, I experience the
    same. I
    am using the W2K Beta version of the Debug build. Can it be the cause?
    Can
    anyone please clarify?
    The configuration is :-
    Windows 2000 Professional
    Checked/Debug build, Beta 3
    Release Candidate 1 (x86), Build 2000

    Regards,
    Abhijit


    ---
    You are currently subscribed to ntdev as: [email protected]
    To unsubscribe send a blank email to $subst('Email.Unsub')


    ---
    You are currently subscribed to ntdev as: [email protected]
    To unsubscribe send a blank email to $subst('Email.Unsub')
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    RE: [ntdev] RE: Problem with DbgPrint for W2KSo is there an unwritten rule
    that DbgPrint() must be running at < DISPATCH_LEVEL? Is this something that
    you only have to worry about when you have a WCHAR in the DbgPrint()
    statement?

    Alan
    -----Original Message-----
    From: [email protected]
    [mailto:[email protected]]On Behalf Of Nathan Nesbit
    Sent: Thursday, May 11, 2000 11:47 AM
    To: NT Developers Interest List
    Subject: [ntdev] RE: Problem with DbgPrint for W2K


    The problem, as I understand it, is that the UNICODE<->ANSI traslation
    tables are in pageable memory. So if you are doing a DbgPrint that needs
    access the tables and you are running at an elevated IRQL, then you will
    bugcheck if the translation tables you need are paged out.

    -----Original Message-----
    From: Ajitabh Prakash [mailto:[email protected]]
    Sent: Wednesday, May 10, 2000 9:45 PM
    To: NT Developers Interest List
    Subject: [ntdev] RE: Problem with DbgPrint for W2K



    Hi abhijit,
    I faced the similar problem.It's surprising that the DbgPrints can
    cause the crash....
    and It took me a One full day to determine that.
    Ajitabh

    -----Original Message-----
    From: Abhijit Mirajkar [SMTP:[email protected]]
    Sent: Thursday, May 11, 2000 10:09 AM
    To: NT Developers Interest List
    Subject: [ntdev] Problem with DbgPrint for W2K

    Hi All,

    I have a NDIS driver for Windows 2000. It works fine unless any DbgPrint
    is
    present. If I put any DbgPrint, it crashes with Bug check code 0x50
    (PAGE_FAULT_IN_NONPAGED_AREA).
    Also if I build my driver with checked environment, I experience the same.
    I
    am using the W2K Beta version of the Debug build. Can it be the cause? Can
    anyone please clarify?
    The configuration is :-
    Windows 2000 Professional
    Checked/Debug build, Beta 3
    Release Candidate 1 (x86), Build 2000

    Regards,
    Abhijit



    ---
    You are currently subscribed to ntdev as: [email protected]
    To unsubscribe send a blank email to $subst('Email.Unsub')



    ---
    You are currently subscribed to ntdev as: [email protected]
    To unsubscribe send a blank email to $subst('Email.Unsub')
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    DpgPrint() as any other function cannot touch pageable memory when running
    on DISPATCH_LEVEL and above. Unfortunately, wide character formating (i.e.
    %ws, %wZ...) has a side effect which Nathan described. I think it isn't
    documented but checked build informs you about it (via assert) immediatelly.
    Free build crashes only when translation tables are paged out which can
    occur randomly.

    Best regards,

    Michal Vodicka
    RKK Informationssysteme s.r.o.
    :We support your Future
    [WWW: http://www.rkk.cz , http://www.skytale.com]



    > ----------
    > From: Alan L. Taylor[SMTP:[email protected]]
    > Reply To: NT Developers Interest List
    > Sent: Thursday, May 11, 2000 7:35 PM
    > To: NT Developers Interest List
    > Subject: [ntdev] RE: Problem with DbgPrint for W2K
    >
    > So is there an unwritten rule that DbgPrint() must be running at <
    > DISPATCH_LEVEL?? Is this something that you only have to worry about when
    > you have a WCHAR in the DbgPrint() statement??
    > ?
    > Alan
    >
    > -----Original Message-----
    > From: [email protected]
    > [mailto:[email protected]]On Behalf Of Nathan Nesbit
    > Sent: Thursday, May 11, 2000 11:47 AM
    > To: NT Developers Interest List
    > Subject: [ntdev] RE: Problem with DbgPrint for W2K
    >
    >
    >
    > The problem, as I understand it, is that the UNICODE<->ANSI
    > traslation tables are in pageable memory.? So if you are doing a DbgPrint
    > that needs access the tables and you are running at an elevated IRQL, then
    > you will bugcheck if the translation tables you need are paged out.
    >
    >
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    From: "Alan L. Taylor" <[email protected]>
    Sent: Thursday, May 11, 2000 1:35 PM


    > RE: [ntdev] RE: Problem with DbgPrint for W2KSo is there an unwritten rule
    > that DbgPrint() must be running at < DISPATCH_LEVEL?

    Not entirely "unwritten". The DDK documentation for KdPrint() says:

    "The Format string supports the printf-style formatting codes. However,
    the unicode format codes (%wc and %ws) can only be used at IRQL
    PASSIVE_LEVEL."

    Anyone familiar with DDK programming of course knows that KdPrint() is
    simply a pre-processor alias for DbgPrint().

    So, while the DDK docs for DbgPrint() for some reason do not have the same
    PASSIVE_LEVEL comment as those for KdPrint(), we must assume that the
    comment "really" applies to DbgPrint().

    > Is this something that
    > you only have to worry about when you have a WCHAR in the DbgPrint()
    > statement?

    AFAIK, basically yes.

    - Matt
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    While I suppose it is in fact semi-documented, this has got to be considered
    a rather colossal bug. How much nonpaged pool is being saved here? 1 page?
    2?

    >
    > From: "Alan L. Taylor" <[email protected]>
    > Sent: Thursday, May 11, 2000 1:35 PM
    >
    >
    > > RE: [ntdev] RE: Problem with DbgPrint for W2KSo is there an
    > unwritten rule
    > > that DbgPrint() must be running at < DISPATCH_LEVEL?
    >
    > Not entirely "unwritten". The DDK documentation for KdPrint() says:
    >
    > "The Format string supports the printf-style formatting
    > codes. However,
    > the unicode format codes (%wc and %ws) can only be used at IRQL
    > PASSIVE_LEVEL."
    >
    > Anyone familiar with DDK programming of course knows that KdPrint() is
    > simply a pre-processor alias for DbgPrint().
    >
    > So, while the DDK docs for DbgPrint() for some reason do not
    > have the same
    > PASSIVE_LEVEL comment as those for KdPrint(), we must assume that the
    > comment "really" applies to DbgPrint().
    >
    > > Is this something that
    > > you only have to worry about when you have a WCHAR in the DbgPrint()
    > > statement?
    >
    > AFAIK, basically yes.
    >
  • Paul_BunnPaul_Bunn Member Posts: 251
    Good point Mark. This is probably left over from the days of a 64MB memory
    being defined in the kernel as a "large memory system". ha !

    Or it could be just an oversight made by an overly frugal kernel engineer.

    Either way, it sucks...

    Regards,

    Paul Bunn, UltraBac.com, 425-644-6000
    Microsoft MVP - WindowsNT/2000
    http://www.ultrabac.com


    -----Original Message-----
    From: Roddy, Mark [mailto:[email protected]]
    Sent: Thursday, May 11, 2000 1:20 PM
    To: NT Developers Interest List
    Subject: [ntdev] RE: Problem with DbgPrint for W2K



    While I suppose it is in fact semi-documented, this has got to be considered
    a rather colossal bug. How much nonpaged pool is being saved here? 1 page?
    2?

    >
    > From: "Alan L. Taylor" <[email protected]>
    > Sent: Thursday, May 11, 2000 1:35 PM
    >
    >
    > > RE: [ntdev] RE: Problem with DbgPrint for W2KSo is there an
    > unwritten rule
    > > that DbgPrint() must be running at < DISPATCH_LEVEL?
    >
    > Not entirely "unwritten". The DDK documentation for KdPrint() says:
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    This disadvantage is because of this:

    OSLOADER (part of NTLDR) loads proper nls files (l_intl.nls + c_xxxx.nls)
    to loader block. Then passes pointer to loader block to the NTOSKRNL's
    main function. Kernel first initializes NlsXxxx variables to point to the
    loader block - which is nonpageable. After memory manager initialization
    the unnamed section is created, intialized from loader block and some views
    are mapped into system cache memory space. These views are in turn
    pageable and can be swapped out (and some are). Some NlsXxxx variables
    are reinitialized at this time to new values. All drivers are initialized
    after this so it is possible for some critical nls pages to be outswapped.
    If such a page is touched by some Rtl conversion routine at raised IRQL
    all of you can imagine what will be the result.

    Paul

    > -----P?vodn? zpr?va-----
    > Od: Paul Bunn [SMTP:[email protected]]
    > Odesl?no: 11. kv?tna 2000 22:28
    > Komu: NT Developers Interest List
    > P?edm?t: [ntdev] RE: Problem with DbgPrint for W2K
    >
    > Good point Mark. This is probably left over from the days of a 64MB
    > memory
    > being defined in the kernel as a "large memory system". ha !
    >
    > Or it could be just an oversight made by an overly frugal kernel engineer.
    >
    > Either way, it sucks...
    >
    > Regards,
    >
    > Paul Bunn, UltraBac.com, 425-644-6000
    > Microsoft MVP - WindowsNT/2000
    > http://www.ultrabac.com
    >
    >
    > -----Original Message-----
    > From: Roddy, Mark [mailto:[email protected]]
    > Sent: Thursday, May 11, 2000 1:20 PM
    > To: NT Developers Interest List
    > Subject: [ntdev] RE: Problem with DbgPrint for W2K
    >
    >
    >
    > While I suppose it is in fact semi-documented, this has got to be
    > considered
    > a rather colossal bug. How much nonpaged pool is being saved here? 1 page?
    > 2?
    >
    > >
    > > From: "Alan L. Taylor" <[email protected]>
    > > Sent: Thursday, May 11, 2000 1:35 PM
    > >
    > >
    > > > RE: [ntdev] RE: Problem with DbgPrint for W2KSo is there an
    > > unwritten rule
    > > > that DbgPrint() must be running at < DISPATCH_LEVEL?
    > >
    > > Not entirely "unwritten". The DDK documentation for KdPrint() says:
    >
    > ---
    > You are currently subscribed to ntdev as: [email protected]
    > To unsubscribe send a blank email to $subst('Email.Unsub')
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    RE: [ntdev] RE: Problem with DbgPrint for W2K>So is there an unwritten rule
    that DbgPrint() must be running at <
    >DISPATCH_LEVEL? Is this something that you only have to worry about
    >when you have a WCHAR in the DbgPrint() statement?

    AFAIK only if you have a Unicode format specifier (%wZ or %zW - I've
    forgotten) in DbgPrint.
    Without it, DbgPrint works fine even in ISRs.

    Max
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    > While I suppose it is in fact semi-documented, this has got to be
    considered
    > a rather colossal bug. How much nonpaged pool is being saved here? 1 page?
    > 2?

    More :-) UNICODE.NLS on my machine (NT4/SP6) is about 87KB in size.
    And this is not the only NLS table.

    Max
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    This disadvantage is because of this:

    OSLOADER (part of NTLDR) loads proper nls files (l_intl.nls + c_xxxx.nls)
    to loader block. Then passes pointer to loader block to the NTOSKRNL's
    main function. Kernel first initializes NlsXxxx variables to point to the
    loader block - which is nonpageable. After memory manager initialization
    the unnamed section is created, intialized from loader block and some views
    are mapped into system cache memory space. These views are in turn
    pageable and can be swapped out (and some are). Some NlsXxxx variables
    are reinitialized at this time to new values. All drivers are initialized
    after this so it is possible for some critical nls pages to be outswapped.
    If such a page is touched by some Rtl conversion routine at raised IRQL
    all of you can imagine what will be the result.

    Paul

    > -----P?vodn? zpr?va-----
    > Od: Paul Bunn [SMTP:[email protected]]
    > Odesl?no: 11. kv?tna 2000 22:28
    > Komu: NT Developers Interest List
    > P?edm?t: [ntdev] RE: Problem with DbgPrint for W2K
    >
    > Good point Mark. This is probably left over from the days of a 64MB
    > memory
    > being defined in the kernel as a "large memory system". ha !
    >
    > Or it could be just an oversight made by an overly frugal kernel engineer.
    >
    > Either way, it sucks...
    >
    > Regards,
    >
    > Paul Bunn, UltraBac.com, 425-644-6000
    > Microsoft MVP - WindowsNT/2000
    > http://www.ultrabac.com
    >
    >
    > -----Original Message-----
    > From: Roddy, Mark [mailto:[email protected]]
    > Sent: Thursday, May 11, 2000 1:20 PM
    > To: NT Developers Interest List
    > Subject: [ntdev] RE: Problem with DbgPrint for W2K
    >
    >
    >
    > While I suppose it is in fact semi-documented, this has got to be
    > considered
    > a rather colossal bug. How much nonpaged pool is being saved here? 1 page?
    > 2?
    >
    > >
    > > From: "Alan L. Taylor" <[email protected]>
    > > Sent: Thursday, May 11, 2000 1:35 PM
    > >
    > >
    > > > RE: [ntdev] RE: Problem with DbgPrint for W2KSo is there an
    > > unwritten rule
    > > > that DbgPrint() must be running at < DISPATCH_LEVEL?
    > >
    > > Not entirely "unwritten". The DDK documentation for KdPrint() says:
    >
    > ---
    > You are currently subscribed to ntdev as: [email protected]
    > To unsubscribe send a blank email to $subst('Email.Unsub')
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Kernel Debugging 13-17 May 2024 Live, Online
Developing Minifilters 1-5 Apr 2024 Live, Online
Internals & Software Drivers 11-15 Mar 2024 Live, Online
Writing WDF Drivers 20-24 May 2024 Live, Online