<div dir="ltr">Hi Adam,<div><br></div><div>Sorry for the late response! I'm very glad you were able to identify and solve the problem, and thank you for sharing your analysis: It will help anyone else who gets tripped up by this.</div><div><br></div><div>Regards,</div><div>Lang.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, May 29, 2020 at 1:22 PM Straw, Adam D <<a href="mailto:adam.d.straw@intel.com">adam.d.straw@intel.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
<div lang="EN-US">
<div class="gmail-m_4840255777136693674WordSection1">
<p class="MsoNormal">Closing the gap on this. Moving nGraph MLIR pointer to the 3c5ddd58 git hash did indeed fix the problem. Thanks so much for all the help.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div style="border-style:solid none none;border-top-width:1pt;border-top-color:rgb(225,225,225);padding:3pt 0in 0in">
<p class="MsoNormal"><b>From:</b> Straw, Adam D <br>
<b>Sent:</b> Wednesday, May 27, 2020 11:54 AM<br>
<b>To:</b> Lang Hames <<a href="mailto:lhames@gmail.com" target="_blank">lhames@gmail.com</a>>; David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>><br>
<b>Cc:</b> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>; Cyphers, Scott <<a href="mailto:Scott.Cyphers@intel.com" target="_blank">Scott.Cyphers@intel.com</a>>; Bobba, Jayaram <<a href="mailto:jayaram.bobba@intel.com" target="_blank">jayaram.bobba@intel.com</a>>; Mostafa, Nagy H <<a href="mailto:Nagy.H.Mostafa@intel.com" target="_blank">Nagy.H.Mostafa@intel.com</a>>; Iyer, Swapna <<a href="mailto:swapna.iyer@intel.com" target="_blank">swapna.iyer@intel.com</a>>; Caballero, Diego <<a href="mailto:diego.caballero@intel.com" target="_blank">diego.caballero@intel.com</a>><br>
<b>Subject:</b> RE: [llvm-dev] [ORC JIT][MLIR] GDBRegistrationListener "second attempt to perform debug registration" assert<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Lang,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">It looks like the change I need is here, correct?<u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Segoe UI",sans-serif"><a href="https://github.com/llvm/llvm-project/commit/3c5dd5863c34ecd51e9d2a49929877d8151dea39" title="https://github.com/llvm/llvm-project/commit/3c5dd5863c34ecd51e9d2a49929877d8151dea39" target="_blank">https://github.com/llvm/llvm-project/commit/3c5dd5863c34ecd51e9d2a49929877d8151dea39</a><u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I would like to move the nGraph MLIR pointer all the way to the tip of master but it is expensive (lots of compile and link issues) so hoping to take a baby step.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Adam <u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div style="border-style:solid none none;border-top-width:1pt;border-top-color:rgb(225,225,225);padding:3pt 0in 0in">
<p class="MsoNormal"><b>From:</b> Straw, Adam D <br>
<b>Sent:</b> Tuesday, May 26, 2020 1:17 PM<br>
<b>To:</b> Lang Hames <<a href="mailto:lhames@gmail.com" target="_blank">lhames@gmail.com</a>>; David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>><br>
<b>Cc:</b> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>; Cyphers, Scott <<a href="mailto:Scott.Cyphers@intel.com" target="_blank">Scott.Cyphers@intel.com</a>>; Bobba, Jayaram <<a href="mailto:jayaram.bobba@intel.com" target="_blank">jayaram.bobba@intel.com</a>>; Mostafa,
Nagy H <<a href="mailto:Nagy.H.Mostafa@intel.com" target="_blank">Nagy.H.Mostafa@intel.com</a>>; Iyer, Swapna <<a href="mailto:swapna.iyer@intel.com" target="_blank">swapna.iyer@intel.com</a>><br>
<b>Subject:</b> RE: [llvm-dev] [ORC JIT][MLIR] GDBRegistrationListener "second attempt to perform debug registration" assert<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Referring to the log messages from my previous mail… I confused myself (and probably others) by reading the “<span style="font-family:"Courier New"">Adding MemMgr 0x55555959f440</span>“ message as “<b><i><span style="font-family:"Courier New"">Registering</span></i></b><span style="font-family:"Courier New"">
MemMgr 0x55555959f440</span>”. Thus the address mismatch made no sense. How could we be registering a `MemMgr` address/key that does not match once we arrive in `notifyObjectLoaded` method?<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Answer: Because the registrations is NOT coming from RTDyldObjectLinkingLayer.cpp. I found this first by adding an additional debug statement (highlighted) thinking the `reinterpret_cast` may be at fault for the key mismatch. I never
saw this print and I then realized my “Adding” vs. “Registering” mistake.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-family:"Courier New""> // Run EventListener notifyLoaded callbacks.<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-family:"Courier New""> {<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-family:"Courier New""> std::lock_guard<std::mutex> Lock(RTDyldLayerMutex);<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-family:"Courier New""> dbgs() << "Registering MemMgr " << MemMgr << "\n";<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-family:"Courier New""> auto LOIItr = LoadedObjInfos.find(MemMgr);<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-family:"Courier New""> assert(LOIItr != LoadedObjInfos.end() && "LoadedObjInfo missing");<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-family:"Courier New""> for (auto *L : EventListeners) {<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-family:"Courier New"">
<span style="background-color:yellow;background-position:initial initial;background-repeat:initial initial">dbgs() << " key = " << reinterpret_cast<uintptr_t>(MemMgr) << "\n";</span><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-family:"Courier New""> L->notifyObjectLoaded(<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-family:"Courier New""> static_cast<uint64_t>(reinterpret_cast<uintptr_t>(MemMgr)), *Obj,<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-family:"Courier New""> *LOIItr->second);<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-family:"Courier New""> }<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-family:"Courier New""> LoadedObjInfos.erase(MemMgr);<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-family:"Courier New""> }</span><u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">So, where is the registration coming from? Remember that I am on a slightly older version of MLIR. My mlir/lib/ExecutionEngine/ExecutionEngine.cpp has the following code with highlighted debug statement added by me:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-family:"Courier New""> objectLayer->setNotifyLoaded(<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-family:"Courier New""> [engine = engine.get()](<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-family:"Courier New""> llvm::orc::VModuleKey, const llvm::object::ObjectFile &object,<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-family:"Courier New""> const llvm::RuntimeDyld::LoadedObjectInfo &objectInfo) {<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-family:"Courier New""> if (engine->gdbListener) {<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-family:"Courier New""> uint64_t key = static_cast<uint64_t>(<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-family:"Courier New""> reinterpret_cast<uintptr_t>(object.getData().data()));<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-family:"Courier New"">
<span style="background-color:yellow;background-position:initial initial;background-repeat:initial initial">dbgs() << "ExecutionEngine key = " << key << "\n";</span><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-family:"Courier New""> engine->gdbListener->notifyObjectLoaded(key, object, objectInfo);<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-family:"Courier New""> }<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-family:"Courier New""> });<u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">The key printed here matches the key printed in `notifyObjectLoaded`. This code is NOT present at the tip of MLIR master. Hence the solution here may be to move to latest MLIR master which I probably should have tried before sending this
mail. Will do that now.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Adam<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div style="border-style:solid none none;border-top-width:1pt;border-top-color:rgb(225,225,225);padding:3pt 0in 0in">
<p class="MsoNormal"><b>From:</b> Straw, Adam D <br>
<b>Sent:</b> Tuesday, May 26, 2020 9:41 AM<br>
<b>To:</b> Lang Hames <<a href="mailto:lhames@gmail.com" target="_blank">lhames@gmail.com</a>>; David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>><br>
<b>Cc:</b> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>; Cyphers, Scott <<a href="mailto:Scott.Cyphers@intel.com" target="_blank">Scott.Cyphers@intel.com</a>>; Bobba, Jayaram <<a href="mailto:jayaram.bobba@intel.com" target="_blank">jayaram.bobba@intel.com</a>>; Mostafa,
Nagy H <<a href="mailto:Nagy.H.Mostafa@intel.com" target="_blank">Nagy.H.Mostafa@intel.com</a>>; Iyer, Swapna <<a href="mailto:swapna.iyer@intel.com" target="_blank">swapna.iyer@intel.com</a>><br>
<b>Subject:</b> RE: [llvm-dev] [ORC JIT][MLIR] GDBRegistrationListener "second attempt to perform debug registration" assert<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Sorry for the delay. Hope everyone had a good long weekend. See attached log captured from GDB session. Here is the punchline:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-family:"Courier New";background-color:yellow;background-position:initial initial;background-repeat:initial initial">Adding MemMgr 0x55555959f440</span><span style="font-family:"Courier New""><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-family:"Courier New"">unit-test: /localdisk/adstraw/ngraph/build/mlir_project/llvm-project/llvm/lib/ExecutionEngine/GDBRegistrationListener.cpp:164: virtual void {anonymous}::GDBJITRegistrationListener::notifyObjectLoaded(llvm::JITEventListener::ObjectKey,
const llvm::object::ObjectFile&, const llvm::RuntimeDyld::LoadedObjectInfo&): Assertion `ObjectBufferMap.find(K) == ObjectBufferMap.end() && "Second attempt to perform debug registration."' failed.<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-family:"Courier New"">(gdb) print/x K<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:0.5in"><span style="font-family:"Courier New"">$2 = 0x555559605c50</span><u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">The key (K) causing the assert a) does not match the addresses of the most recently added MemMgr and b) does not match the address of ANY MemMgr in the entire log file. The plot thickens.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Wondering if there is some other object (besides a MemMgr) that registers its address-as-key into `ObjectBufferMap`.
<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Adam <u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><b>From:</b> Lang Hames <<a href="mailto:lhames@gmail.com" target="_blank">lhames@gmail.com</a>>
<br>
<b>Sent:</b> Thursday, May 21, 2020 4:53 PM<br>
<b>To:</b> David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>><br>
<b>Cc:</b> Straw, Adam D <<a href="mailto:adam.d.straw@intel.com" target="_blank">adam.d.straw@intel.com</a>>;
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>; Cyphers, Scott <<a href="mailto:scott.cyphers@intel.com" target="_blank">scott.cyphers@intel.com</a>>; Bobba, Jayaram <<a href="mailto:jayaram.bobba@intel.com" target="_blank">jayaram.bobba@intel.com</a>>; Mostafa, Nagy
H <<a href="mailto:nagy.h.mostafa@intel.com" target="_blank">nagy.h.mostafa@intel.com</a>><br>
<b>Subject:</b> Re: [llvm-dev] [ORC JIT][MLIR] GDBRegistrationListener "second attempt to perform debug registration" assert<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<div>
<p class="MsoNormal">Hi Adam,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Calls to the listeners should be protected by the RTDyldLayerMutex. Could you apply the attached patch and share the debugging output from one of the failing runs?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Regards,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Lang.<u></u><u></u></p>
</div>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">On Wed, May 20, 2020 at 8:00 PM David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border-style:none none none solid;border-left-width:1pt;border-left-color:rgb(204,204,204);padding:0in 0in 0in 6pt;margin:5pt 0in 5pt 4.8pt">
<div>
<p class="MsoNormal">+Lang<u></u><u></u></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">On Wed, May 20, 2020 at 4:44 PM Straw, Adam D via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border-style:none none none solid;border-left-width:1pt;border-left-color:rgb(204,204,204);padding:0in 0in 0in 6pt;margin:5pt 0in 5pt 4.8pt">
<div>
<div>
<p class="MsoNormal">Hi all,<u></u><u></u></p>
<p class="MsoNormal">Attention: Lang Hames<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">I am developing the
<a href="https://github.com/NervanaSystems/ngraph/tree/master/src/contrib/mlir" target="_blank">
nGraph MLIR</a> implementation and hitting the following assert while running nGraph unit tests:<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> assert(ObjectBufferMap.find(K) == ObjectBufferMap.end() &&</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> "Second attempt to perform debug registration.");</span><u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">Here is a
<a href="https://github.com/llvm/llvm-project/blob/3d5360a4398bfa6878f94ca9ac55bc568692c765/llvm/lib/ExecutionEngine/GDBRegistrationListener.cpp#L163" target="_blank">
permalink</a> for that line of code on GitHub. The failure only occurs when running multiple unit tests back-to-back. Inevitably, if I rerun the failing unit test, it passes. The failure also tends to move around with a different unit tests failing on successive
runs.<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">I am able to hit the failure in GDB. Here is a partial backtrace:<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal" style="margin-left:0.5in">
<span style="font-family:"Courier New"">#3 0x00007fffec4cf412 in __GI___assert_fail (assertion=assertion@entry=0x7ffff1d145e0 "ObjectBufferMap.find(K) == ObjectBufferMap.end() && \"Second attempt to perform debug registration.\"",
</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:0.5in">
<span style="font-family:"Courier New""> file=file@entry=0x7ffff1d144d8 "/localdisk/adstraw/ngraph/build/mlir_project/llvm-project/llvm/lib/ExecutionEngine/GDBRegistrationListener.cpp", line=line@entry=164,
</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:0.5in">
<span style="font-family:"Courier New""> function=function@entry=0x7ffff1d15520 <(anonymous namespace)::GDBJITRegistrationListener::notifyObjectLoaded(unsigned long, llvm::object::ObjectFile const&, llvm::RuntimeDyld::LoadedObjectInfo const&)::__PRETTY_FUNCTION__>
"virtual void {anonymous}::GDBJITRegistrationListener::notifyObjectLoaded(llvm::JITEventListener::ObjectKey, const llvm::object::ObjectFile&, const llvm::RuntimeDyld::LoadedObjectInfo&)")</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:0.5in">
<span style="font-family:"Courier New""> at assert.c:101</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:0.5in">
<span style="font-family:"Courier New"">#4 0x00007ffff01ed4d3 in (anonymous namespace)::GDBJITRegistrationListener::notifyObjectLoaded (this=0x5555591a9270,
<span style="color:black;background-color:yellow;background-position:initial initial;background-repeat:initial initial">K=93825060893584</span>, Obj=..., L=...)</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:0.5in">
<span style="font-family:"Courier New""> at /localdisk/adstraw/ngraph/build/mlir_project/llvm-project/llvm/lib/ExecutionEngine/GDBRegistrationListener.cpp:163</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:0.5in">
<span style="font-family:"Courier New"">#5 0x00007ffff01b0eca in std::function<void (unsigned long, llvm::object::ObjectFile const&, llvm::RuntimeDyld::LoadedObjectInfo const&)>::operator()(unsigned long, llvm::object::ObjectFile const&, llvm::RuntimeDyld::LoadedObjectInfo
const&) const (__args#2=..., __args#1=..., __args#0=<optimized out>, this=0x5555594e09b8) at /usr/include/c++/7/bits/std_function.h:706</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:0.5in">
<span style="font-family:"Courier New"">#6 llvm::orc::RTDyldObjectLinkingLayer::onObjLoad (this=<optimized out>,
<span style="color:black;background-color:yellow;background-position:initial initial;background-repeat:initial initial">K=3</span>, R=..., Obj=..., MemMgr=0x5555591c4160, LoadedObjInfo=std::unique_ptr<llvm::RuntimeDyld::LoadedObjectInfo> = {...},
</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:0.5in">
<span style="font-family:"Courier New""> Resolved=std::map with 8 elements = {...}, InternalSymbols=std::set with 0 elements)</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:0.5in">
<span style="font-family:"Courier New""> at /localdisk/adstraw/ngraph/build/mlir_project/llvm-project/llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp:267</span><u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">A little debug context:<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<ul type="disc">
<li class="MsoNormal">
<b>Frame #6</b> with K=3 we are about to execute the `NotifyLoaded` callback<u></u><u></u></li><li class="MsoNormal">
<b>Frame #5</b> we execute the `NotifyLoaded` callback which apparently transforms K from 3 to 93825060893584 (0x5555596CF390) which looks like a pointer. I don’t know the code well enough to grok what’s going on here. I’m not even sure where this callback
resides, but it could be <a href="https://github.com/llvm/llvm-project/blob/c66f89005f6d23b6885d8f93f33ff27dc60ce7dd/llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp#L312" target="_blank">
here</a> in RTDyldObjectLinkingLater.cpp where we are using the address of the `MemMgr` as K.<u></u><u></u></li><li class="MsoNormal">
<b>Frame #4 </b>now in `notifyObjectLoaded` with K=93825060893584 which will go on to assert in
<b>frame #3</b> due to the fact that that key (K) already exists in the map<u></u><u></u></li></ul>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">All of this leads me to believe there is some sort of race. Theory: with two unit tests A and B running back to back…<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<ol start="1" type="1">
<li class="MsoNormal">
Unit test A allocates and deallocates a `MemMgr` (or whatever other object we are using for a key) at address X<u></u><u></u></li><li class="MsoNormal">
Unit test A calls ` notifyFreeingObject` to free the object at K=X but gets stuck (does not lock) the ` JITDebugLock` mutex
<a href="https://github.com/llvm/llvm-project/blob/3d5360a4398bfa6878f94ca9ac55bc568692c765/llvm/lib/ExecutionEngine/GDBRegistrationListener.cpp#L181" target="_blank">
here</a> for whatever reason<u></u><u></u></li><li class="MsoNormal">
Meanwhile unit test B allocates a `MemMgr` (or whatever other object we are using for a key) at newly freed address X<u></u><u></u></li><li class="MsoNormal">
Unit test B calls `notifyObjectLoaded` to register the object at K=X and locks the ` JITDebugLock`
<a href="https://github.com/llvm/llvm-project/blob/3d5360a4398bfa6878f94ca9ac55bc568692c765/llvm/lib/ExecutionEngine/GDBRegistrationListener.cpp#L162" target="_blank">
here</a> with unit test A still waiting in step #2 above<u></u><u></u></li><li class="MsoNormal">
This goes on to assert as the key was not erased (step #2) before it was added (step #4)<u></u><u></u></li></ol>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">I could use a little help to debug the error further. Curiously, we do hit this issue in continuous integration (CI) --- only when running on development systems “by hand”. I
am investigating the differences (perhaps single vs. multi threaded?) as to why this might be the case.<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">Note that I am using a slightly old version of MLIR master, I’m at this commit:<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal" style="margin-left:0.5in">
<span style="font-family:"Courier New"">commit 2f8b4545f4960778e37114c024073d208751ca89</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:0.5in">
<span style="font-family:"Courier New"">Author: Adam Straw <<a href="mailto:adam.d.straw@intel.com" target="_blank">adam.d.straw@intel.com</a>></span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:0.5in">
<span style="font-family:"Courier New"">Date: Tue Apr 14 22:49:18 2020 +0300</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:0.5in">
<span style="font-family:"Courier New""> </span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:0.5in">
<span style="font-family:"Courier New""> [mlir] Fix assert on signed integer type in EDSC</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:0.5in">
<span style="font-family:"Courier New""> </span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:0.5in">
<span style="font-family:"Courier New""> Integer type in Std dialect is signless so we should be checking</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:0.5in">
<span style="font-family:"Courier New""> for signless integer type instead of signed integer type in EDSC.</span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:0.5in">
<span style="font-family:"Courier New""> </span><u></u><u></u></p>
<p class="MsoNormal" style="margin-left:0.5in">
<span style="font-family:"Courier New""> Differential Revision: <a href="https://reviews.llvm.org/D78144" target="_blank">
https://reviews.llvm.org/D78144</a></span><u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">Thanks in advance for the help.<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">Adam<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">Note: I am out of office this Fri and the following Mon but otherwise should be prompt with email replies.<u></u><u></u></p>
<p class="MsoNormal"><span style="font-family:"Courier New""> </span><u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
<p class="MsoNormal">_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><u></u><u></u></p>
</blockquote>
</div>
</blockquote>
</div>
</div>
</div>
</blockquote></div>