<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 10, 2014 at 4:21 PM, Lang Hames <span dir="ltr"><<a href="mailto:lhames@gmail.com" target="_blank">lhames@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Oooh. Neat. Thanks Dave. Please go ahead and commit that.</div></blockquote><div><br></div><div>Committed in <span style="color:rgb(0,0,0)">217563.<br><br>Running the PBQP test without my change under valgrind didn't show any memory leak, but hopefully with Arnaud's change and valgrind he can see the leak and then verify that my change addresses it... *fingers crossed*</span></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>Arnaud - I have no idea whether Dave's patch will help with this bug, but it's certainly worth testing.</div><span class=""><font color="#888888"><div><br></div><div>- Lang.</div></font></span></div><div class=""><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 10, 2014 at 4:10 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">While I'm not sure where the leak is, using some pre-canned memory management might help... <br><br>Attached is a patch that changes this allocation to use shared_ptr, perhaps it'll address the bug?<br><br>(ideally we shouldn't need the intrusive ref counting (std::enable_shared_from_this) but instead have a weak_set that has std::weak_ptr in it & implicitly removes elements as they become null (probably on a harvesting schedule, rather than with a direct callback as is currently implemented))<br><div class="gmail_chip gmail_drive_chip" style="width:396px;min-height:18px;max-height:18px;padding:5px;color:rgb(34,34,34);font-family:arial;font-style:normal;font-weight:bold;font-size:13px;border:1px solid rgb(221,221,221);line-height:1;background-color:rgb(245,245,245)"><a href="https://docs.google.com/file/d/0B0jpkch3iC_7TXFVU2hCcUpfZXM/edit?usp=drive_web" style="display:inline-block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-decoration:none;padding:1px 0px;border:none;width:100%" target="_blank"><img style="vertical-align: bottom; border: none;" src="https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png"> <span dir="ltr" style="color:rgb(17,85,204);text-decoration:none;vertical-align:bottom">pbqp_leak.diff</span></a></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 10, 2014 at 3:19 PM, Arnaud A. de Grandmaison <span dir="ltr"><<a href="mailto:arnaud.degrandmaison@arm.com" target="_blank">arnaud.degrandmaison@arm.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div lang="EN-GB" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Hi Lang,<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">In PBQPBuilderWithCoalescing::build, around line 360, we have code looking like:<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">…<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">PBQP::Vector newCosts(g.getNodeCosts(node));<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">addPhysRegCoalesce(newCosts, pregOpt, cBenefit);<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">g.setNodeCosts(node, newCosts);<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">…<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">I suspect the leak occurs around the setNodeCosts method, and I have trouble understanding how it handles the case where the node already has costs.<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">It seems to me that:<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"> - we make of copy of the node’s costs (probably because someone else can refer to it ?)<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"> - we modify the copy<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"> - we set the node’s new costs. But what is supposed to happen there, especially in the CostAllocator part ?<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Could you shed some light there ?<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Thanks,<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Arnaud<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p><p class="MsoNormal" style="margin-left:36pt"><b><span lang="EN-US" style="font-size:10pt;font-family:Tahoma,sans-serif">From:</span></b><span lang="EN-US" style="font-size:10pt;font-family:Tahoma,sans-serif"> Lang Hames [mailto:<a href="mailto:lhames@gmail.com" target="_blank">lhames@gmail.com</a>] <br><b>Sent:</b> 10 September 2014 19:26<br><b>To:</b> Arnaud De Grandmaison<br><b>Subject:</b> Re: Leaks in PBQPBuilderWithCoalescing::build ?<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:36pt"><u></u> <u></u></p><div><p class="MsoNormal" style="margin-left:36pt">Thanks Arnaud!<u></u><u></u></p><div><p class="MsoNormal" style="margin-left:36pt"><u></u> <u></u></p></div><div><p class="MsoNormal" style="margin-left:36pt">- Lang.<u></u><u></u></p></div></div><div><p class="MsoNormal" style="margin-left:36pt"><u></u> <u></u></p><div><p class="MsoNormal" style="margin-left:36pt">On Wed, Sep 10, 2014 at 11:23 AM, Arnaud A. de Grandmaison <<a href="mailto:arnaud.degrandmaison@arm.com" target="_blank">arnaud.degrandmaison@arm.com</a>> wrote:<u></u><u></u></p><div><div><p class="MsoNormal" style="margin-left:36pt">Hi Lang,<u></u><u></u></p><p class="MsoNormal" style="margin-left:36pt"> <u></u><u></u></p><p class="MsoNormal" style="margin-left:36pt">For your information, the leak sanitizer found something when I committed my patch:<u></u><u></u></p><p class="MsoNormal" style="margin-left:36pt"> <u></u><u></u></p><p class="MsoNormal" style="margin-left:36pt"><a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/4506/steps/check-llvm%20asan/logs/stdio" target="_blank">http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/4506/steps/check-llvm%20asan/logs/stdio</a><u></u><u></u></p><p class="MsoNormal" style="margin-left:36pt"> <u></u><u></u></p><p class="MsoNormal" style="margin-left:36pt">I will try to have a look at it.<u></u><u></u></p><p class="MsoNormal" style="margin-left:36pt"> <u></u><u></u></p><p class="MsoNormal" style="margin-left:36pt">Cheers,<u></u><u></u></p><p class="MsoNormal" style="margin-left:36pt">--<u></u><u></u></p><p class="MsoNormal" style="margin-left:36pt">Arnaud A. de Grandmaison<u></u><u></u></p><p class="MsoNormal" style="margin-left:36pt"> <u></u><u></u></p></div></div></div><p class="MsoNormal" style="margin-left:36pt"><u></u> <u></u></p></div></div></div><br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>