Subject: pkg/34870: Incorrect patch in textproc/jade
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: K Suominen <kalevi.suominen@helsinki.fi>
List: pkgsrc-bugs
Date: 10/20/2006 15:50:00
>Number:         34870
>Category:       pkg
>Synopsis:       Incorrect patch in textproc/jade
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Oct 20 15:50:00 +0000 2006
>Originator:     K Suominen
>Release:        NetBSD 2.0
>Organization:
	
>Environment:
	
	
System: NetBSD weber.home 2.0 NetBSD 2.0 (WEBER_SB) #9: Sat Mar 18 14:36:03 EET 2006 jks@weber.home:/usr/src/sys/arch/i386/compile/WEBER_SB i386
Architecture: i386
Machine: i386
>Description:
	Some classes based on Resource (such as AttributeValue) contain
	virtual functions. An object of such a class begins with the vtable
	pointer, and the Resource object (counter) is offset by the size
	of the pointer (4). Hence the cast of (a pointer to) such an object
	to (a pointer to) Resource, introduced in "patch-ap", is wrong.
	(It typically leads to the corruption of the vtable pointer with
	ensueing SIGSEGV and core dump.)
>How-To-Repeat:
	
>Fix:
	Remove "patch-ap". The remaining compilation problems can be
	solved by delaying the instantiation of some templates in
	"parser_inst.cxx": replace "patch-ai" with the following
	(and corresponding changes in "patch-aj")

--- parser_inst.cxx.orig_dist	1998-10-07 13:04:12.000000000 +0300
+++ parser_inst.cxx	2006-10-07 22:22:20.000000000 +0300
@@ -13,9 +13,9 @@
 
 #ifdef SP_MANUAL_INST
 
-#define SP_DEFINE_TEMPLATES
 #include "Owner.h"
 #include "CopyOwner.h"
+#define SP_DEFINE_TEMPLATES
 #include "Vector.h"
 #include "NCVector.h"
 #include "Ptr.h"
@@ -72,6 +72,9 @@
 #include "types.h"
 #include "Id.h"
 
+#include "Owner.cxx"
+#include "CopyOwner.cxx"
+
 #ifdef SP_NAMESPACE
 namespace SP_NAMESPACE {
 #endif
@@ -1324,6 +1327,7 @@
 #endif
 #endif
 #endif
+#if defined(_LP64) || defined(__arm__)
 #ifdef __DECCXX
 #pragma define_template Vector<size_t>
 #else
@@ -1337,6 +1341,7 @@
 #endif
 #endif
 #endif
+#endif
 #ifdef __DECCXX
 #pragma define_template Vector<unsigned int>
 #else

	and by changing the order of AttributeValue and
	AttributeDefinitionDesc in Attribute.h:

--- Attribute.h.orig	1998-10-07 08:15:48.000000000 +0300
+++ Attribute.h	2006-10-07 21:09:06.000000000 +0300
@@ -31,6 +31,27 @@
 class AttributeContext;
 class Syntax;
 
+class SP_API AttributeValue : public Resource {
+public:
+  enum Type {
+    implied,
+    cdata,
+    tokenized
+    };
+  AttributeValue();
+  virtual ~AttributeValue();
+  virtual AttributeSemantics *makeSemantics(const DeclaredValue *,
+					    AttributeContext &,
+					    const StringC &,
+					    unsigned &,
+					    unsigned &) const;
+  virtual Type info(const Text *&, const StringC *&) const = 0;
+  virtual const Text *text() const;
+  virtual Boolean recoverUnquoted(const StringC &, const Location &,
+				  AttributeContext &, const StringC &);
+  static Boolean handleAsUnterminated(const Text &, AttributeContext &);
+};
+
 class SP_API AttributeDefinitionDesc {
 public:
   AttributeDefinitionDesc() { }
@@ -373,27 +394,6 @@
   ConstPtr<Notation> notation_;
 };
 
-class SP_API AttributeValue : public Resource {
-public:
-  enum Type {
-    implied,
-    cdata,
-    tokenized
-    };
-  AttributeValue();
-  virtual ~AttributeValue();
-  virtual AttributeSemantics *makeSemantics(const DeclaredValue *,
-					    AttributeContext &,
-					    const StringC &,
-					    unsigned &,
-					    unsigned &) const;
-  virtual Type info(const Text *&, const StringC *&) const = 0;
-  virtual const Text *text() const;
-  virtual Boolean recoverUnquoted(const StringC &, const Location &,
-				  AttributeContext &, const StringC &);
-  static Boolean handleAsUnterminated(const Text &, AttributeContext &);
-};
-
 class SP_API ImpliedAttributeValue : public AttributeValue {
 public:
   ImpliedAttributeValue();

>Unformatted: