[PATCH] acpica: fix disassembly on i386 platforms (LP: #1547469)

Colin King colin.king at canonical.com
Fri Feb 19 14:42:01 UTC 2016


From: Colin Ian King <colin.king at canonical.com>

On i386 builds on Xenial I'm seeing:

*** Error in `/home/king/repos/fwts/src/.libs/lt-fwts': double free or
  corruption (!prev): 0x08bfb010 ***

this occurs because AcpiGbl_ParseOpRoot is being deleted and not being
set back to NULL, so subsequent parsing of externally loaded tables
append to this non-null tree with the last Op nodes and this causes
issues when we free these objects twice on the subsequent call of
AcpiPsDeleteParseTree.  We need to always ensure AcpiGbl_ParseOpRoot
is NULL after deleting the parse tree from it.

The second set of fixes syncs the disassembly code with the current
iASL main disassbly idoims.

Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
 src/acpica/source/common/adisasm.c               |  1 +
 src/acpica/source/compiler/fwts_iasl_interface.c | 14 ++++++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/acpica/source/common/adisasm.c b/src/acpica/source/common/adisasm.c
index 3dabe3b..520863c 100644
--- a/src/acpica/source/common/adisasm.c
+++ b/src/acpica/source/common/adisasm.c
@@ -700,6 +700,7 @@ AdDoExternalFileList (
             AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot,
                 AcpiGbl_RootNode, OwnerId);
             AcpiPsDeleteParseTree (AcpiGbl_ParseOpRoot);
+            AcpiGbl_ParseOpRoot = NULL;
 
             ExternalListHead = ExternalListHead->Next;
         }
diff --git a/src/acpica/source/compiler/fwts_iasl_interface.c b/src/acpica/source/compiler/fwts_iasl_interface.c
index 83fb926..d0ffcb7 100644
--- a/src/acpica/source/compiler/fwts_iasl_interface.c
+++ b/src/acpica/source/compiler/fwts_iasl_interface.c
@@ -39,9 +39,15 @@ static void init_asl_core(void)
 {
 	int i;
 
+	AcpiOsInitialize();
+	ACPI_DEBUG_INITIALIZE();
 	AcpiGbl_ExternalFileList = NULL;
 	AcpiDbgLevel = 0;
-	PrInitializePreprocessor ();
+	PrInitializePreprocessor();
+	AcpiGbl_DmOpt_Verbose = FALSE;
+	AcpiGbl_IntegerBitWidth = 64;
+	AcpiGbl_IntegerNybbleWidth = 16;
+	AcpiGbl_IntegerByteWidth = 8;
 
 	for (i = 0; i < ASL_NUM_FILES; i++) {
 		Gbl_Files[i].Handle = NULL;
@@ -53,7 +59,7 @@ static void init_asl_core(void)
 	Gbl_Files[ASL_FILE_STDERR].Handle   = stdout;
 	Gbl_Files[ASL_FILE_STDERR].Filename = "STDOUT";
 
-	Gbl_LineBufferSize = 16384;
+	Gbl_LineBufferSize = 1024;
 	Gbl_CurrentLineBuffer = NULL;
 	Gbl_MainTokenBuffer = NULL;
 	UtExpandLineBuffers();
@@ -133,6 +139,10 @@ int fwts_iasl_disassemble_aml(
 
 		/* ...and do the ACPICA disassambly... */
 		AslDoOneFile((char *)tables[which]);
+		UtFreeLineBuffers();
+		AslParserCleanup();
+		if (AcpiGbl_ExternalFileList)
+			AcpiDmClearExternalFileList();
 
 		fclose(fperr);
 		fclose(fpout);
-- 
2.7.0




More information about the fwts-devel mailing list