在 2026-8-17 19:13, Pali Rohár 写道:
On Monday 17 August 2026 19:09:08 LIU Hao wrote:
在 2026-8-16 19:07, Pali Rohár 写道:
For CI testing, it is needed to also remove this t_tsearch test from the
"XFAIL_TESTS =" section in mingw-w64-crt/testcases/Makefile.am

diff --git a/mingw-w64-crt/testcases/Makefile.am 
b/mingw-w64-crt/testcases/Makefile.am
index 9c785f893ea9..e96071e6f61c 100644
--- a/mingw-w64-crt/testcases/Makefile.am
+++ b/mingw-w64-crt/testcases/Makefile.am
@@ -300,8 +300,7 @@ XFAIL_TESTS = \
     t_excpt_int_divzero_thrd \
     t_excpt_int_overflow \
     t_excpt_int_overflow_thrd \
-  t_nullptrexception \
-  t_tsearch
+  t_nullptrexception

   # Include the complex math testcase fragment.
   include complex/Makefile.am


On Saturday 15 August 2026 15:58:53 Pali Rohár wrote:
The test t_tsearch.c is crashing on Windows XP. Function twalk() invokes
twalk() in infinite recursion which cause stack overflow.

The reason is that tdestroy() frees the memory for the root node which
invalidates root pointer and accessing it later cause use-after-free error.
Seems that msvcrt memory allocator on Windows XP can trigger this crash
more often than on other Windows versions.

Fix this issue, after the tdestroy() call, sets the root node pointer to NULL.
---
   mingw-w64-crt/testcases/t_tsearch.c | 1 +
   1 file changed, 1 insertion(+)

diff --git a/mingw-w64-crt/testcases/t_tsearch.c 
b/mingw-w64-crt/testcases/t_tsearch.c
index 496525980529..91c0de50e9f0 100644
--- a/mingw-w64-crt/testcases/t_tsearch.c
+++ b/mingw-w64-crt/testcases/t_tsearch.c
@@ -117,6 +117,7 @@ int main (int argc, char **argv)
    printf("----------\n");
    tdestroy(root, noop_free);
+ root = NULL;
    printf("---------- tree after deletion of all nodes using tdestroy() 
only:\n");
    nodes_printed = 0;
    twalk(root, print_node);
--
2.20.1


These changes look good to me, too. I have squashed them into a single commit, 
and pushed.

Ok. Could you also remove that FIXME comment about which Kirill pointed out?
With that root=NULL; assignment, the FIXME comment is addressed.


diff --git a/mingw-w64-crt/testcases/t_tsearch.c 
b/mingw-w64-crt/testcases/t_tsearch.c
index 91c0de50e9f0..7f27e52963b5 100644
--- a/mingw-w64-crt/testcases/t_tsearch.c
+++ b/mingw-w64-crt/testcases/t_tsearch.c
@@ -7,11 +7,6 @@
  /* mingw-w64 headers */
  #include "libtest.h"

-/**
- * FIXME: calling `twalk` after `tdestroy` walks the tree as if tree was not
- *  destroyed. That is, it dereferences freed nodes.
- */
-
  static int node_cmp (const void *a, const void *b)
  {
   return strcmp((const char *) a, (const char *) b);

Done now.


--
Best regards,
LIU Hao

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to