Commit 7932b2ad authored by Simon Peyton Jones's avatar Simon Peyton Jones

Revert "Add purgeObj() to remove the symbol table entries for an object"

This reverts commit 9e6e4796.

I reverted it because one of these two patches
  9e6e4796 Add purgeObj()
  b5e8b3b1 Make the linker API thread-safe

causes a seg-fault on Windows.  The seg-fault happens immediately
the linker is invoked, in ghci or in Template Haskell.

I believe that it is the "linker API thread-safe" commit that causes
the seg-fault; it happens even if the "purgeObj" commit alone is
reverted.  But since the two patches mess with the same code, to
revert the "linker API" patch I had revert both.
parent 9437a24d
......@@ -51,9 +51,6 @@ void *lookupSymbol( char *lbl );
/* delete an object from the pool */
HsInt unloadObj( pathchar *path );
/* purge an object's symbols from the symbol table, but don't unload it */
HsInt purgeObj( pathchar *path );
/* add an obj (populate the global symbol table, but don't resolve yet) */
HsInt loadObj( pathchar *path );
......
......@@ -2280,45 +2280,20 @@ mmap_again:
}
#endif // USE_MMAP
/*
* Remove symbols from the symbol table, and free oc->symbols.
* This operation is idempotent.
*/
static void removeOcSymbols (ObjectCode *oc)
{
if (oc->symbols == NULL) return;
// Remove all the mappings for the symbols within this object..
/* Remove all the mappings for the symbols within this object..
*/
int i;
for (i = 0; i < oc->n_symbols; i++) {
if (oc->symbols[i] != NULL) {
ghciRemoveSymbolTable(symhash, oc->symbols[i], oc);
}
}
stgFree(oc->symbols);
oc->symbols = NULL;
}
/*
* Release StablePtrs and free oc->stable_ptrs.
* This operation is idempotent.
*/
static void freeOcStablePtrs (ObjectCode *oc)
{
// Release any StablePtrs that were created when this
// object module was initialized.
ForeignExportStablePtr *fe_ptr, *next;
for (fe_ptr = oc->stable_ptrs; fe_ptr != NULL; fe_ptr = next) {
next = fe_ptr->next;
freeStablePtr(fe_ptr->stable_ptr);
stgFree(fe_ptr);
}
oc->stable_ptrs = NULL;
}
/*
* freeObjectCode() releases all the pieces of an ObjectCode. It is called by
* the GC when a previously unloaded ObjectCode has been determined to be
......@@ -3065,7 +3040,6 @@ static HsInt loadObj_ (pathchar *path)
if (! loadOc(oc)) {
// failed; free everything we've allocated
removeOcSymbols(oc);
// no need to freeOcStablePtrs, they aren't created until resolveObjs()
freeObjectCode(oc);
return 0;
}
......@@ -3201,7 +3175,7 @@ HsInt resolveObjs (void)
/* -----------------------------------------------------------------------------
* delete an object from the pool
*/
static HsInt unloadObj_ (pathchar *path, rtsBool just_purge)
static HsInt unloadObj_ (pathchar *path)
{
ObjectCode *oc, *prev, *next;
HsBool unloadedAnyObj = HS_BOOL_FALSE;
......@@ -3217,23 +3191,29 @@ static HsInt unloadObj_ (pathchar *path, rtsBool just_purge)
if (!pathcmp(oc->fileName,path)) {
// these are both idempotent, so in just_purge mode we can
// later call unloadObj() to really unload the object.
removeOcSymbols(oc);
freeOcStablePtrs(oc);
if (!just_purge) {
if (prev == NULL) {
objects = oc->next;
} else {
prev->next = oc->next;
}
oc->next = unloaded_objects;
unloaded_objects = oc;
oc->status = OBJECT_UNLOADED;
if (prev == NULL) {
objects = oc->next;
} else {
prev = oc;
prev->next = oc->next;
}
oc->next = unloaded_objects;
unloaded_objects = oc;
// Release any StablePtrs that were created when this
// object module was initialized.
{
ForeignExportStablePtr *fe_ptr, *next;
for (fe_ptr = oc->stable_ptrs; fe_ptr != NULL; fe_ptr = next) {
next = fe_ptr->next;
freeStablePtr(fe_ptr->stable_ptr);
stgFree(fe_ptr);
}
}
oc->status = OBJECT_UNLOADED;
/* This could be a member of an archive so continue
* unloading other members. */
......@@ -3255,15 +3235,7 @@ static HsInt unloadObj_ (pathchar *path, rtsBool just_purge)
HsInt unloadObj (pathchar *path)
{
ACQUIRE_LOCK(&linker_mutex);
HsInt r = unloadObj_(path, rtsFalse);
RELEASE_LOCK(&linker_mutex);
return r;
}
HsInt purgeObj (pathchar *path)
{
ACQUIRE_LOCK(&linker_mutex);
HsInt r = unloadObj_(path, rtsTrue);
HsInt r = unloadObj_(path);
RELEASE_LOCK(&linker_mutex);
return r;
}
......
......@@ -87,41 +87,4 @@ int main (int argc, char *argv[])
printf("%d ", i);
fflush(stdout);
}
for (i=0; i < ITERATIONS; i++) {
r = loadObj(OBJPATH);
if (!r) {
errorBelch("loadObj(%s) failed", OBJPATH);
exit(1);
}
r = resolveObjs();
if (!r) {
errorBelch("resolveObjs failed");
exit(1);
}
#if LEADING_UNDERSCORE
f = lookupSymbol("_f");
#else
f = lookupSymbol("f");
#endif
if (!f) {
errorBelch("lookupSymbol failed");
exit(1);
}
r = f(3);
if (r != 4) {
errorBelch("call failed; %d", r);
exit(1);
}
// check that we can purge first, then unload
purgeObj(OBJPATH);
performMajorGC();
unloadObj(OBJPATH);
performMajorGC();
printf("%d ", i);
fflush(stdout);
}
hs_exit();
exit(0);
}
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment