Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash on WinPE #163

Open
wants to merge 2 commits into
base: msys2-3.4.7
Choose a base branch
from
Open

Conversation

lesderid
Copy link

Native RAM disks, e.g. as are used in WinPE environments, have other characteristics than regular filesystems such as NTFS. For instance, re-opening files with NtOpenFile is buggy. This can cause a bugcheck with the current implementation of mmap.

The first commit adds RAM disk detection. The second commit uses init_reopen_attr in mmap to circumvent the re-opening bug.

Fixes #160

lesderid added 2 commits July 14, 2023 00:50
Native RAM disks, e.g. as are used in WinPE environments, have other
characteristics than regular filesystems such as NTFS. For instance,
re-opening files with NtOpenFile is buggy.

This commit checks whether a volume is a RAM disk through the NT object
the drive letter link refers to. This seems to be the only reliable
method of checking whether a volume is a native RAM disk.
Calling mmap on a file stored on a volume with buggy file re-opening
currently bugchecks. This commit solves this by using the
init_reopen_attr helper function.

Fixes msys2#160
@lesderid
Copy link
Author

lesderid commented Jul 13, 2023

This should probably be submitted upstream to Cygwin, but I don't have time for this right now.

I've submitted this upstream.

@dscho
Copy link
Collaborator

dscho commented Aug 14, 2023

This should probably be submitted upstream to Cygwin, but I don't have time for this right now.

I've submitted this upstream.

For lurkers, the submission can be seen here: https://inbox.sourceware.org/cygwin-patches/[email protected]/

@lesderid
Copy link
Author

It might be a while before I can address the review comments, but the patch does work as-is.

@jeremyd2019
Copy link
Member

what ever became of this?

@dscho
Copy link
Collaborator

dscho commented Feb 5, 2025

what ever became of this?

In https://inbox.sourceware.org/cygwin-patches/[email protected]/, Corinna pointed out that the conditions under which reopen is assumed to be buggy were way to broad (read: they would have changed behavior in many setups where no change of behavior was necessary at all) and made a couple of good suggestions how to improve the patches (re-use already-figured-out information, move code to a more appropriate location), and that's the last word on the list, there was no reply by @lesderid so far.

@lesderid
Copy link
Author

lesderid commented Feb 5, 2025

there was no reply by @lesderid so far.

I found some other issues with the first patch and sadly haven't had the time yet to look into it. The second one should be good to go.

@dscho
Copy link
Collaborator

dscho commented Feb 5, 2025

The second one should be good to go.

@lesderid You may want to reply to Corinna's mail so that she is aware of your answer, too. We here in the MSYS2 project have no permission to apply patches to Cygwin.

status = NtOpenFile (&h,
fh->get_access () | GENERIC_EXECUTE | SYNCHRONIZE,
&attr, &io, FILE_SHARE_VALID_FLAGS,
fh->pc.init_reopen_attr (attr, h), &io,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be:

Suggested change
fh->pc.init_reopen_attr (attr, h), &io,
fh->pc.init_reopen_attr (attr, fh->get_handle ()), &io,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Some executables cause BSOD in WinPE
3 participants