public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: Duplicates in /proc/partitions
Date: Thu, 19 Aug 2021 13:26:01 +0200	[thread overview]
Message-ID: <YR4/yRCTTTz/nXXl@calimero.vinschen.de> (raw)
In-Reply-To: <YR4sYNqO+bVYuCHd@calimero.vinschen.de>

On Aug 19 12:03, Corinna Vinschen via Cygwin wrote:
> On Aug 18 18:36, Lavrentiev, Anton (NIH/NLM/NCBI) [C] via Cygwin wrote:
> > > And I just confirmed that if I print the context right before NtOpenFile(), and just do
> > > the "continue",
> > 
> > But then I also tried this:  I removed the "continue" before "NtOpenFile()" and allowed it to proceed,
> > but I moved NtClose(devhdl) right after the "printf" statement (that we were tweaking), and
> > inserted the "continue" there, so it does not proceed with enumerating of the partitions.
> > And so again, I got the output that matches my disks without the duplication.  So this actually
> > exonerates NtOpenFile() :-)
> > [...]
> 
> Unfortunately I can't reproduce the issue.  I created a couple of
> virtual drives and added them to my W10 and my W7 VM, but to no avail.

Never mind.  I now can reproduce the problem at will.  The trick is to
create objects inside the \Device directory while the loop iterating
over the directory is running.

As shitty as it is, a NtOpenDirectoryObject/NtQueryDirectoryObject/NtClose
loop is not working atomically.  If a new object is inserted into the
dir preceeding the currently handled entry (which, on a reliable system
should *never* occur), the entry is moved by one, and the next
NtQueryDirectoryObject call returns the same object again.

Windows never disappoints when one is looking for really ugly problems.

The good news is that NtQueryDirectoryObject is also capable to take a
big buffer and return as much entries as fit in in the buffer.  I'll
give it a try now in the vain hope that this way to call
NtQueryDirectoryObject returns reliable, atomic-like results...


Corinna

  reply	other threads:[~2021-08-19 11:26 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-13 10:56 David Balažic
2021-08-13 15:17 ` Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2021-08-16 14:51 ` Corinna Vinschen
2021-08-16 16:56   ` Brian Inglis
2021-08-16 17:23     ` Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2021-08-16 18:49     ` Corinna Vinschen
2021-08-16 21:54       ` Brian Inglis
2021-08-17 12:57       ` Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2021-08-17 13:51         ` Corinna Vinschen
2021-08-18 14:18           ` Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2021-08-18 15:01             ` Corinna Vinschen
2021-08-18 18:18               ` Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2021-08-18 18:27                 ` Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2021-08-18 18:36                   ` Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2021-08-19 10:03                     ` Corinna Vinschen
2021-08-19 11:26                       ` Corinna Vinschen [this message]
2021-08-19 14:48                         ` Corinna Vinschen
2021-08-19 15:15                           ` Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2021-08-19 15:37                             ` Corinna Vinschen
2021-08-19 15:46                               ` Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2021-08-19 19:19                                 ` Corinna Vinschen
2021-08-19  9:37                 ` Corinna Vinschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YR4/yRCTTTz/nXXl@calimero.vinschen.de \
    --to=corinna-cygwin@cygwin.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).