Is it possible for vDbgPrintEx to print the same string twice?

I add something to print by vDbgPrintEx in the driver and use WinDBG to watch the messages. Now sometimes, I get exactly the same message twice, one right after another, which should only print once. Is it possible for this to happen? Or there should be something wrong with my code.

Is the line number continuous ?

Yes. Same messages in two continuous lines.

It’s your code.

Mark Roddy

On Fri, Dec 15, 2017 at 2:27 AM, xxxxx@gmail.com
wrote:

> Yes. Same messages in two continuous lines.
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: http:> showlists.cfm?list=ntdev>
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
> software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at <
> http://www.osronline.com/page.cfm?name=ListServer&gt;
></http:></http:>

Um, clearly yes. If it certainly possible that two consecutive debug messages have the same string.

What you probably want to know is if it is possible to erroneously print the same line twice due to some bug or limitation in the design or implementation of this function. A key point here is about the theoretically impossible nature of exactly correlating events from multiple CPUs via this type of logging, but what you can say for sure is that the sequence of events from a single producing thread (CPU) should be correct.

When there are multiple threads (CPUs) involved, the logging function must aggregate the information in some order ? which may not necessarily be the same order in which the instructions to generate the information have been executed in terms of wall clock time. This is clearly due to the necessity that lock acquisition order (or the forward progress of a given thread in a lock free algorithm) is non deterministic. Assuming the semantics are correct, it will get in to the log eventually, but after some unbounded delay

This may be a totally of topic reply however. Perhaps if you told us more about what you are seeing we could help you interpret it better. Remember the old adage that a problem well stated is a problem nearly solved.

Sent from Mailhttps: for Windows 10

________________________________
From: xxxxx@lists.osr.com on behalf of xxxxx@foxmail.com
Sent: Friday, December 15, 2017 1:41:35 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Is it possible for vDbgPrintEx to print the same string twice?

Is the line number continuous ?


NTDEV is sponsored by OSR

Visit the list online at: http:

MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
Details at http:

To unsubscribe, visit the List Server section of OSR Online at http:</http:></http:></http:></https:>

Code is like this:
Function remove from list()
{
WdfSpinLockAcquire
remove a node from list
check node’s state to be “added to list” and print error if not.
set node state to “remove from list”
vDbgPrintEx( “get the node and the address for the node memory”)
WdfSpinLockRelease
}

Function add to list()
{
WdfSpinLockAcquire
check node’s state to be “remove from list” and print error if not.
set node state to “added to list”
add a node to list
vDbgPrintEx( “put the node the address for the node memory”)
WdfSpinLockRelease
}

And I got print like this:

  1. get new node FFFFE002B79370A0
  2. put node FFFFE002B79370A0
  3. get new node FFFFE002B79370A0
  4. get new node FFFFE002B79370A0
  5. Put node FFFFE002B79370A0
  6. get new node FFFFE002B79370A0
  7. Put node FFFFE002B79370A0

Line 8 and 9 are exactly the same in contiguous two lines. But there’s no error reported in the state check in both functions. So I suppose vDbgPrintEx may print twice…

Well I’m convinced. Couldn’t possible be your new code, must be this other
code that has been around for like 40 years.

Mark Roddy

On Mon, Dec 18, 2017 at 10:07 PM, xxxxx@gmail.com
wrote:

> Code is like this:
> Function remove from list()
> {
> WdfSpinLockAcquire
> remove a node from list
> check node’s state to be “added to list” and print error if not.
> set node state to “remove from list”
> vDbgPrintEx( “get the node and the address for the node memory”)
> WdfSpinLockRelease
> }
>
> Function add to list()
> {
> WdfSpinLockAcquire
> check node’s state to be “remove from list” and print error if not.
> set node state to “added to list”
> add a node to list
> vDbgPrintEx( “put the node the address for the node memory”)
> WdfSpinLockRelease
> }
>
> And I got print like this:
> 1. get new node FFFFE002B79370A0
> 2. …
> 5. put node FFFFE002B79370A0
> 6. …
> 8. get new node FFFFE002B79370A0
> 9. get new node FFFFE002B79370A0
> 10. …
> 13. Put node FFFFE002B79370A0
> 14. …
> 15. get new node FFFFE002B79370A0
> 16. …
> 19. Put node FFFFE002B79370A0
>
> Line 8 and 9 are exactly the same in contiguous two lines. But there’s no
> error reported in the state check in both functions. So I suppose
> vDbgPrintEx may print twice…
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: http:> showlists.cfm?list=ntdev>
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
> software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at <
> http://www.osronline.com/page.cfm?name=ListServer&gt;
></http:></http:>

On Dec 18, 2017, at 7:07 PM, xxxxx@gmail.com wrote:
>
> Code is like this:

Show us the EXACT code, not a transcript. It’s way to easy to omit what you think are important details when you summarize like this.

Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.