https://bugs.winehq.org/show_bug.cgi?id=53960
Bug ID: 53960 Summary: ucrt has different struct layout than msvcrt Product: Wine Version: unspecified Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: msvcrt Assignee: wine-bugs@winehq.org Reporter: euloanty@live.com Distribution: ---
https://bugs.winehq.org/show_bug.cgi?id=51698
I found that bug before it was actually because UCRT definition of struct _iobuf in wine is just wrong.
This is a serious abi issue that has to be fixed and that is also probably why UCRT programs do not work very well on wine.
/* referenced from win10sdk ucrt C:\Program Files (x86)\Windows Kits\10\Source\10.0.19041.0\ucrt //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ // // Internal Stream Types (__crt_stdio_stream and friends) // //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ // Ensure that __crt_stdio_stream_data* and FILE* pointers are freely convertible: struct ucrt_stdio_stream_data { union { FILE public_file; char* ptr; }; char* base; int cnt; long flags; long file; int charbuf; int bufsiz; char* tmpfname; };
The definition of UCRT is
struct #if __has_cpp_attribute(__gnu__::__may_alias__) [[__gnu__::__may_alias__]] #endif ucrt_iobuf { char* _ptr; char* _base; int _cnt; long _flag; long _file; int _charbuf; int _bufsiz; char* _tmpfname; };
while msvcrt is
struct #if __has_cpp_attribute(__gnu__::__may_alias__) [[__gnu__::__may_alias__]] #endif ucrt_iobuf { char* _ptr; int _cnt; char* _base; int _flag; int _file; int _charbuf; int _bufsiz; char* _tmpfname; };
The location of _base and _cnt swaps.