[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Warnings in mingw64 build on emacs-28 branch
From: |
Óscar Fuentes |
Subject: |
Re: Warnings in mingw64 build on emacs-28 branch |
Date: |
Sun, 07 Nov 2021 16:51:56 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
Eli Zaretskii <eliz@gnu.org> writes:
>> 3) This warning is new with gcc 11.
>>
>> C:/emacs/git/emacs/emacs-28/src/w32heap.c: In function 'getrlimit':
>> C:/emacs/git/emacs/emacs-28/src/w32heap.c:853:14: warning: 'm' may be used
>> uninitialized [-Wmaybe-uninitialized]
>> 853 | if (!VirtualQuery ((LPCVOID) &m, &m, sizeof m))
>> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> In file included from
>> C:/msys64/mingw64/x86_64-w64-mingw32/include/winbase.h:25,
>> from
>> C:/msys64/mingw64/x86_64-w64-mingw32/include/windows.h:70,
>> from C:/emacs/git/emacs/emacs-28/src/w32common.h:24,
>> from C:/emacs/git/emacs/emacs-28/src/w32heap.c:54:
>> C:/msys64/mingw64/x86_64-w64-mingw32/include/memoryapi.h:45:28: note: by
>> argument 1 of type 'LPCVOID' {aka 'const void *'} to 'VirtualQuery' declared
>> here
>> 45 | WINBASEAPI SIZE_T WINAPI VirtualQuery (LPCVOID lpAddress,
>> PMEMORY_BASIC_INFORMATION lpBuffer, SIZE_T dwLength);
>> | ^~~~~~~~~~~~
>> C:/emacs/git/emacs/emacs-28/src/w32heap.c:844:34: note: 'm' declared here
>> 844 | MEMORY_BASIC_INFORMATION m;
>> | ^
>
> That's a compiler bug, I think. I see nothing wrong in the call.
AFAIU that call to VirtualQuery does not do what we want. When lpAddress
is provided the function rounds down the address to a page boundary and
starts scanning pages *up*. Since we want information about the capacity
of the stack, the scan ignores all the space below the current page
boundary.
There is GetCurrentThreadStackLimits, but requires _WIN32_WINNT >=
0x0602 and it works on allocated pages.
OTOH, we could call CreateThread with dwStackSize set to a fixed value
and return that value from getrlimit(RLIMIT_STACK...). However, we need
the main thread's stack size as well...
There is a hack that uses NtCurrentTeb to obtain the lower address of
the stack and pass it to VirtualQuery. I don't know how portable it is
across Windows versions.
- Warnings in mingw64 build on emacs-28 branch, Andy Moreton, 2021/11/07
- Re: Warnings in mingw64 build on emacs-28 branch, Eli Zaretskii, 2021/11/07
- Re: Warnings in mingw64 build on emacs-28 branch,
Óscar Fuentes <=
- Re: Warnings in mingw64 build on emacs-28 branch, Eli Zaretskii, 2021/11/07
- Re: Warnings in mingw64 build on emacs-28 branch, Óscar Fuentes, 2021/11/07
- Re: Warnings in mingw64 build on emacs-28 branch, Eli Zaretskii, 2021/11/07
- Re: Warnings in mingw64 build on emacs-28 branch, Óscar Fuentes, 2021/11/07
- Re: Warnings in mingw64 build on emacs-28 branch, Eli Zaretskii, 2021/11/07
Re: Warnings in mingw64 build on emacs-28 branch, Andy Moreton, 2021/11/07