<div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div>(This is a little long, but I wanted to show my steps so I could be corrected)<br>So after spending a very long time looking at it (probably too long), I think I have a solution. <br></div>Looking at the code snippet from /dlls/atl100/tests/atl.c<br><br>    hwnd = create_container_window();<br>    SetWindowLongW(hwnd, GWLP_USERDATA, 0xdeadbeef);<br>    container = NULL;<br>    hr = AtlAxAttachControl(control, hwnd, &container);<br>    ok(1==0, "Leaving AtlAxAttachControl second 0x%08x, 0x%08x\n",container, &container);<br>    ok(container != NULL, "Expected not NULL!\n");<br>    val = GetWindowLongW(hwnd, GWLP_USERDATA);<br>    ok(val == 0xdeadbeef, "Expected unchanged, returned %08x\n", val);<br>    DestroyWindow(hwnd);<br><br></div>The data that was never freed in this case was the container which got assigned in the AtlAxAttatchControl function<br><br>==8187== 64 bytes in 1 blocks are definitely lost in loss record 271 of 577<br>==8187==    at 0x7BC519A5: RtlAllocateHeap (heap.c:260)<br>==8187==    by 0x4D27844: IOCS_Create (atl_ax.c:953)<br>==8187==    by 0x4D27844: AtlAxAttachControl (???:0)<br>==8187==    by 0x487D35A: func_atl (in /home/kduggan15/Documents/Wine/wine-valgrind/wine/dlls/atl100/tests/<a href="http://atl100_test-stripped.exe.so">atl100_test-stripped.exe.so</a>)<br>==8187==    by 0x487D66E: ??? (in /home/kduggan15/Documents/Wine/wine-valgrind/wine/dlls/atl100/tests/<a href="http://atl100_test-stripped.exe.so">atl100_test-stripped.exe.so</a>)<br>==8187==    by 0x487CDD8: main (in /home/kduggan15/Documents/Wine/wine-valgrind/wine/dlls/atl100/tests/<a href="http://atl100_test-stripped.exe.so">atl100_test-stripped.exe.so</a>)<br>==8187== <br><br></div>The hard part of this for me was figuring out who was responsible for freeing container. After some time I came to the conclusion that the caller of<br></div>the AtlAxAttachControl function was intended to free container. I namely came to this conclusion because I couldn't really see how the DestroyWindow<br></div>function would be able to free the container. If DestoyWindow is supposed to be responsible for freeing container, I just wasn't <br></div>smart enough to figure it out and will have too look again.<br><br></div>To fix it, I just added  "IUnknown_Release(container);" after DestroyWindow(hwnd) so the new code would look like this<br><br>    hwnd = create_container_window();<br>    SetWindowLongW(hwnd, GWLP_USERDATA, 0xdeadbeef);<br>    container = NULL;<br>    hr = AtlAxAttachControl(control, hwnd, &container);<br>    ok(1==0, "Leaving AtlAxAttachControl second 0x%08x, 0x%08x\n",container, &container);<br>    ok(container != NULL, "Expected not NULL!\n");<br>    val = GetWindowLongW(hwnd, GWLP_USERDATA);<br>    ok(val == 0xdeadbeef, "Expected unchanged, returned %08x\n", val);<br>    DestroyWindow(hwnd);<br>+  IUnknown_Release(container);<br><br></div>Valgrind shows that this does remove the memory leak<br></div>If this looks good enough, then I'll go ahead and submit it as a patch. I just wanted to get opinions here before I did<br><br></div>Thank you all for your assistance up to this point. I've never worked with a project as large as Wine so exploring the source<br></div>code and learning the debugging tools has been onerous, but I feel like I've learned a lot and feel accomplished (even if this attempt is incorrect).<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Mar 24, 2018 at 5:14 PM, Austin English <span dir="ltr"><<a href="mailto:austinenglish@gmail.com" target="_blank">austinenglish@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div>On mobile, so can't verify, but look at:</div><span class=""><div dir="auto"><span style="font-family:sans-serif">==9846==    by 0x4B07572: AtlAxAttachControl (atl_ax.c:1156)</span></div></span><div dir="auto">Line 1156 in atl_ax.</div><div dir="auto">And<span class=""><br><span style="font-family:sans-serif">==9846==    by 0x4804025: test_AtlAxAttachControl (atl.c:902)</span><br></span>Line 902 atl.c</div><div dir="auto"><br></div><div dir="auto">You can use `find -name atl.c` to find its location in the source checkout.<div><div class="h5"><br><div class="gmail_quote" dir="auto"><div dir="ltr">On Sat, Mar 24, 2018, 13:52 Kieran Duggan <<a href="mailto:kieranduggan15@gmail.com" target="_blank">kieranduggan15@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div>If that's the case, Is there a way that I can see where the AtlAxAttachControl was called from? It's not necessary technically, but knowing which test case caused a memory leak would be useful <br></div>When I ran the full test suite I got something like this<br><br>==9846== 64 bytes in 1 blocks are definitely lost in loss record 1,255 of 2,380<br>==9846==    at 0x7BC46859: notify_alloc (heap.c:260)<br>==9846==    by 0x7BC49D56: RtlAllocateHeap (heap.c:1726)<br>==9846==    by 0x4B06D40: IOCS_Create (atl_ax.c:952)<br>==9846==    by 0x4B07572: AtlAxAttachControl (atl_ax.c:1156)<br>==9846==    by 0x4804025: test_AtlAxAttachControl (atl.c:902)<br>==9846==    by 0x4805130: func_atl (atl.c:1092)<br>==9846==    by 0x4805485: run_test (test.h:603)<br>==9846==    by 0x4805EDC: main (test.h:687)<br>==9846== <br><br></div>Because I can see what parameters the method was called with I get a little more useful information<br></div>For example this one shows that a specific test case is where the function causes<br>If a leak f I look around the logs a little more I don't see the other test cases breaking.<br></div>So if there is a way to see where AtlAxAttachControl is being called from while running the test that would be useful.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Mar 24, 2018 at 2:49 AM, Austin English <span dir="ltr"><<a href="mailto:austinenglish@gmail.com" rel="noreferrer" target="_blank">austinenglish@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="m_-4171782022544339769m_-1307589748473766123HOEnZb"><div class="m_-4171782022544339769m_-1307589748473766123h5">On Sat, Mar 24, 2018 at 1:34 AM, Kieran Duggan <<a href="mailto:kieranduggan15@gmail.com" rel="noreferrer" target="_blank">kieranduggan15@gmail.com</a>> wrote:<br>
> So I'm attempting to run individual tests now. What exactly should I do<br>
> after I "make service.ok"? I tried just running valgrind the way I would<br>
> expect to use it i.e.<br>
><br>
> valgrind --trace-children=yes --track-origins=yes --leak-check=full<br>
> --num-callers=20 --workaround-gcc296-bugs=yes --log-file="filename.log"<br>
> ./wine<br>
> /home/kduggan15/Documents/<wbr>Wine/wine-valgrind/dlls/<wbr>atl100/tests/<a href="http://atl100_test-stripped.exe.so" rel="noreferrer noreferrer" target="_blank">atl100_test-<wbr>stripped.exe.so</a><br>
><br>
> I get<br>
><br>
> 64 bytes in 1 blocks are definitely lost in loss record 1,250 of 2,380<br>
> ==11711==    at 0x7BC46859: notify_alloc (heap.c:260)<br>
> ==11711==    by 0x7BC49D56: RtlAllocateHeap (heap.c:1726)<br>
> ==11711==    by 0x4D16D40: IOCS_Create (atl_ax.c:952)<br>
> ==11711==    by 0x4D17572: AtlAxAttachControl (atl_ax.c:1156)<br>
> ==11711==    by 0x4804025: ??? (in<br>
> /home/kduggan15/Documents/<wbr>Wine/wine-valgrind/dlls/<wbr>atl100/tests/<a href="http://atl100_test-stripped.exe.so" rel="noreferrer noreferrer" target="_blank">atl100_test-<wbr>stripped.exe.so</a>)<br>
><br>
> The issue being that the <a href="http://atl100_test-stripped.exe.so" rel="noreferrer noreferrer" target="_blank">atl100_test-stripped.exe.so</a> doesn't have any debug<br>
> symbols<br>
> Also I initially tried make service.ok and I just get something likemake<br>
> service is up to date or it just builds the tests without running valgrind.<br>
> If it does run valgrind, then I don't know where the log is going (and I<br>
> checked wine-valgrind/logs of course)<br>
><br>
> That's basically all I got. Sorry if these questions are a bit basic. I'm<br>
> just running into a few roadblocks and could use the assistance. I really<br>
> appreciate the help<br>
<br>
</div></div>Hi Kieran,<br>
<br>
You've got it. Notice how the output is prefixed with the pid of the<br>
wine process; that's valgrind's output. The source code lines on the<br>
end of the line, like a backtrace.<br>
<br>
So that output shows that there's a leak in atl100, allocated via<br>
heap.c's notify_alloc, then RtlAllocateHeap, then IOCS_Create, then<br>
AtlAxAttachControl).<br>
<br>
Your task would be to find that leak, then fix it, i.e., free the<br>
memory where it should have been, but wasn't.<br>
<br>
FYI, after running the tests, you may need to run 'rm service.ok',<br>
otherwise the test won't run (only if it succeeded beforehand).<br>
</blockquote></div><br></div>
</blockquote></div></div></div></div></div>
</blockquote></div><br></div>