MSVCRTD/tests/debug.c: buggy call to operator new

Saulius Krasuckas saulius2 at ar.fi.lt
Sun Jun 12 16:08:46 CDT 2005


Wrong value of 0 (_FREE_BLOCK) is passed as a second parameter (int 
nBlockUse) to the operator [1], which causes real DLL on real windows to 
pop up a MSVCRTD Library window, informing you:

| Debug Error!
| Error: memory allocation: bad memory block type.

The test succeeds only on Wine:

| void test_new(void)
| {
|   void *mem;
| 
|   mem = pMSVCRTD_operator_new_dbg(42, 0, __FILE__, __LINE__);
|   ok(mem != NULL, "memory not allocated\n");
| }

The bug sits here already for one year [2] minus one week [3].  It causes 
long timeouts during run of Winetest.  I hate it.  Here goes my patch.

I left inability of our operator to differentiate between memory block 
types (and to handle wrong types) untouched [4].  Hence, I warn about a 
possible bug in the MSVCRTD_operator_new_dbg().  

Is the patch OK?  Do I hide the bug?  If yes, how should I cope with 
exceptions in Wine?  What else can I do to avoid MSVCRTD Library poping up 
error window?


[1] http://msdn.microsoft.com/library/shared/deeptree/asp/rightframe.asp?dtcfg=/library/deeptreeconfig.xml&url=/library/en-us/vclib/html/_CRT__malloc_dbg.asp?frame=true&hidetoc=false
[2] http://www.winehq.com/hypermail/wine-cvs/2004/05/0184.html
[3] http://test.winehq.org/data/200406181000/
[4] http://msdn.microsoft.com/library/shared/deeptree/asp/rightframe.asp?dtcfg=/library/deeptreeconfig.xml&url=/library/en-us/vsdebug/html/_core_types_of_blocks_on_the_debug_heap.asp?frame=true&hidetoc=false


Index: dlls/msvcrtd/tests/debug.c
===================================================================
RCS file: /home/wine/wine/dlls/msvcrtd/tests/debug.c,v
retrieving revision 1.1
diff -p -u -r1.1 debug.c
--- dlls/msvcrtd/tests/debug.c  18 May 2004 01:05:36 -0000      1.1
+++ dlls/msvcrtd/tests/debug.c  12 Jun 2005 20:54:38 -0000
@@ -23,6 +23,7 @@
 #include "windef.h"
 #include "winbase.h"
 #include "winnt.h"
+#include "crtdbg.h"
 
 #include "wine/test.h"
 
@@ -55,7 +56,7 @@ void test_new(void)
 {
   void *mem;
 
-  mem = pMSVCRTD_operator_new_dbg(42, 0, __FILE__, __LINE__);
+  mem = pMSVCRTD_operator_new_dbg(42, _NORMAL_BLOCK, __FILE__, __LINE__);
   ok(mem != NULL, "memory not allocated\n");
 }
 



More information about the wine-devel mailing list