[commit: ghc] master: Correct incorrect free in PE linker (ee2e9ec)
git at git.haskell.org
git at git.haskell.org
Sat Aug 19 07:32:02 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/ee2e9ece388e75ac433097ac726a555a07ae0830/ghc
>---------------------------------------------------------------
commit ee2e9ece388e75ac433097ac726a555a07ae0830
Author: Tamar Christina <tamar at zhox.com>
Date: Sat Aug 19 08:31:34 2017 +0100
Correct incorrect free in PE linker
Summary:
The big-obj support (D3523) had introduced an early free on
the info structure. Because the pointer is not NULL'd
and the default of all the utility functions was to the
standard object format, it all kept working.
The one big-obj test that exists was subjected to a timing issue.
usually the test ran quickly enough that the allocator hasn't
had time to reclaim the memory yet, so it still passed.
This corrects it. Also as it so happens, static LLVM libraries
from mingw-w64 are compiled using big-obj.
Test Plan: ./validate
Reviewers: austin, bgamari, erikd, simonmar
Reviewed By: bgamari
Subscribers: rwbarton, thomie
GHC Trac Issues: #13815, #13093
Differential Revision: https://phabricator.haskell.org/D3862
>---------------------------------------------------------------
ee2e9ece388e75ac433097ac726a555a07ae0830
rts/linker/PEi386.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/rts/linker/PEi386.c b/rts/linker/PEi386.c
index 22258fe..42e7008 100644
--- a/rts/linker/PEi386.c
+++ b/rts/linker/PEi386.c
@@ -1421,6 +1421,7 @@ ocGetNames_PEi386 ( ObjectCode* oc )
addr = (char*)cstring_from_COFF_symbol_name(
getSymShortName (info, symtab_i),
strtab);
+ stgFree (info);
IF_DEBUG(linker,
debugBelch("addImportSymbol `%s' => `%s'\n",
@@ -1471,8 +1472,6 @@ ocGetNames_PEi386 ( ObjectCode* oc )
i += getSymNumberOfAuxSymbols (info, symtab_i);
}
- stgFree (info);
-
/* Allocate BSS space */
SymbolAddr* bss = NULL;
if (globalBssSize > 0) {
@@ -1570,6 +1569,7 @@ ocGetNames_PEi386 ( ObjectCode* oc )
if (result != NULL || dllInstance == 0) {
errorBelch("Could not load `%s'. Reason: %s\n",
(char*)dllName, result);
+ stgFree (info);
return false;
}
@@ -1599,8 +1599,10 @@ ocGetNames_PEi386 ( ObjectCode* oc )
sname[size-start]='\0';
stgFree(tmp);
if (!ghciInsertSymbolTable(oc->fileName, symhash, (SymbolName*)sname,
- addr, false, oc))
+ addr, false, oc)) {
+ stgFree (info);
return false;
+ }
break;
}
@@ -1617,6 +1619,7 @@ ocGetNames_PEi386 ( ObjectCode* oc )
if (! ghciInsertSymbolTable(oc->fileName, symhash, (SymbolName*)sname, addr,
isWeak, oc)) {
+ stgFree (info);
return false;
}
} else {
@@ -1650,6 +1653,7 @@ ocGetNames_PEi386 ( ObjectCode* oc )
i += getSymNumberOfAuxSymbols (info, symtab_i);
}
+ stgFree (info);
return true;
}
More information about the ghc-commits
mailing list