Skip to content

Commit

Permalink
fix memory mapping on Windows (#19623)
Browse files Browse the repository at this point in the history
### Description
<!-- Describe your changes. -->
Windows memory map casts mapped_offset to DWORD directly. It will be
truncated if it is larger than 2^32-1. We need to set high
dwFileOffsetHigh for this case.


### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->

The bug was found from #19450
  • Loading branch information
yufenglee authored Feb 25, 2024
1 parent 0fcc6fb commit 430a086
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions onnxruntime/core/platform/windows/env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,8 @@ Status WindowsEnv::MapFileIntoMemory(_In_z_ const ORTCHAR_T* file_path,

void* const mapped_base = MapViewOfFile(file_mapping_handle.get(),
FILE_MAP_READ,
0,
static_cast<DWORD>(mapped_offset),
static_cast<DWORD>((mapped_offset >> 32) & 0xFFFFFFFF),
static_cast<DWORD>(mapped_offset & 0xFFFFFFFF),
mapped_length);
GSL_SUPPRESS(r.11)
mapped_memory =
Expand Down

0 comments on commit 430a086

Please sign in to comment.