-- v4: msvcrt: Return proper errno for _aligned_msize
From: Bartosz Kosiorek gang65@poczta.onet.pl
--- dlls/msvcr100/tests/msvcr100.c | 22 +++++++++++++++++++++- dlls/msvcrt/heap.c | 9 ++++++--- 2 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/dlls/msvcr100/tests/msvcr100.c b/dlls/msvcr100/tests/msvcr100.c index 7bde5c7935d..090d64589cc 100644 --- a/dlls/msvcr100/tests/msvcr100.c +++ b/dlls/msvcr100/tests/msvcr100.c @@ -175,6 +175,7 @@ struct SchedulerVtbl { };
static int* (__cdecl *p_errno)(void); +static int (__cdecl *p_get_errno)(int *); static int (__cdecl *p_wmemcpy_s)(wchar_t *dest, size_t numberOfElements, const wchar_t *src, size_t count); static int (__cdecl *p_wmemmove_s)(wchar_t *dest, size_t numberOfElements, const wchar_t *src, size_t count); static FILE* (__cdecl *p_fopen)(const char*,const char*); @@ -259,6 +260,7 @@ static BOOL init(void) }
SET(p_errno, "_errno"); + SET(p_get_errno, "_get_errno"); SET(p_set_invalid_parameter_handler, "_set_invalid_parameter_handler"); SET(p_wmemcpy_s, "wmemcpy_s"); SET(p_wmemmove_s, "wmemmove_s"); @@ -640,6 +642,13 @@ static void test__aligned_msize(void) { void *mem; int ret; + errno_t err; + + ret = p__aligned_msize(NULL, 16, 7); + ok(ret == -1, "_aligned_msize returned %d\n", ret); + ret = p_get_errno(&err); + ok(ret == 0, "Expected _get_errno to return 0, got %d\n", ret); + ok(err == EINVAL, "Expected output variable to be EINVAL, got %d\n", err);
mem = p__aligned_offset_malloc(23, 16, 7); ret = p__aligned_msize(mem, 16, 7); @@ -650,8 +659,19 @@ static void test__aligned_msize(void) ok(ret == 28, "_aligned_msize returned %d\n", ret); ret = p__aligned_msize(mem, 1, 7); ok(ret == 39-sizeof(void*), "_aligned_msize returned %d\n", ret); + + /* Test different Offset values */ + ret = p__aligned_msize(mem, 8, 14); + ok(ret == 32, "_aligned_msize returned %d\n", ret); + ret = p__aligned_msize(mem, 8, 8); + ok(ret == 32, "_aligned_msize returned %d\n", ret); + ret = p__aligned_msize(mem, 8, 7); // 31 + ok(ret == 32, "_aligned_msize returned %d\n", ret); // 31 + ret = p__aligned_msize(mem, 8, 5); + ok(ret == 32, "_aligned_msize returned %d\n", ret); ret = p__aligned_msize(mem, 8, 0); - todo_wine ok(ret == 32, "_aligned_msize returned %d\n", ret); + ok(ret == 32, "_aligned_msize returned %d\n", ret); + p__aligned_free(mem);
mem = p__aligned_offset_malloc(3, 16, 0); diff --git a/dlls/msvcrt/heap.c b/dlls/msvcrt/heap.c index bf06c37e2c5..e38ade7f557 100644 --- a/dlls/msvcrt/heap.c +++ b/dlls/msvcrt/heap.c @@ -48,7 +48,7 @@ typedef int (CDECL *MSVCRT_new_handler_func)(size_t size); static MSVCRT_new_handler_func MSVCRT_new_handler; static LONG MSVCRT_new_mode;
-/* FIXME - According to documentation it should be 8*1024, at runtime it returns 16 */ +/* FIXME - According to documentation it should be 8*1024, at runtime it returns 16 */ static unsigned int MSVCRT_amblksiz = 16; /* FIXME - According to documentation it should be 480 bytes, at runtime default is 0 */ static size_t MSVCRT_sbh_threshold = 0; @@ -370,13 +370,16 @@ size_t CDECL _aligned_msize(void *p, size_t alignment, size_t offset) { void **alloc_ptr;
- if(!MSVCRT_CHECK_PMT(p)) return -1; + if(!MSVCRT_CHECK_PMT(p)) + return -1;
if(alignment < sizeof(void*)) alignment = sizeof(void*);
alloc_ptr = SAVED_PTR(p); - return _msize(*alloc_ptr)-alignment-sizeof(void*); + // return _msize(*alloc_ptr) + (offset & 7) - alignment - sizeof(void*); + // memblock = ALIGN_PTR(temp, alignment, offset); + return _msize(*alloc_ptr) - alignment - sizeof(void*); } #endif
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=139384
Your paranoid android.
=== w7u_2qxl (32 bit report) ===
Report validation errors: msvcr100:msvcr100 crashed (c0000417)
=== w7u_adm (32 bit report) ===
Report validation errors: msvcr100:msvcr100 crashed (c0000417)
=== w7u_el (32 bit report) ===
Report validation errors: msvcr100:msvcr100 crashed (c0000417)
=== w8 (32 bit report) ===
Report validation errors: msvcr100:msvcr100 crashed (c0000417)
=== w8adm (32 bit report) ===
Report validation errors: msvcr100:msvcr100 crashed (c0000417)
=== w864 (32 bit report) ===
Report validation errors: msvcr100:msvcr100 crashed (c0000417)
=== w10pro64 (32 bit report) ===
Report validation errors: msvcr100:msvcr100 crashed (c0000417)
=== w10pro64_en_AE_u8 (32 bit report) ===
Report validation errors: msvcr100:msvcr100 crashed (c0000417)
=== w11pro64 (32 bit report) ===
Report validation errors: msvcr100:msvcr100 crashed (c0000417)
=== w864 (64 bit report) ===
Report validation errors: msvcr100:msvcr100 crashed (c0000417)
=== w10pro64 (64 bit report) ===
Report validation errors: msvcr100:msvcr100 crashed (c0000417)
=== w10pro64_ar (64 bit report) ===
Report validation errors: msvcr100:msvcr100 crashed (c0000417)
=== w10pro64_ja (64 bit report) ===
Report validation errors: msvcr100:msvcr100 crashed (c0000417)
=== w10pro64_zh_CN (64 bit report) ===
Report validation errors: msvcr100:msvcr100 crashed (c0000417)
=== w11pro64_amd (64 bit report) ===
Report validation errors: msvcr100:msvcr100 crashed (c0000417)
=== debian11 (32 bit report) ===
msvcr100: Unhandled exception: 0xc0000417 in 32-bit code (0x7b682207). msvcr100.c:665: Test failed: _aligned_msize returned 31 msvcr100.c:667: Test failed: _aligned_msize returned 31 msvcr100.c:669: Test failed: _aligned_msize returned 31 msvcr100.c:671: Test failed: _aligned_msize returned 31 msvcr100.c:673: Test failed: _aligned_msize returned 31
=== debian11 (32 bit ar:MA report) ===
msvcr100: Unhandled exception: 0xc0000417 in 32-bit code (0x7b682207). msvcr100.c:665: Test failed: _aligned_msize returned 31 msvcr100.c:667: Test failed: _aligned_msize returned 31 msvcr100.c:669: Test failed: _aligned_msize returned 31 msvcr100.c:671: Test failed: _aligned_msize returned 31 msvcr100.c:673: Test failed: _aligned_msize returned 31
=== debian11 (32 bit de report) ===
msvcr100: Unhandled exception: 0xc0000417 in 32-bit code (0x7b682207). msvcr100.c:665: Test failed: _aligned_msize returned 31 msvcr100.c:667: Test failed: _aligned_msize returned 31 msvcr100.c:669: Test failed: _aligned_msize returned 31 msvcr100.c:671: Test failed: _aligned_msize returned 31 msvcr100.c:673: Test failed: _aligned_msize returned 31
=== debian11 (32 bit fr report) ===
msvcr100: Unhandled exception: 0xc0000417 in 32-bit code (0x7b682207). msvcr100.c:665: Test failed: _aligned_msize returned 31 msvcr100.c:667: Test failed: _aligned_msize returned 31 msvcr100.c:669: Test failed: _aligned_msize returned 31 msvcr100.c:671: Test failed: _aligned_msize returned 31 msvcr100.c:673: Test failed: _aligned_msize returned 31
=== debian11 (32 bit he:IL report) ===
msvcr100: Unhandled exception: 0xc0000417 in 32-bit code (0x7b682207). msvcr100.c:665: Test failed: _aligned_msize returned 31 msvcr100.c:667: Test failed: _aligned_msize returned 31 msvcr100.c:669: Test failed: _aligned_msize returned 31 msvcr100.c:671: Test failed: _aligned_msize returned 31 msvcr100.c:673: Test failed: _aligned_msize returned 31
=== debian11 (32 bit hi:IN report) ===
msvcr100: Unhandled exception: 0xc0000417 in 32-bit code (0x7b682207). msvcr100.c:665: Test failed: _aligned_msize returned 31 msvcr100.c:667: Test failed: _aligned_msize returned 31 msvcr100.c:669: Test failed: _aligned_msize returned 31 msvcr100.c:671: Test failed: _aligned_msize returned 31 msvcr100.c:673: Test failed: _aligned_msize returned 31
=== debian11 (32 bit ja:JP report) ===
msvcr100: Unhandled exception: 0xc0000417 in 32-bit code (0x7b682207). msvcr100.c:665: Test failed: _aligned_msize returned 31 msvcr100.c:667: Test failed: _aligned_msize returned 31 msvcr100.c:669: Test failed: _aligned_msize returned 31 msvcr100.c:671: Test failed: _aligned_msize returned 31 msvcr100.c:673: Test failed: _aligned_msize returned 31
=== debian11 (32 bit zh:CN report) ===
msvcr100: Unhandled exception: 0xc0000417 in 32-bit code (0x7b682207). msvcr100.c:665: Test failed: _aligned_msize returned 31 msvcr100.c:667: Test failed: _aligned_msize returned 31 msvcr100.c:669: Test failed: _aligned_msize returned 31 msvcr100.c:671: Test failed: _aligned_msize returned 31 msvcr100.c:673: Test failed: _aligned_msize returned 31
=== debian11b (32 bit WoW report) ===
msvcr100: Unhandled exception: 0xc0000417 in wow64 32-bit code (0x76fb2207). msvcr100.c:665: Test failed: _aligned_msize returned 31 msvcr100.c:667: Test failed: _aligned_msize returned 31 msvcr100.c:669: Test failed: _aligned_msize returned 31 msvcr100.c:671: Test failed: _aligned_msize returned 31 msvcr100.c:673: Test failed: _aligned_msize returned 31
=== debian11b (64 bit WoW report) ===
msvcr100: Unhandled exception: 0xc0000417 in 64-bit code (0x006fffff483a77). msvcr100.c:665: Test failed: _aligned_msize returned 31 msvcr100.c:667: Test failed: _aligned_msize returned 31 msvcr100.c:669: Test failed: _aligned_msize returned 31 msvcr100.c:671: Test failed: _aligned_msize returned 31 msvcr100.c:673: Test failed: _aligned_msize returned 31
This merge request was closed by Bartosz Kosiorek.