Skip to content

Commit 505f719

Browse files
vtjnashJeffBezanson
authored andcommitted
win64-debug: relax 32-bit reservation requirement
I've been encountering this assertion consistently now on recent versions of Windows 10, so make it non-fatal as it is not essential.
1 parent 8e65833 commit 505f719

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

ui/repl.c

+6-16
Original file line numberDiff line numberDiff line change
@@ -169,22 +169,9 @@ int main(int argc, char *argv[])
169169
uv_setup_args(argc, argv); // no-op on Windows
170170
#else
171171

172-
#if defined(_P64) && defined(JL_DEBUG_BUILD)
173-
static int is_running_under_wine()
174-
{
175-
static const char * (CDECL *pwine_get_version)(void);
176-
HMODULE hntdll = GetModuleHandle("ntdll.dll");
177-
assert(hntdll);
178-
pwine_get_version = (void *)GetProcAddress(hntdll, "wine_get_version");
179-
return pwine_get_version != 0;
180-
}
181-
#endif
182-
183172
static void lock_low32() {
184173
#if defined(_P64) && defined(JL_DEBUG_BUILD)
185174
// Wine currently has a that causes it to answer VirtualQuery incorrectly.
186-
// See https://www.winehq.org/pipermail/wine-devel/2016-March/112188.html for details
187-
int under_wine = is_running_under_wine();
188175
// block usage of the 32-bit address space on win64, to catch pointer cast errors
189176
char *const max32addr = (char*)0xffffffffL;
190177
SYSTEM_INFO info;
@@ -198,16 +185,19 @@ static void lock_low32() {
198185
if (meminfo.State == MEM_FREE) { // reserve all free pages in the first 4GB of memory
199186
char *first = (char*)meminfo.BaseAddress;
200187
char *last = first + meminfo.RegionSize;
201-
char *p;
202188
if (last > max32addr)
203189
last = max32addr;
204190
// adjust first up to the first allocation granularity boundary
205191
// adjust last down to the last allocation granularity boundary
206192
first = (char*)(((long long)first + info.dwAllocationGranularity - 1) & ~(info.dwAllocationGranularity - 1));
207193
last = (char*)((long long)last & ~(info.dwAllocationGranularity - 1));
208194
if (last != first) {
209-
p = VirtualAlloc(first, last - first, MEM_RESERVE, PAGE_NOACCESS); // reserve all memory in between
210-
assert(under_wine || p == first);
195+
void *p = VirtualAlloc(first, last - first, MEM_RESERVE, PAGE_NOACCESS); // reserve all memory in between
196+
if ((char*)p != first)
197+
// Wine and Windows10 seem to have issues with reporting memory access information correctly
198+
// so we sometimes end up with unexpected results - this is just ignore those and continue
199+
// this is just a debugging aid to help find accidental pointer truncation anyways, so it's not critical
200+
VirtualFree(p, 0, MEM_RELEASE);
211201
}
212202
}
213203
meminfo.BaseAddress += meminfo.RegionSize;

0 commit comments

Comments
 (0)