From owner-acpi-jp@jp.freebsd.org  Thu Dec 14 20:01:01 2000
Received: (from daemon@localhost)
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) id UAA66551;
	Thu, 14 Dec 2000 20:01:01 +0900 (JST)
	(envelope-from owner-acpi-jp@jp.FreeBSD.org)
Received: from tasogare.imasy.or.jp (daemon@tasogare.imasy.or.jp [202.227.24.5])
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) with ESMTP id UAA66545
	for <acpi-jp@jp.freebsd.org>; Thu, 14 Dec 2000 20:00:58 +0900 (JST)
	(envelope-from iwasaki@jp.FreeBSD.org)
Received: from localhost (iwasaki.imasy.or.jp [202.227.24.92])
	by tasogare.imasy.or.jp (8.11.1+3.4W/3.7W-tasogare/smtpfeed 1.07) with ESMTP id eBEB0pk47646
	for <acpi-jp@jp.freebsd.org>; Thu, 14 Dec 2000 20:00:52 +0900 (JST)
	(envelope-from iwasaki@jp.FreeBSD.org)
To: acpi-jp@jp.freebsd.org
X-Mailer: Mew version 1.94.1 on Emacs 19.34 / Mule 2.3 (SUETSUMUHANA)
Mime-Version: 1.0
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-Id: <20001214200045D.iwasaki@jp.FreeBSD.org>
Date: Thu, 14 Dec 2000 20:00:45 +0900
From: Mitsuru IWASAKI <iwasaki@jp.freebsd.org>
X-Dispatcher: imput version 20000228(IM140)
Lines: 49
Reply-To: acpi-jp@jp.freebsd.org
Precedence: list
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+000315
X-Sequence: acpi-jp 962
Subject: [acpi-jp 962] patch against AcpiDsInitObjectFromOp()
Errors-To: owner-acpi-jp@jp.freebsd.org
Sender: owner-acpi-jp@jp.freebsd.org
X-Originator: iwasaki@jp.freebsd.org

Hi, I'm trying to make ACPICA debugger to work in userland, and found
a problem on memory allocation for String Object in Dispatcher subsystem.

When I terminate the debugger, I always get following core dump.

ACPI Subsystem version [Dec 14 2000]
Parsing Methods:.........................................................................................................................................................................
169 Control Methods found and parsed (499 nodes total)
ACPI Namespace successfully loaded at root 0x808eac4
- q
cmdelete-0300: *** Error: _CmFree: Entry not found in list
 cmalloc-0441: _CmFree: Entry 0x28146cd9 was not found in allocation list
acpicadb in free(): error: junk pointer, too high to make sense.
Abort(core dumped)

This problem was caused by freeing string pointer to memory mapped
DSDT data block.  I think decoded string data from DSDT should be
duplicated into the memory block allocated by ACPICA memory management
subsystem.
# This is not serious problem though :-)
# because we never terminate ACPICA explicitly in kerenl space for now.

Here is a patch for this problem.  Any comments are welcome as always.
Thanks

Index: dsobject.c
===================================================================
RCS file: /home/ncvs/src/sys/contrib/dev/acpica/Subsystem/Dispatcher/dsobject.c,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 dsobject.c
--- dsobject.c	2000/12/08 09:20:36	1.1.1.3
+++ dsobject.c	2000/12/14 05:26:56
@@ -445,8 +445,14 @@
 
 
     case ACPI_TYPE_STRING:
-        (*ObjDesc)->String.Pointer = Op->Value.String;
         (*ObjDesc)->String.Length = STRLEN (Op->Value.String);
+        (*ObjDesc)->String.Pointer =
+                            AcpiCmCallocate ((*ObjDesc)->String.Length + 1);
+        if (!(*ObjDesc)->String.Pointer)
+        {
+            return (AE_NO_MEMORY);
+        }
+        STRNCPY((*ObjDesc)->String.Pointer, Op->Value.String, (*ObjDesc)->String.Length);
         break;
 
 

