-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix custom date formats in i686 builds #3626
Conversation
Christoph Reiter reported on the Git for Windows issue tracker[1], that mingw_strftime() imports strftime() from ucrtbase.dll with the wrong calling convention. It should be __cdecl instead of WINAPI, which we always use in DECLARE_PROC_ADDR(). The MSYS2 project encountered cmake sefaults on x86 Windows caused by the same issue in the cmake source. [2] There are no known git crashes that where caused by this, yet, but we should try to prevent them. We import two other non-WINAPI functions via DECLARE_PROC_ADDR(), too. * NtSetSystemInformation() (NTAPI) * GetUserNameExW() (SEC_ENTRY) NTAPI, SEC_ENTRY and WINAPI are all ususally defined as __stdcall, but there are circumstances where they're defined differently. Teach DECLARE_PROC_ADDR() about calling conventions and be explicit about when we want to use which calling convention. Import winnt.h for the definition of NTAPI and sspi.h for SEC_ENTRY near their respective only users. [1] git-for-windows#3560 [2] msys2/MINGW-packages#10152 Reported-By: Christoph Reiter <[email protected]> Signed-off-by: Matthias Aßhauer <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
This is needed because the signature of `DECLARE_PROC_ADDR()` has changed, as per `ma/windows-dynload-fix`. Signed-off-by: Johannes Schindelin <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
@@ -8,7 +8,7 @@ int win32_fsync_no_flush(int fd) | |||
|
|||
#define FLUSH_FLAGS_FILE_DATA_ONLY 1 | |||
|
|||
DECLARE_PROC_ADDR(ntdll.dll, NTSTATUS, NtFlushBuffersFileEx, | |||
DECLARE_PROC_ADDR(ntdll.dll, NTSTATUS, NTAPI, NtFlushBuffersFileEx, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing our NTAPI
definition here comes from winternl.h
here. I used winnt.h
in t/helper/test-drop-caches.c
we might want to make them use the same source at some point in the future, but this isn't urgent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing our
NTAPI
definition here comes fromwinternl.h
here. I usedwinnt.h
int/helper/test-drop-caches.c
we might want to make them use the same source at some point in the future, but this isn't urgent.
winternl.h
#include
s windef.h
, which in turn #include
s winnt.h
.
So there is nothing we need to do here.
Besides, we can allow ourselves to trust the mingw-w64-headers
to not #define
parts as central as NTAPI
in incompatible ways depending which header file you #include
.
Fix custom date formats in i686 builds
Fix custom date formats in i686 builds
Fix custom date formats in i686 builds
Fix custom date formats in i686 builds
Fix custom date formats in i686 builds
Fix custom date formats in i686 builds
Fix custom date formats in i686 builds
Fix custom date formats in i686 builds
Fix custom date formats in i686 builds
Fix custom date formats in i686 builds
Fix custom date formats in i686 builds
Fix custom date formats in i686 builds
Fix custom date formats in i686 builds
Fix custom date formats in i686 builds
Fix custom date formats in i686 builds
Fix custom date formats in i686 builds
Fix custom date formats in i686 builds
Fix custom date formats in i686 builds
Fix custom date formats in i686 builds
Fix custom date formats in i686 builds
Fix custom date formats in i686 builds
Fix custom date formats in i686 builds
In i686 builds, this will crash with a segmentation fault:
(Note that if you try to reproduce this in a regular Git for Windows SDK, you will have to call
make NDEBUG=1
to be able to reproduce the segmentation fault.)The reason is that the
strftime()
function is imported with an incorrect calling convention. It is quite timely that Matthias Aßauer submitted a patch to address precisely this bug, and that contribution already made it into upstream'sseen
branch as thema/windows-dynload-fix
topic (and is slated to be fast-tracked into v2.35.0). This PR backports that topic, along with a fix-up for a patch that has not landed upstream yet so that the result still builds.This fixes #3624