Skip to content

Conversation

@huoyaoyuan
Copy link
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 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
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
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 on lines 15 to 18
#ifdef TARGET_WINDOWS
HANDLE m_hFileMapping;
#endif

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#ifdef TARGET_WINDOWS
HANDLE m_hFileMapping;
#endif

This can be deleted from here (close the FileMapping handle at the end of the Open method instead)

Comment on lines +116 to +117
if (m_File)
delete m_File;
Copy link
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
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?

Comment on lines 172 to 173
if (m_File)
delete m_File;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (m_File)
delete m_File;
delete m_File;

0, OPEN_EXISTING, 0, 0);
return (m_hFile == INVALID_HANDLE_VALUE) ? NULL : map_file();
m_File = CreateMappedFile(moduleName);
if (m_File != nullptr && m_File->Size() > UINT_MAX)
Copy link
Member

Choose a reason for hiding this comment

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

Is m_File->Size() > UINT_MAX always needed? It isn't checked on all uses of CreateMappedFile()? Perhaps CreateMappedFile() should be updated for that check instead of using size_t.

Copy link
Member Author

Choose a reason for hiding this comment

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

This would make it loose the ability to load files >4GB in ildasm. It should be none-issue since the PE header has limitation about size anyway.

#include <limits.h>
#include <algorithm>
#include "dn-stdio.h"
#include "dn-memmap.h"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#include "dn-memmap.h"
#include <dn-memmap.h>

Comment on lines 146 to 147
if (f)
delete f;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (f)
delete f;
delete f;


GetMapViewOfFile(szFile, &pbMapAddress, &dwFileSize);
MemoryMappedFile* f = CreateMappedFile(szFile);
if (f == nullptr || f->Size() >= UINT32_MAX)
Copy link
Member

Choose a reason for hiding this comment

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

We should use the same type, UINT32_MAX or UINT_MAX or MAXDWORD. Just be consistent.

}
EX_CATCH
{
return nullptr;
Copy link
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
Member

Choose a reason for hiding this comment

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

Or perhaps assert?

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

Labels

area-PAL-coreclr 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.

3 participants