https://bugs.winehq.org/show_bug.cgi?id=36662
Bug ID: 36662 Summary: valgrind shows a few memory leaks in ws2_32/tests/sock.c Product: Wine Version: 1.7.19 Hardware: x86 OS: Linux Status: NEW Keywords: download, source, testcase, valgrind Severity: normal Priority: P2 Component: winsock Assignee: wine-bugs@winehq.org Reporter: austinenglish@gmail.com
==21586== Thread 1 ws2_32_test.exe.so: ==21586== 60 bytes in 1 blocks are possibly lost in loss record 350 of 701 ==21586== at 0x7BC4C6EB: notify_alloc (heap.c:255) ==21586== by 0x7BC50F2F: RtlAllocateHeap (heap.c:1716) ==21586== by 0x50B07F4: WS2_sendto (socket.c:4545) ==21586== by 0x50B0611: WSASend (socket.c:4500) ==21586== by 0x4F6E338: test_send (sock.c:4194) ==21586== by 0x4F7FDB1: func_sock (sock.c:7742) ==21586== by 0x4F80BB1: run_test (test.h:584) ==21586== by 0x4F80FA0: main (test.h:654) ==21586==
==21586== 60 bytes in 1 blocks are possibly lost in loss record 351 of 701 ==21586== at 0x7BC4C6EB: notify_alloc (heap.c:255) ==21586== by 0x7BC50F2F: RtlAllocateHeap (heap.c:1716) ==21586== by 0x50B07F4: WS2_sendto (socket.c:4545) ==21586== by 0x50B0611: WSASend (socket.c:4500) ==21586== by 0x4F6E6AF: test_send (sock.c:4234) ==21586== by 0x4F7FDB1: func_sock (sock.c:7742) ==21586== by 0x4F80BB1: run_test (test.h:584) ==21586== by 0x4F80FA0: main (test.h:654) ==21586==
==21586== 60 bytes in 1 blocks are definitely lost in loss record 352 of 701 ==21586== at 0x7BC4C6EB: notify_alloc (heap.c:255) ==21586== by 0x7BC50F2F: RtlAllocateHeap (heap.c:1716) ==21586== by 0x50B638A: WS2_recv_base (socket.c:6554) ==21586== by 0x50B61D4: WSARecv (socket.c:6522) ==21586== by 0x4F7A61B: test_completion_port (sock.c:6862) ==21586== by 0x4F7FDAC: func_sock (sock.c:7739) ==21586== by 0x4F80BB1: run_test (test.h:584) ==21586== by 0x4F80FA0: main (test.h:654) ==21586==
https://bugs.winehq.org/show_bug.cgi?id=36662
Sebastian Lackner sebastian@fds-team.de changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |sebastian@fds-team.de
--- Comment #1 from Sebastian Lackner sebastian@fds-team.de --- Created attachment 49347 --> https://bugs.winehq.org/attachment.cgi?id=49347 ws2_32/tests: Enter alertable state to ensure memory is released.
The attached patch should fix the last issue (the definite leak). The problem is that the thread never enters an alertable state after the APC_USER callback has been queued.
For these tests this issue wasn't really critical, since the amount of leaked memory was relatively small - but it leaves one open question: Is the same also required on Windows? I've never seen any Windows network apps that have to care about that manually. I somehow suspect that on Windows some of the internal network commands use alertable waits .... any ideas?
https://bugs.winehq.org/show_bug.cgi?id=36662
--- Comment #2 from Austin English austinenglish@gmail.com --- (In reply to Sebastian Lackner from comment #1)
Created attachment 49347 [details] ws2_32/tests: Enter alertable state to ensure memory is released.
The attached patch should fix the last issue (the definite leak). The problem is that the thread never enters an alertable state after the APC_USER callback has been queued.
Works here, thanks.
https://bugs.winehq.org/show_bug.cgi?id=36662
--- Comment #3 from Sebastian Lackner sebastian@fds-team.de --- Could you please check again with current wine git? I guess that this should be fixed by http://source.winehq.org/git/wine.git/commit/4273b0d938b9ed64c0edefdeb96cda3... (similar to bug 38143)
https://bugs.winehq.org/show_bug.cgi?id=36662
--- Comment #4 from Austin English austinenglish@gmail.com --- (In reply to Sebastian Lackner from comment #3)
Could you please check again with current wine git? I guess that this should be fixed by http://source.winehq.org/git/wine.git/commit/ 4273b0d938b9ed64c0edefdeb96cda33d1479bb8 (similar to bug 38143)
After that, with gcc-4.9.2 and valgrind 3.10.1, I get a crash instead:
sock.c:2362: Tests skipped: SOCK_RAW is not supported
err:seh:segv_handler Got unexpected trap 0 wine: Unhandled illegal instruction at address 0x7bc26b15 (thread 0025), starting debugger... preloader: Warning: failed to reserve range 00110000-68000000 preloader: Warning: failed to reserve range 7f000000-82000000 Unhandled exception: illegal instruction in 32-bit code (0x7bc26b15). Register dump: CS:0023 SS:002b DS:002b ES:002b FS:000b GS:0013 EIP:7bc26b15 ESP:04bfef14 EBP:04bff264 EFLAGS:00000044( - -- Z- -P- ) EAX:04bff278 EBX:7b8b7000 ECX:04bfef18 EDX:00000216 ESI:04bff288 EDI:04bfef10 Stack dump: 0x04bfef14: 00000216 00010007 00000000 00000000 0x04bfef24: 00000000 00000000 00000000 00000000 0x04bfef34: 00000000 00000000 00000000 00000000 0x04bfef44: 00000000 00000000 00000000 00000000 0x04bfef54: 00000000 00000000 00000000 00000000 0x04bfef64: 00000000 00000000 00000000 00000000 Backtrace: =>0 0x7bc26b15 __wine_call_from_regs+0x101() in ntdll (0x04bff264) 1 0x7bc7fb8c RtlUnwind+0xb() in ntdll (0x04bff2b8) 2 0x00000004 (0x04bff2b8) 3 0x7b880ed8 unwind_frame+0x46(record=0x4bff7a8, frame=0x4bff818) [/home/austin/wine-valgrind/dlls/winecrt0/exception.c:74] in kernel32 (0x04bff2e8) 4 0x7b880f80 __wine_exception_handler_page_fault+0x3a(record=0x4bff7a8, frame=0x4bff818, context=0x4bff4dc, pdispatcher=0x4bff38c) [/home/austin/wine-valgrind/dlls/winecrt0/exception.c:111] in kernel32 (0x04bff308) 5 0x7bc7ff45 call_exception_handler+0x28() in ntdll (0x04bff338) 6 0x7bc7ff17 EXC_CallHandler+0x1a() in ntdll (0x04bff358) 7 0x7bc7bc97 call_stack_handlers+0xcc(rec=0x4bff7a8, context=0x4bff4dc) [/home/austin/wine-valgrind/dlls/ntdll/signal_i386.c:671] in ntdll (0x04bff3b8) 8 0x7bc7c08f raise_exception+0x311(rec=0x4bff7a8, context=0x4bff4dc, first_chance=0x1) [/home/austin/wine-valgrind/dlls/ntdll/signal_i386.c:749] in ntdll (0x04bff448) 9 0x7bc7fbb3 NtRaiseException+0x23(rec=<couldn't compute location>, context=<couldn't compute location>, first_chance=<couldn't compute location>) [/home/austin/wine-valgrind/dlls/ntdll/signal_i386.c:2622] in ntdll (0x04bff478) 10 0x7bc7e7fe raise_segv_exception+0x138(rec=<couldn't compute location>, context=<couldn't compute location>) [/home/austin/wine-valgrind/dlls/ntdll/signal_i386.c:1938] in ntdll (0x04bff4c8) 11 0xdeadbabe (0x04bff8e8) 12 0x04c2488e WS2_recv_base+0x200(s=0x9c, lpBuffers=0x4bffa80, dwBufferCount=0x1, lpNumberOfBytesRecvd=0x4bffa8c, lpFlags=0x4bffa88, lpFrom=(nil), lpFromlen=0x0(nil), lpOverlapped=(nil), lpCompletionRoutine=(nil), lpControlBuffer=(nil)) [/home/austin/wine-valgrind/dlls/ws2_32/socket.c:6727] in ws2_32 (0x04bffa48) 13 0x04c1eb16 WS_recv+0x46(s=<couldn't compute location>, buf=<couldn't compute location>, len=<couldn't compute location>, flags=<couldn't compute location>) [/home/austin/wine-valgrind/dlls/ws2_32/socket.c:4396] in ws2_32 (0x04bffa98) 14 0x04abce79 test_events+0x1180(useMessages=0) [/home/austin/wine-valgrind/dlls/ws2_32/tests/sock.c:5158] in ws2_32_test (0x04bffcc8) 15 0x04accd8a func_sock+0x153() [/home/austin/wine-valgrind/dlls/ws2_32/tests/sock.c:8265] in ws2_32_test (0x04bffcf8) 16 0x04acdb22 run_test+0x9f(name="sock") [/home/austin/wine-valgrind/dlls/ws2_32/tests/../../../include/wine/test.h:584] in ws2_32_test (0x04bffd38) 17 0x04acdeee main+0x209(argc=<couldn't compute location>, argv=<couldn't compute location>) [/home/austin/wine-valgrind/dlls/ws2_32/tests/../../../include/wine/test.h:654] in ws2_32_test (0x04bffde8)
I'll attach the full output.
https://bugs.winehq.org/show_bug.cgi?id=36662
--- Comment #5 from Austin English austinenglish@gmail.com --- Created attachment 50936 --> https://bugs.winehq.org/attachment.cgi?id=50936 output/backtrace
https://bugs.winehq.org/show_bug.cgi?id=36662
--- Comment #6 from Austin English austinenglish@gmail.com --- (In reply to Austin English from comment #5)
Created attachment 50936 [details] output/backtrace
this is with wine-1.7.37-260-g4c1791f
https://bugs.winehq.org/show_bug.cgi?id=36662
--- Comment #7 from Nikolay Sivov bunglehead@gmail.com --- Could you retest if it still crashes?
https://bugs.winehq.org/show_bug.cgi?id=36662
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |FIXED
--- Comment #8 from Austin English austinenglish@gmail.com --- (In reply to Nikolay Sivov from comment #7)
Could you retest if it still crashes?
With valgrind-3.13.0.SVN-16204-vex-3299 and wine-2.1, I get: ==15711== Invalid free() / delete / delete[] / realloc() ==15711== at 0x7BC5084A: notify_realloc (heap.c:270) ==15711== by 0x7BC551A0: RtlReAllocateHeap (heap.c:1860) ==15711== by 0x4D24CDD: WS_get_local_ips (socket.c:6306) ==15711== by 0x4D24FFC: WS_gethostbyname (socket.c:6389) ==15711== by 0x4BC8192: test_getsockname (sock.c:4455) ==15711== by 0x4BE6468: func_sock (sock.c:10120) ==15711== by 0x4BE72C1: run_test (test.h:589) ==15711== by 0x4BE76ED: main (test.h:671) ==15711== Address 0x6082a98 is 0 bytes after a recently re-allocated block of size 0 alloc'd ==15711== at 0x7BC50754: notify_alloc (heap.c:254) ==15711== by 0x7BC54BD5: RtlAllocateHeap (heap.c:1716) ==15711== by 0x4D24B3E: WS_get_local_ips (socket.c:6272) ==15711== by 0x4D24FFC: WS_gethostbyname (socket.c:6389) ==15711== by 0x4BC8192: test_getsockname (sock.c:4455) ==15711== by 0x4BE6468: func_sock (sock.c:10120) ==15711== by 0x4BE72C1: run_test (test.h:589) ==15711== by 0x4BE76ED: main (test.h:671) ==15711==
==15711== Invalid free() / delete / delete[] / realloc() ==15711== at 0x7BC5084A: notify_realloc (heap.c:270) ==15711== by 0x7BC552CE: RtlReAllocateHeap (heap.c:1896) ==15711== by 0x4D24CDD: WS_get_local_ips (socket.c:6306) ==15711== by 0x4D24FFC: WS_gethostbyname (socket.c:6389) ==15711== by 0x4BC873B: test_gethostbyname (sock.c:4558) ==15711== by 0x4BE6481: func_sock (sock.c:10125) ==15711== by 0x4BE72C1: run_test (test.h:589) ==15711== by 0x4BE76ED: main (test.h:671) ==15711== Address 0x48d62f8 is 0 bytes after a recently re-allocated block of size 0 alloc'd ==15711== at 0x7BC50754: notify_alloc (heap.c:254) ==15711== by 0x7BC54BD5: RtlAllocateHeap (heap.c:1716) ==15711== by 0x4D24B3E: WS_get_local_ips (socket.c:6272) ==15711== by 0x4D24FFC: WS_gethostbyname (socket.c:6389) ==15711== by 0x4BC873B: test_gethostbyname (sock.c:4558) ==15711== by 0x4BE6481: func_sock (sock.c:10125) ==15711== by 0x4BE72C1: run_test (test.h:589) ==15711== by 0x4BE76ED: main (test.h:671) ==15711==
but no crash. And the original leaks aren't present, marking fixed.
https://bugs.winehq.org/show_bug.cgi?id=36662
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #9 from Alexandre Julliard julliard@winehq.org --- Closing bugs fixed in 2.2.