<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote"><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">


Ryan, can you do one final thing? When you run that program, be sure<br>
to specify `+RTS -Dl` (must be linked with -debug.) This will enable<br>
all the debug output where the linker is concerned. There will be a<br>
few hundred lines just for initialization (based on my machine.) If my<br>
theory is correct, you&#39;ll probably see stuff like &#39;Unloading object<br>
file ...&#39; right as the invalid read/segfault occurs.</blockquote><div><br></div><div>Hi Austin,</div><div><br></div><div>I did this, and it produced a 97MB text file of debug output, the tail end of which was:</div><div>

<br></div><div><div><font face="courier new, monospace" size="1"><b>initLinker: idempotent return</b></font></div><div><font face="courier new, monospace" size="1"><b>lookupSymbol: value of stg_gc_unpt_r1 is 0x485570</b></font></div>

<div><font face="courier new, monospace" size="1"><b>`stg_gc_unpt_r1&#39; resolves to 0x485570Reloc: P = 0x40b510f3   S = 0x485570   A = 0xfffffffffffffffc</b></font></div><div><font face="courier new, monospace" size="1"><b>relocations for section 3 using symtab 8</b></font></div>

<div><font face="courier new, monospace" size="1"><b>Rel entry   0 is raw( (nil) 0x800000001  (nil))   lookupSymbol: looking up base_ControlziApplicative_zdfApplicativeIO3_info</b></font></div><div><font face="courier new, monospace" size="1"><b>initLinker: start</b></font></div>

<div><font face="courier new, monospace" size="1"><b>initLinker: idempotent return</b></font></div><div><font face="courier new, monospace" size="1"><b>lookupSymbol: value of base_ControlziApplicative_zdfApplicativeIO3_info is 0x40b51058</b></font></div>

<div><font face="courier new, monospace" size="1"><b>`base_ControlziApplicative_zdfApplicativeIO3_info&#39; resolves to 0x40b51058Reloc: P = 0x40b51100   S = 0x40b51058   A = (nil)</b></font></div><div><font face="courier new, monospace" size="1"><b>resolveObjs: done</b></font></div>

<div><font face="courier new, monospace" size="1"><b>lookupSymbol: looking up f</b></font></div><div><font face="courier new, monospace" size="1"><b>initLinker: start</b></font></div><div><font face="courier new, monospace" size="1"><b>initLinker: idempotent return</b></font></div>

<div><font face="courier new, monospace" size="1"><b>lookupSymbol: value of f is 0x440330c0</b></font></div><div><font face="courier new, monospace" size="1"><b>initLinker: start</b></font></div><div><font face="courier new, monospace" size="1"><b>initLinker: idempotent return</b></font></div>

<div><font face="courier new, monospace" size="1"><b>unloadObj: Test.o</b></font></div><div><font face="courier new, monospace" size="1"><b>Checking whether to unload Test.o</b></font></div><div><font face="courier new, monospace" size="1"><b>Unloading object file Test.o</b></font></div>

</div><div><br></div><div>And that&#39;s when it segfaulted (notusing valgrind).  If it is of any use, here is the full output, which fortunately compresses down to 4.4MB:</div><div><br></div><div>    <a href="http://www.cs.indiana.edu/~rrnewton/temp/linker_unload_debug_output.txt.bz2">http://www.cs.indiana.edu/~rrnewton/temp/linker_unload_debug_output.txt.bz2</a><br>

</div><div><br></div><div>Best,</div><div>  -Ryan</div><div><br></div><div>P.S. Here is the equivalent output from the same thing being run under valgrind:</div><div><br></div><div><div>initLinker: idempotent return</div>

<div>lookupSymbol: value of base_ControlziApplicative_zdfApplicativeIO3_info is 0x4c15058</div><div>`base_ControlziApplicative_zdfApplicativeIO3_info&#39; resolves to 0x4c15058Reloc: P = 0x4c15100   S = 0x4c15058   A = (nil)</div>

<div>resolveObjs: done</div><div>lookupSymbol: looking up f</div><div>initLinker: start</div><div>initLinker: idempotent return</div><div>lookupSymbol: value of f is 0x4c0f0c0</div><div>initLinker: start</div><div>initLinker: idempotent return</div>

<div>unloadObj: Test.o</div><div>Checking whether to unload Test.o</div><div>Unloading object file Test.o</div><div>==9030== Invalid read of size 8</div><div>==9030==    at 0x492502: checkUnload (CheckUnload.c:286)</div>
<div>
==9030==    by 0x476580: GarbageCollect (GC.c:666)</div><div>==9030==    by 0x46ADCD: scheduleDoGC (Schedule.c:1652)</div><div>==9030==    by 0x46B976: performGC_ (Schedule.c:2551)</div><div>==9030==    by 0x46B9AE: performMajorGC (Schedule.c:2565)</div>

<div>==9030==    by 0x4043E1: main (in /home/beehive/ryan_scratch/ghc-working/testsuite/tests/rts/linker_unload2)</div><div>==9030==  Address 0x95c4580 is 80 bytes inside a block of size 120 free&#39;d</div><div>==9030==    at 0x4A063F0: free (vg_replace_malloc.c:446)</div>

<div>==9030==    by 0x4656D5: stgFree (RtsUtils.c:107)</div><div>==9030==    by 0x45DDF4: freeObjectCode (Linker.c:2087)</div><div>==9030==    by 0x4924CF: checkUnload (CheckUnload.c:295)</div><div>==9030==    by 0x476580: GarbageCollect (GC.c:666)</div>

<div>==9030==    by 0x46ADCD: scheduleDoGC (Schedule.c:1652)</div><div>==9030==    by 0x46B976: performGC_ (Schedule.c:2551)</div><div>==9030==    by 0x46B9AE: performMajorGC (Schedule.c:2565)</div><div>==9030==    by 0x4043E1: main (in /home/beehive/ryan_scratch/ghc-working/testsuite/tests/rts/linker_unload2)</div>

<div>==9030==</div></div><div><br></div><div><br></div><div><br></div></div></div></div>