<div dir="ltr">Ah, OK - it was fixed by Benjamin Kramer in <span style="font-size:17.6000003814697px">r239673</span><div><span style="font-size:17.6000003814697px"><br></span></div><div><span style="font-size:17.6000003814697px"><br></span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 15, 2015 at 8:33 AM, Eli Bendersky <span dir="ltr"><<a href="mailto:eliben@google.com" target="_blank">eliben@google.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="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Sat, Jun 13, 2015 at 10:13 AM, Alexey Samsonov <span dir="ltr"><<a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Looks like this change have caused (or triggered) a memory leak:<br>
<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__lab.llvm.org-3A8011_builders_sanitizer-2Dx86-5F64-2Dlinux-2Dbootstrap_builds_7649_steps_check-2Dllvm-2520asan_logs_stdio&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=bIlkKlezTYE0nZZO2t_nGFnBeRX5n2R8-eXKbVbuiuQ&s=h5dxBepYLtwxtFkURCLgGZgTMxYhRy-vc5skc9L9w4w&e=" rel="noreferrer" target="_blank">http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/7649/steps/check-llvm%20asan/logs/stdio</a><br>
<div><div><br></div></div></blockquote><div><br></div></span><div>Thanks, I'll take a look.</div><div><div class="h5"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>
On Fri, Jun 12, 2015 at 4:26 PM, Eli Bendersky <<a href="mailto:eliben@google.com" target="_blank">eliben@google.com</a>> wrote:<br>
> Author: eliben<br>
> Date: Fri Jun 12 18:26:42 2015<br>
> New Revision: 239646<br>
><br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D239646-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=bIlkKlezTYE0nZZO2t_nGFnBeRX5n2R8-eXKbVbuiuQ&s=gbjK-sFXo-wGEUq07bvLfSmTncK0dWPbK1CZTaiKk4I&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=239646&view=rev</a><br>
> Log:<br>
> Fix returning error message in LLVMLinkModules<br>
><br>
> On error, the temporary output stream wouldn't be flushed and therefore the<br>
> caller would see an empty error message.<br>
><br>
> Patch by Antoine Pitrou<br>
><br>
> Differential Revision: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_D10241&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=bIlkKlezTYE0nZZO2t_nGFnBeRX5n2R8-eXKbVbuiuQ&s=C2bDieflqMFJd4lY6l4y52Li-5tsvxT9duSGL0M5298&e=" rel="noreferrer" target="_blank">http://reviews.llvm.org/D10241</a><br>
><br>
> Modified:<br>
>     llvm/trunk/lib/Linker/LinkModules.cpp<br>
>     llvm/trunk/unittests/Linker/LinkModulesTest.cpp<br>
><br>
> Modified: llvm/trunk/lib/Linker/LinkModules.cpp<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_Linker_LinkModules.cpp-3Frev-3D239646-26r1-3D239645-26r2-3D239646-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=bIlkKlezTYE0nZZO2t_nGFnBeRX5n2R8-eXKbVbuiuQ&s=SA5ZZG95XuhAZAbdpMalVl5x6ahm1ojDY8r48Vk7Oug&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=239646&r1=239645&r2=239646&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/Linker/LinkModules.cpp (original)<br>
> +++ llvm/trunk/lib/Linker/LinkModules.cpp Fri Jun 12 18:26:42 2015<br>
> @@ -1802,7 +1802,9 @@ LLVMBool LLVMLinkModules(LLVMModuleRef D<br>
>    LLVMBool Result = Linker::LinkModules(<br>
>        D, unwrap(Src), [&](const DiagnosticInfo &DI) { DI.print(DP); });<br>
><br>
> -  if (OutMessages && Result)<br>
> +  if (OutMessages && Result) {<br>
> +    Stream.flush();<br>
>      *OutMessages = strdup(Message.c_str());<br>
> +  }<br>
>    return Result;<br>
>  }<br>
><br>
> Modified: llvm/trunk/unittests/Linker/LinkModulesTest.cpp<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_unittests_Linker_LinkModulesTest.cpp-3Frev-3D239646-26r1-3D239645-26r2-3D239646-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=bIlkKlezTYE0nZZO2t_nGFnBeRX5n2R8-eXKbVbuiuQ&s=fX-GAVj-T4s1OIURyrDCuc8933nVyssZqq3idc-CCBU&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Linker/LinkModulesTest.cpp?rev=239646&r1=239645&r2=239646&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/unittests/Linker/LinkModulesTest.cpp (original)<br>
> +++ llvm/trunk/unittests/Linker/LinkModulesTest.cpp Fri Jun 12 18:26:42 2015<br>
> @@ -15,6 +15,7 @@<br>
>  #include "llvm/IR/Module.h"<br>
>  #include "llvm/Linker/Linker.h"<br>
>  #include "llvm/Support/SourceMgr.h"<br>
> +#include "llvm-c/Linker.h"<br>
>  #include "gtest/gtest.h"<br>
><br>
>  using namespace llvm;<br>
> @@ -125,6 +126,22 @@ TEST_F(LinkModuleTest, BlockAddress) {<br>
>    delete LinkedModule;<br>
>  }<br>
><br>
> +static Module *getExternal(LLVMContext &Ctx, StringRef FuncName) {<br>
> +  // Create a module with an empty externally-linked function<br>
> +  Module *M = new Module("ExternalModule", Ctx);<br>
> +  FunctionType *FTy = FunctionType::get(<br>
> +      Type::getVoidTy(Ctx), Type::getInt8PtrTy(Ctx), false /*=isVarArgs*/);<br>
> +<br>
> +  Function *F =<br>
> +      Function::Create(FTy, Function::ExternalLinkage, FuncName, M);<br>
> +  F->setCallingConv(CallingConv::C);<br>
> +<br>
> +  BasicBlock *BB = BasicBlock::Create(Ctx, "", F);<br>
> +  IRBuilder<> Builder(BB);<br>
> +  Builder.CreateRetVoid();<br>
> +  return M;<br>
> +}<br>
> +<br>
>  static Module *getInternal(LLVMContext &Ctx) {<br>
>    Module *InternalM = new Module("InternalModule", Ctx);<br>
>    FunctionType *FTy = FunctionType::get(<br>
> @@ -178,4 +195,27 @@ TEST_F(LinkModuleTest, TypeMerge) {<br>
>              M1->getNamedGlobal("t2")->getType());<br>
>  }<br>
><br>
> +TEST_F(LinkModuleTest, CAPISuccess) {<br>
> +  std::unique_ptr<Module> DestM(getExternal(Ctx, "foo"));<br>
> +  std::unique_ptr<Module> SourceM(getExternal(Ctx, "bar"));<br>
> +  char *errout = nullptr;<br>
> +  LLVMBool result = LLVMLinkModules(wrap(DestM.get()), wrap(SourceM.get()),<br>
> +                                    LLVMLinkerDestroySource, &errout);<br>
> +  EXPECT_EQ(0, result);<br>
> +  EXPECT_EQ(nullptr, errout);<br>
> +  // "bar" is present in destination module<br>
> +  EXPECT_NE(nullptr, DestM->getFunction("bar"));<br>
> +}<br>
> +<br>
> +TEST_F(LinkModuleTest, CAPIFailure) {<br>
> +  // Symbol clash between two modules<br>
> +  std::unique_ptr<Module> DestM(getExternal(Ctx, "foo"));<br>
> +  std::unique_ptr<Module> SourceM(getExternal(Ctx, "foo"));<br>
> +  char *errout = nullptr;<br>
> +  LLVMBool result = LLVMLinkModules(wrap(DestM.get()), wrap(SourceM.get()),<br>
> +                                    LLVMLinkerDestroySource, &errout);<br>
> +  EXPECT_EQ(1, result);<br>
> +  EXPECT_STREQ("Linking globals named 'foo': symbol multiply defined!", errout);<br>
> +}<br>
> +<br>
>  } // end anonymous namespace<br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
<br>
<br>
<br>
</div></div><span><font color="#888888">--<br>
Alexey Samsonov<br>
<a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a><br>
</font></span></blockquote></div></div></div><br></div></div>
</blockquote></div><br></div>