From ee2e9ece388e75ac433097ac726a555a07ae0830 Mon Sep 17 00:00:00 2001 From: Tamar Christina Date: Sat, 19 Aug 2017 08:31:34 +0100 Subject: 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 --- rts/linker/PEi386.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'rts/linker') diff --git a/rts/linker/PEi386.c b/rts/linker/PEi386.c index 22258fe970..42e700805e 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; } -- cgit v1.2.1