Function _beginthreadex in msvcr70+ use dummy stack value for thrdaddr
pointer argument if caller specify NULL. This seems to be for compatibility
with older Windows versions where CreateThread crashes if NULL thrdaddr
pointer is supplied.
Pass pointer to dummy stack value in mingw-w64 i386 _beginthreadex wrapper
if the supplied pointer is NULL. This allows allows applications to call
_beginthreadex with NULL thrdaddr argument for CRT any build without
crashing on older systems.
---
mingw-w64-crt/misc/i386__beginthreadex.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mingw-w64-crt/misc/i386__beginthreadex.c
b/mingw-w64-crt/misc/i386__beginthreadex.c
index b23f654844fa..de5a07c27c76 100644
--- a/mingw-w64-crt/misc/i386__beginthreadex.c
+++ b/mingw-w64-crt/misc/i386__beginthreadex.c
@@ -45,7 +45,8 @@ uintptr_t __cdecl _beginthreadex(void *security, unsigned
stack_size, _beginthre
}
thread_args[0] = (void *)start_address;
thread_args[1] = arglist;
- ret = __msvcrt_beginthreadex(security, stack_size, thread_func, thread_args,
initflag, thrdaddr);
+ /* pre-msvcr70 versions of _beginthreadex do not change NULL thrdaddr to
dummy stack value */
+ ret = __msvcrt_beginthreadex(security, stack_size, thread_func, thread_args,
initflag, thrdaddr ?: &(unsigned){0});
if (!ret)
free(thread_args);
return ret;
--
2.20.1
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public