http://bugs.winehq.org/show_bug.cgi?id=10179
Summary: Heap corruption in tiny example program Product: Wine Version: CVS/GIT Platform: Other OS/Version: other Status: NEW Severity: enhancement Priority: P2 Component: wine-kernel AssignedTo: wine-bugs@winehq.org ReportedBy: dank@kegel.com
The call to GlobalHandle in the following program causes the warning
warn:heap:HEAP_ValidateInUseArena Heap 0x110000: invalid in-use arena magic for 0x110810
To reproduce, copy the following program to dlls/kernel32/tests/bug.c and compile with
../../../tools/winegcc/winegcc -B../../../tools/winebuild -mconsole -I../../../include bug.c ../../../libs/port/libwine_port.a -ladvapi32 -lkernel32
then run with
WINEDEBUG=warn+heap ./a.out
#include <stdarg.h> #include <windef.h> #include <winbase.h> #include <winerror.h> #include <assert.h>
int main(int argc, char **argv) { HGLOBAL hmem,hmem2; UCHAR *pmem;
SetLastError(NO_ERROR); hmem=GlobalAlloc(0, 1); assert(hmem != NULL); hmem=GlobalReAlloc(hmem,0,GMEM_MODIFY | GMEM_MOVEABLE); pmem=GlobalLock(hmem); hmem2=GlobalHandle(pmem); // Here's the line that causes the warning assert(hmem2==hmem); assert(pmem!=NULL && !GlobalUnlock(hmem) && GetLastError()==NO_ERROR); assert(!GlobalFree(hmem)); assert(HeapValidate(GetProcessHeap(), 0, 0)); return 0; }
This was boiled down from alloc.c (which has a similar warning).