Skip to content

Cleanup most usages of Windows file mapping#121896

Open
huoyaoyuan wants to merge 30 commits intodotnet:mainfrom
huoyaoyuan:pal/mmap
Open

Cleanup most usages of Windows file mapping#121896
huoyaoyuan wants to merge 30 commits intodotnet:mainfrom
huoyaoyuan:pal/mmap

Conversation

@huoyaoyuan
Copy link
Copy Markdown
Member

The remaining cases are superpmi (included in #121367) and PEImage, which involves LoadLibrary and we would want more future-proof abstraction.

All the cases included in this PR are transitively used by ilasm/ildasm. For stgio, I'm doing simple ifdef's on OS api, since it's too complicated around different I/O models, and we would get rid of it with new metadata library.

@github-actions github-actions Bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Nov 22, 2025
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Nov 22, 2025
@huoyaoyuan huoyaoyuan added area-PAL-coreclr only for closed issues and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Nov 22, 2025
#ifdef HOST_WINDOWS
#define MEMORY_MAPPED_STRESSLOG_BASE_ADDRESS (void*)0x400000000000
#else
#define MEMORY_MAPPED_STRESSLOG_BASE_ADDRESS nullptr
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this removing support for memory mapped stresslog on non-Windows?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes. NativeAOT copy of stresslog removes memory map support on all platforms. I haven't measured the impact.

Comment thread src/coreclr/minipal/dn-memmap.h Outdated
Comment thread src/coreclr/minipal/dn-memmap.h Outdated
Comment thread src/coreclr/minipal/Windows/dn-memmap.cpp
Comment on lines +116 to +117
if (m_File)
delete m_File;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This can just be delete m_File;. Implementations of delete have handled nullptr for over 30 years.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

All of the existing code here are performing null test for delete. Should we prefer consistency here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, please.

Comment thread src/coreclr/ilasm/asmparse.h Outdated
Comment thread src/coreclr/ilasm/asmparse.h Outdated
Comment thread src/coreclr/ildasm/dasm.cpp Outdated
Comment thread src/coreclr/ildasm/ildasmpch.h Outdated
Comment thread src/coreclr/minipal/dn-memmap.h Outdated
Comment thread src/coreclr/minipal/dn-memmap.h Outdated
Comment thread src/coreclr/tools/metainfo/mdobj.cpp Outdated
Comment thread src/coreclr/tools/metainfo/mdobj.cpp Outdated
}
EX_CATCH
{
return nullptr;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
return nullptr;
// Swallow all exceptions.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Or perhaps assert?

@agocke
Copy link
Copy Markdown
Member

agocke commented Mar 23, 2026

@AaronRobinsonMSFT Can you take another look?

@jkotas
Copy link
Copy Markdown
Member

jkotas commented Mar 23, 2026

#121896 (comment) is not addressed. Memory mapped stress log has been used for GC development. cc @dotnet/gc @janvorli

@janvorli
Copy link
Copy Markdown
Member

What is the motivation for removing the memory mapped stress log?

Yes. NativeAOT copy of stresslog removes memory map support on all platforms. I haven't measured the impact.

The memory mapped stress log is a debugging feature that allows accessing a stress log in a running application. I would prefer keeping it working.

@huoyaoyuan
Copy link
Copy Markdown
Member Author

The motivation is just to simplify implementation. I can add it back if necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-PAL-coreclr only for closed issues community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants