[jira] [Commented] (XERCESC-2088) Bad casting from DOMTextImpl to DOMElementImpl

2018-11-12 Thread Philip Armstrong (JIRA)


[ 
https://issues.apache.org/jira/browse/XERCESC-2088?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16683554#comment-16683554
 ] 

Philip Armstrong commented on XERCESC-2088:
---

Done. See https://issues.apache.org/jira/browse/XERCESC-2157

> Bad casting from DOMTextImpl to DOMElementImpl
> --
>
> Key: XERCESC-2088
> URL: https://issues.apache.org/jira/browse/XERCESC-2088
> Project: Xerces-C++
>  Issue Type: Bug
>  Components: DOM
>Affects Versions: 3.1.1, 3.1.2, 3.1.3, 3.1.4
> Environment: ubuntu 16.04 LTS, Intel(R) Core(TM) i7-6700 CPU @ 
> 3.40GHz, 16GB
>Reporter: Yuseok Jeon
>Assignee: Scott Cantor
>Priority: Major
> Fix For: 3.2.0
>
> Attachments: Actual_result.txt, DOMNodeBase.hpp, casting.patch, 
> relationship_tree.jpeg
>
>
> Hi all, 
> Our recently developed type confusion detection tool reports a type_confusion 
> error in the "xercesc/dom/imple/DOMCasts.hpp" 
> xercesc/dom/imple/DOMCasts.hpp, line 146
> static inline DOMNodeImpl *castToNodeImpl(const DOMNode *p)
> {
> DOMElementImpl *pE = (DOMElementImpl *)p;
> return &(pE->fNode);
> }
> p is pointing to the object allocated as DOMTextImpl, and it is casted into 
> DOMElementImpl. However, since DOMElementImpl is not a subobject of 
> DOMTextImpl, it is violating C++ standard rules 5.2.9/11 (down casting is 
> undefined if the object that the pointer to be casted points to is not a 
> suboject of down casting type) and causes undefined behaviors.
> There are similar type-confusion cases as below links. 
>  - (libstdc++) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60734
>  - (Firefox) https://bugzilla.mozilla.org/show_bug.cgi?id=1074280
> I attached a actual type confusion report and object relationship 
> information. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

-
To unsubscribe, e-mail: c-dev-unsubscr...@xerces.apache.org
For additional commands, e-mail: c-dev-h...@xerces.apache.org



[jira] [Commented] (XERCESC-2088) Bad casting from DOMTextImpl to DOMElementImpl

2018-11-12 Thread Roger Leigh (JIRA)


[ 
https://issues.apache.org/jira/browse/XERCESC-2088?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16683516#comment-16683516
 ] 

Roger Leigh commented on XERCESC-2088:
--

It might be not possible to add an attachment because this particular issue has 
been closed.  Please could you open a new one for this request.  Thanks.

> Bad casting from DOMTextImpl to DOMElementImpl
> --
>
> Key: XERCESC-2088
> URL: https://issues.apache.org/jira/browse/XERCESC-2088
> Project: Xerces-C++
>  Issue Type: Bug
>  Components: DOM
>Affects Versions: 3.1.1, 3.1.2, 3.1.3, 3.1.4
> Environment: ubuntu 16.04 LTS, Intel(R) Core(TM) i7-6700 CPU @ 
> 3.40GHz, 16GB
>Reporter: Yuseok Jeon
>Assignee: Scott Cantor
>Priority: Major
> Fix For: 3.2.0
>
> Attachments: Actual_result.txt, DOMNodeBase.hpp, casting.patch, 
> relationship_tree.jpeg
>
>
> Hi all, 
> Our recently developed type confusion detection tool reports a type_confusion 
> error in the "xercesc/dom/imple/DOMCasts.hpp" 
> xercesc/dom/imple/DOMCasts.hpp, line 146
> static inline DOMNodeImpl *castToNodeImpl(const DOMNode *p)
> {
> DOMElementImpl *pE = (DOMElementImpl *)p;
> return &(pE->fNode);
> }
> p is pointing to the object allocated as DOMTextImpl, and it is casted into 
> DOMElementImpl. However, since DOMElementImpl is not a subobject of 
> DOMTextImpl, it is violating C++ standard rules 5.2.9/11 (down casting is 
> undefined if the object that the pointer to be casted points to is not a 
> suboject of down casting type) and causes undefined behaviors.
> There are similar type-confusion cases as below links. 
>  - (libstdc++) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60734
>  - (Firefox) https://bugzilla.mozilla.org/show_bug.cgi?id=1074280
> I attached a actual type confusion report and object relationship 
> information. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

-
To unsubscribe, e-mail: c-dev-unsubscr...@xerces.apache.org
For additional commands, e-mail: c-dev-h...@xerces.apache.org



[jira] [Commented] (XERCESC-2088) Bad casting from DOMTextImpl to DOMElementImpl

2018-11-12 Thread Philip Armstrong (JIRA)


[ 
https://issues.apache.org/jira/browse/XERCESC-2088?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16683515#comment-16683515
 ] 

Philip Armstrong commented on XERCESC-2088:
---

Let’s try again. Apologies for the comment / list spam.
{code:java}
Subject: [PATCH] Change dynamic_casts to virtual methods to avoid the need for
 rtti.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This requires that derived classes that inherit both from DOMNode and one of

  HasDOMNodeImpl
  HasDOMParentImpl
  HasDOMChildImpl

*must* implement hasDOMNodeImpl() and it’s neighbour virtual methods to return 
"this"
instead of nullptr as the methods on DOMNode do. Programmer beware!

diff --git a/src/xercesc/dom/DOMNode.hpp b/src/xercesc/dom/DOMNode.hpp
index 49d45f228..c6a155872 100644
--- a/src/xercesc/dom/DOMNode.hpp
+++ b/src/xercesc/dom/DOMNode.hpp
@@ -31,6 +31,9 @@ class DOMDocument;
 class DOMNamedNodeMap;
 class DOMNodeList;
 class DOMUserDataHandler;
+class HasDOMNodeImpl;
+class HasDOMParentImpl;
+class HasDOMChildImpl;
 
 /**
  * The DOMNode interface is the primary datatype for the entire
@@ -333,6 +336,16 @@ public:
 // ---
 //  Node methods
 // ---
+    /**
+ * casting methods
+ */
+    virtual HasDOMNodeImpl* hasDOMNodeImpl() { return nullptr; }
+    virtual const HasDOMNodeImpl* constHasDOMNodeImpl() const { return 
nullptr; }
+    virtual HasDOMParentImpl* hasDOMParentImpl() { return nullptr; }
+    virtual const HasDOMParentImpl* constHasDOMParentImpl() const { return 
nullptr; }
+    virtual HasDOMChildImpl* hasDOMChildImpl() { return nullptr; }
+    virtual const HasDOMChildImpl* constHasDOMChildImpl() const { return 
nullptr; }
+
 /**
  * Returns a duplicate of this node.
  *
diff --git a/src/xercesc/dom/impl/DOMAttrImpl.hpp 
b/src/xercesc/dom/impl/DOMAttrImpl.hpp
index 8c6a5ae7b..62bb4937d 100644
--- a/src/xercesc/dom/impl/DOMAttrImpl.hpp
+++ b/src/xercesc/dom/impl/DOMAttrImpl.hpp
@@ -47,8 +47,12 @@ class DOMElementImpl;
 class DOMTypeInfoImpl;
 
 class CDOM_EXPORT DOMAttrImpl: public DOMAttr, public HasDOMNodeImpl, public 
HasDOMParentImpl {
-
 public:
+    HasDOMNodeImpl* hasDOMNodeImpl() { return this; }
+    const HasDOMNodeImpl* constHasDOMNodeImpl() const { return this; }
+    HasDOMParentImpl* hasDOMParentImpl() { return this; }
+    const HasDOMParentImpl* constHasDOMParentImpl() const { return this; }
+
 DOMNodeImpl    fNode;
 DOMParentNode  fParent;
 const XMLCh   *fName;
diff --git a/src/xercesc/dom/impl/DOMCDATASectionImpl.hpp 
b/src/xercesc/dom/impl/DOMCDATASectionImpl.hpp
index d141deb27..cbc29c0cc 100644
--- a/src/xercesc/dom/impl/DOMCDATASectionImpl.hpp
+++ b/src/xercesc/dom/impl/DOMCDATASectionImpl.hpp
@@ -44,6 +44,12 @@ XERCES_CPP_NAMESPACE_BEGIN
 
 
 class CDOM_EXPORT DOMCDATASectionImpl: public DOMCDATASection, public 
HasDOMNodeImpl, public HasDOMChildImpl {
+public:
+    HasDOMNodeImpl* hasDOMNodeImpl() { return this; }
+    const HasDOMNodeImpl* constHasDOMNodeImpl() const { return this; }
+    HasDOMChildImpl* hasDOMChildImpl() { return this; }
+    const HasDOMChildImpl* constHasDOMChildImpl() const { return this; }
+
 protected:
 DOMNodeImpl   fNode;
 DOMChildNode  fChild;
diff --git a/src/xercesc/dom/impl/DOMCasts.hpp 
b/src/xercesc/dom/impl/DOMCasts.hpp
index 7d99dae29..b77ec1eb5 100644
--- a/src/xercesc/dom/impl/DOMCasts.hpp
+++ b/src/xercesc/dom/impl/DOMCasts.hpp
@@ -56,7 +56,8 @@ XERCES_CPP_NAMESPACE_BEGIN
 
 static inline const DOMNodeImpl *castToNodeImpl(const DOMNode *p)
 {
-    const HasDOMNodeImpl* pE = dynamic_cast(p);
+    //const HasDOMNodeImpl* pE = dynamic_cast(p);
+    const HasDOMNodeImpl* pE = p->constHasDOMNodeImpl();
 if (!pE || !pE->getNodeImpl()) {
 throw DOMException(DOMException::INVALID_STATE_ERR, 0, 
XMLPlatformUtils::fgMemoryManager);
 }
@@ -65,7 +66,8 @@ static inline const DOMNodeImpl *castToNodeImpl(const DOMNode 
*p)
 
 static inline DOMNodeImpl *castToNodeImpl(DOMNode *p)
 {
-    HasDOMNodeImpl *pE = dynamic_cast(p);
+    //HasDOMNodeImpl *pE = dynamic_cast(p);
+    HasDOMNodeImpl* pE = p->hasDOMNodeImpl();
 if (!pE || !pE->getNodeImpl()) {
 throw DOMException(DOMException::INVALID_STATE_ERR, 0, 
XMLPlatformUtils::fgMemoryManager);
 }
@@ -73,7 +75,8 @@ static inline DOMNodeImpl *castToNodeImpl(DOMNode *p)
 }
 
 static inline const DOMParentNode *castToParentImpl(const DOMNode *p) {
-    const HasDOMParentImpl *pE = dynamic_cast(p);
+    //const HasDOMParentImpl *pE = dynamic_cast(p);
+    const HasDOMParentImpl *pE = p->constHasDOMParentImpl();
 if (!pE || !pE->getParentNodeImpl()) {
 throw DOMException(DOMException::INVALID_STATE_ERR, 0, 
XMLPlatformUtils::fgMemoryM

[jira] [Commented] (XERCESC-2088) Bad casting from DOMTextImpl to DOMElementImpl

2018-11-12 Thread Philip Armstrong (JIRA)


[ 
https://issues.apache.org/jira/browse/XERCESC-2088?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16683498#comment-16683498
 ] 

Philip Armstrong commented on XERCESC-2088:
---

The patch is included below. I wouldn't claim this is good code style, given 
the risk of a future programmer creating a class that inherits from DOMNode & 
one of the sister classes but forgetting to implement the relevant virtual 
methods, nor is it mergeable as is but it does solve the 'rtti' issue for us.

(I don't seem to be able to attach files to Jira comments, hopefully including 
it inline will be OK, it’s not very large)

{{Subject: [PATCH] Change dynamic_casts to virtual methods to avoid the need 
for}}
{{ rtti.}}
{{MIME-Version: 1.0}}
{{Content-Type: text/plain; charset=UTF-8}}
{{Content-Transfer-Encoding: 8bit}}

{{This requires that derived classes that inherit both from DOMNode and one of}}

{{  HasDOMNodeImpl}}
{{  HasDOMParentImpl}}
{{  HasDOMChildImpl}}

{{*must* implement hasDOMNodeImpl() and it’s neighbour virtual methods to 
return "this"}}
{{instead of nullptr as the methods on DOMNode do. Programmer beware!}}

{{diff --git a/src/xercesc/dom/DOMNode.hpp b/src/xercesc/dom/DOMNode.hpp}}
{{index 49d45f228..c6a155872 100644}}
{{--- a/src/xercesc/dom/DOMNode.hpp}}
{{+++ b/src/xercesc/dom/DOMNode.hpp}}
{{@@ -31,6 +31,9 @@ class DOMDocument;}}
{{ class DOMNamedNodeMap;}}
{{ class DOMNodeList;}}
{{ class DOMUserDataHandler;}}
{{+class HasDOMNodeImpl;}}
{{+class HasDOMParentImpl;}}
{{+class HasDOMChildImpl;}}
{{ }}
{{ /**}}
{{  * The DOMNode interface is the primary datatype for the 
entire}}
{{@@ -333,6 +336,16 @@ public:}}
{{ // 
---}}
{{ //  Node methods}}
{{ // 
---}}
{{+    /**}}
{{+ * casting methods}}
{{+ */}}
{{+    virtual HasDOMNodeImpl* hasDOMNodeImpl() \{ return nullptr; }}}
{{+    virtual const HasDOMNodeImpl* constHasDOMNodeImpl() const \{ return 
nullptr; }}}
{{+    virtual HasDOMParentImpl* hasDOMParentImpl() \{ return nullptr; }}}
{{+    virtual const HasDOMParentImpl* constHasDOMParentImpl() const \{ return 
nullptr; }}}
{{+    virtual HasDOMChildImpl* hasDOMChildImpl() \{ return nullptr; }}}
{{+    virtual const HasDOMChildImpl* constHasDOMChildImpl() const \{ return 
nullptr; }}}
{{+}}
{{ /**}}
{{  * Returns a duplicate of this node.}}
{{  *}}
{{diff --git a/src/xercesc/dom/impl/DOMAttrImpl.hpp 
b/src/xercesc/dom/impl/DOMAttrImpl.hpp}}
{{index 8c6a5ae7b..62bb4937d 100644}}
{{--- a/src/xercesc/dom/impl/DOMAttrImpl.hpp}}
{{+++ b/src/xercesc/dom/impl/DOMAttrImpl.hpp}}
{{@@ -47,8 +47,12 @@ class DOMElementImpl;}}
{{ class DOMTypeInfoImpl;}}
{{ }}
{{ class CDOM_EXPORT DOMAttrImpl: public DOMAttr, public HasDOMNodeImpl, public 
HasDOMParentImpl {}}
{{-}}
{{ public:}}
{{+    HasDOMNodeImpl* hasDOMNodeImpl() \{ return this; }}}
{{+    const HasDOMNodeImpl* constHasDOMNodeImpl() const \{ return this; }}}
{{+    HasDOMParentImpl* hasDOMParentImpl() \{ return this; }}}
{{+    const HasDOMParentImpl* constHasDOMParentImpl() const \{ return this; }}}
{{+}}
{{ DOMNodeImpl    fNode;}}
{{ DOMParentNode  fParent;}}
{{ const XMLCh   *fName;}}
{{diff --git a/src/xercesc/dom/impl/DOMCDATASectionImpl.hpp 
b/src/xercesc/dom/impl/DOMCDATASectionImpl.hpp}}
{{index d141deb27..cbc29c0cc 100644}}
{{--- a/src/xercesc/dom/impl/DOMCDATASectionImpl.hpp}}
{{+++ b/src/xercesc/dom/impl/DOMCDATASectionImpl.hpp}}
{{@@ -44,6 +44,12 @@ XERCES_CPP_NAMESPACE_BEGIN}}
{{ }}
{{ }}
{{ class CDOM_EXPORT DOMCDATASectionImpl: public DOMCDATASection, public 
HasDOMNodeImpl, public HasDOMChildImpl {}}
{{+public:}}
{{+    HasDOMNodeImpl* hasDOMNodeImpl() \{ return this; }}}
{{+    const HasDOMNodeImpl* constHasDOMNodeImpl() const \{ return this; }}}
{{+    HasDOMChildImpl* hasDOMChildImpl() \{ return this; }}}
{{+    const HasDOMChildImpl* constHasDOMChildImpl() const \{ return this; }}}
{{+}}
{{ protected:}}
{{ DOMNodeImpl   fNode;}}
{{ DOMChildNode  fChild;}}
{{diff --git a/src/xercesc/dom/impl/DOMCasts.hpp 
b/src/xercesc/dom/impl/DOMCasts.hpp}}
{{index 7d99dae29..b77ec1eb5 100644}}
{{--- a/src/xercesc/dom/impl/DOMCasts.hpp}}
{{+++ b/src/xercesc/dom/impl/DOMCasts.hpp}}
{{@@ -56,7 +56,8 @@ XERCES_CPP_NAMESPACE_BEGIN}}
{{ }}
{{ static inline const DOMNodeImpl *castToNodeImpl(const DOMNode *p)}}
{{ {}}
{{-    const HasDOMNodeImpl* pE = dynamic_cast(p);}}
{{+    //const HasDOMNodeImpl* pE = dynamic_cast(p);}}
{{+    const HasDOMNodeImpl* pE = p->constHasDOMNodeImpl();}}
{{ if (!pE || !pE->getNodeImpl()) {}}
{{ throw DOMException(DOMException::INVALID_STATE_ERR, 0, 
XMLPlatformUtils::fgMemoryManager);}}
{{ }}}
{{@@ -65,7 +66,8 @@ static inline const DOMNodeImpl *castToNodeImpl(const 
DOMNode *p)}}
{{ }}
{{ static inline DOMNodeImpl *cas

[jira] [Commented] (XERCESC-2088) Bad casting from DOMTextImpl to DOMElementImpl

2018-11-12 Thread Philip Armstrong (JIRA)


[ 
https://issues.apache.org/jira/browse/XERCESC-2088?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16683500#comment-16683500
 ] 

Philip Armstrong commented on XERCESC-2088:
---

Apologies - Jira seems to have mangled the patch :(

> Bad casting from DOMTextImpl to DOMElementImpl
> --
>
> Key: XERCESC-2088
> URL: https://issues.apache.org/jira/browse/XERCESC-2088
> Project: Xerces-C++
>  Issue Type: Bug
>  Components: DOM
>Affects Versions: 3.1.1, 3.1.2, 3.1.3, 3.1.4
> Environment: ubuntu 16.04 LTS, Intel(R) Core(TM) i7-6700 CPU @ 
> 3.40GHz, 16GB
>Reporter: Yuseok Jeon
>Assignee: Scott Cantor
>Priority: Major
> Fix For: 3.2.0
>
> Attachments: Actual_result.txt, DOMNodeBase.hpp, casting.patch, 
> relationship_tree.jpeg
>
>
> Hi all, 
> Our recently developed type confusion detection tool reports a type_confusion 
> error in the "xercesc/dom/imple/DOMCasts.hpp" 
> xercesc/dom/imple/DOMCasts.hpp, line 146
> static inline DOMNodeImpl *castToNodeImpl(const DOMNode *p)
> {
> DOMElementImpl *pE = (DOMElementImpl *)p;
> return &(pE->fNode);
> }
> p is pointing to the object allocated as DOMTextImpl, and it is casted into 
> DOMElementImpl. However, since DOMElementImpl is not a subobject of 
> DOMTextImpl, it is violating C++ standard rules 5.2.9/11 (down casting is 
> undefined if the object that the pointer to be casted points to is not a 
> suboject of down casting type) and causes undefined behaviors.
> There are similar type-confusion cases as below links. 
>  - (libstdc++) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60734
>  - (Firefox) https://bugzilla.mozilla.org/show_bug.cgi?id=1074280
> I attached a actual type confusion report and object relationship 
> information. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

-
To unsubscribe, e-mail: c-dev-unsubscr...@xerces.apache.org
For additional commands, e-mail: c-dev-h...@xerces.apache.org



[jira] [Commented] (XERCESC-2088) Bad casting from DOMTextImpl to DOMElementImpl

2018-11-11 Thread Scott Cantor (JIRA)


[ 
https://issues.apache.org/jira/browse/XERCESC-2088?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16682987#comment-16682987
 ] 

Scott Cantor commented on XERCESC-2088:
---

I really could not accept a constraint of "no RTTI" when it comes to fixing 
other bugs, that would put me in a fairly untenable position trying to maintain 
what little of the code base I can actually effectively maintain as it is.

> Bad casting from DOMTextImpl to DOMElementImpl
> --
>
> Key: XERCESC-2088
> URL: https://issues.apache.org/jira/browse/XERCESC-2088
> Project: Xerces-C++
>  Issue Type: Bug
>  Components: DOM
>Affects Versions: 3.1.1, 3.1.2, 3.1.3, 3.1.4
> Environment: ubuntu 16.04 LTS, Intel(R) Core(TM) i7-6700 CPU @ 
> 3.40GHz, 16GB
>Reporter: Yuseok Jeon
>Assignee: Scott Cantor
>Priority: Major
> Fix For: 3.2.0
>
> Attachments: Actual_result.txt, DOMNodeBase.hpp, casting.patch, 
> relationship_tree.jpeg
>
>
> Hi all, 
> Our recently developed type confusion detection tool reports a type_confusion 
> error in the "xercesc/dom/imple/DOMCasts.hpp" 
> xercesc/dom/imple/DOMCasts.hpp, line 146
> static inline DOMNodeImpl *castToNodeImpl(const DOMNode *p)
> {
> DOMElementImpl *pE = (DOMElementImpl *)p;
> return &(pE->fNode);
> }
> p is pointing to the object allocated as DOMTextImpl, and it is casted into 
> DOMElementImpl. However, since DOMElementImpl is not a subobject of 
> DOMTextImpl, it is violating C++ standard rules 5.2.9/11 (down casting is 
> undefined if the object that the pointer to be casted points to is not a 
> suboject of down casting type) and causes undefined behaviors.
> There are similar type-confusion cases as below links. 
>  - (libstdc++) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60734
>  - (Firefox) https://bugzilla.mozilla.org/show_bug.cgi?id=1074280
> I attached a actual type confusion report and object relationship 
> information. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

-
To unsubscribe, e-mail: c-dev-unsubscr...@xerces.apache.org
For additional commands, e-mail: c-dev-h...@xerces.apache.org



[jira] [Commented] (XERCESC-2088) Bad casting from DOMTextImpl to DOMElementImpl

2018-11-10 Thread Roger Leigh (JIRA)


[ 
https://issues.apache.org/jira/browse/XERCESC-2088?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16682457#comment-16682457
 ] 

Roger Leigh commented on XERCESC-2088:
--

[~phila] It would certainly be useful to see how you implemented this without 
RTTI.  I'm unsure how many Xerces-C++ users rely no no-rtti, is anyone else 
requiring this?

There are other approaches which could also be considered such as std::variant 
for "external polymorphism" (or equivalent implementations).

> Bad casting from DOMTextImpl to DOMElementImpl
> --
>
> Key: XERCESC-2088
> URL: https://issues.apache.org/jira/browse/XERCESC-2088
> Project: Xerces-C++
>  Issue Type: Bug
>  Components: DOM
>Affects Versions: 3.1.1, 3.1.2, 3.1.3, 3.1.4
> Environment: ubuntu 16.04 LTS, Intel(R) Core(TM) i7-6700 CPU @ 
> 3.40GHz, 16GB
>Reporter: Yuseok Jeon
>Assignee: Scott Cantor
>Priority: Major
> Fix For: 3.2.0
>
> Attachments: Actual_result.txt, DOMNodeBase.hpp, casting.patch, 
> relationship_tree.jpeg
>
>
> Hi all, 
> Our recently developed type confusion detection tool reports a type_confusion 
> error in the "xercesc/dom/imple/DOMCasts.hpp" 
> xercesc/dom/imple/DOMCasts.hpp, line 146
> static inline DOMNodeImpl *castToNodeImpl(const DOMNode *p)
> {
> DOMElementImpl *pE = (DOMElementImpl *)p;
> return &(pE->fNode);
> }
> p is pointing to the object allocated as DOMTextImpl, and it is casted into 
> DOMElementImpl. However, since DOMElementImpl is not a subobject of 
> DOMTextImpl, it is violating C++ standard rules 5.2.9/11 (down casting is 
> undefined if the object that the pointer to be casted points to is not a 
> suboject of down casting type) and causes undefined behaviors.
> There are similar type-confusion cases as below links. 
>  - (libstdc++) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60734
>  - (Firefox) https://bugzilla.mozilla.org/show_bug.cgi?id=1074280
> I attached a actual type confusion report and object relationship 
> information. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

-
To unsubscribe, e-mail: c-dev-unsubscr...@xerces.apache.org
For additional commands, e-mail: c-dev-h...@xerces.apache.org



[jira] [Commented] (XERCESC-2088) Bad casting from DOMTextImpl to DOMElementImpl

2018-11-09 Thread Philip Armstrong (JIRA)


[ 
https://issues.apache.org/jira/browse/XERCESC-2088?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16681321#comment-16681321
 ] 

Philip Armstrong commented on XERCESC-2088:
---

If you’d like to see the patch I can put it up if people think that restoring 
the ability to compile without rtti is a feature that’s worth preserving.

> Bad casting from DOMTextImpl to DOMElementImpl
> --
>
> Key: XERCESC-2088
> URL: https://issues.apache.org/jira/browse/XERCESC-2088
> Project: Xerces-C++
>  Issue Type: Bug
>  Components: DOM
>Affects Versions: 3.1.1, 3.1.2, 3.1.3, 3.1.4
> Environment: ubuntu 16.04 LTS, Intel(R) Core(TM) i7-6700 CPU @ 
> 3.40GHz, 16GB
>Reporter: Yuseok Jeon
>Assignee: Scott Cantor
>Priority: Major
> Fix For: 3.2.0
>
> Attachments: Actual_result.txt, DOMNodeBase.hpp, casting.patch, 
> relationship_tree.jpeg
>
>
> Hi all, 
> Our recently developed type confusion detection tool reports a type_confusion 
> error in the "xercesc/dom/imple/DOMCasts.hpp" 
> xercesc/dom/imple/DOMCasts.hpp, line 146
> static inline DOMNodeImpl *castToNodeImpl(const DOMNode *p)
> {
> DOMElementImpl *pE = (DOMElementImpl *)p;
> return &(pE->fNode);
> }
> p is pointing to the object allocated as DOMTextImpl, and it is casted into 
> DOMElementImpl. However, since DOMElementImpl is not a subobject of 
> DOMTextImpl, it is violating C++ standard rules 5.2.9/11 (down casting is 
> undefined if the object that the pointer to be casted points to is not a 
> suboject of down casting type) and causes undefined behaviors.
> There are similar type-confusion cases as below links. 
>  - (libstdc++) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60734
>  - (Firefox) https://bugzilla.mozilla.org/show_bug.cgi?id=1074280
> I attached a actual type confusion report and object relationship 
> information. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

-
To unsubscribe, e-mail: c-dev-unsubscr...@xerces.apache.org
For additional commands, e-mail: c-dev-h...@xerces.apache.org



[jira] [Commented] (XERCESC-2088) Bad casting from DOMTextImpl to DOMElementImpl

2018-11-09 Thread Philip Armstrong (JIRA)


[ 
https://issues.apache.org/jira/browse/XERCESC-2088?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16681320#comment-16681320
 ] 

Philip Armstrong commented on XERCESC-2088:
---

NB. For our internal use we require no-rtti, so I have written a small patch 
which replaces the calls to dynamic_cast which virtual methods on DOMNode which 
return "nullptr" by default & return "this" in those classes which multiply 
inherit from DOMNode and HasDOM(Node|Parent|Child)Impl.

This approach passes all the Xerces tests, but obviously is somewhat fragile in 
that any programmer creating classes that multiply inherit from both DOMNode & 
Has...Impl in the future must implement these virtual functions too.

> Bad casting from DOMTextImpl to DOMElementImpl
> --
>
> Key: XERCESC-2088
> URL: https://issues.apache.org/jira/browse/XERCESC-2088
> Project: Xerces-C++
>  Issue Type: Bug
>  Components: DOM
>Affects Versions: 3.1.1, 3.1.2, 3.1.3, 3.1.4
> Environment: ubuntu 16.04 LTS, Intel(R) Core(TM) i7-6700 CPU @ 
> 3.40GHz, 16GB
>Reporter: Yuseok Jeon
>Assignee: Scott Cantor
>Priority: Major
> Fix For: 3.2.0
>
> Attachments: Actual_result.txt, DOMNodeBase.hpp, casting.patch, 
> relationship_tree.jpeg
>
>
> Hi all, 
> Our recently developed type confusion detection tool reports a type_confusion 
> error in the "xercesc/dom/imple/DOMCasts.hpp" 
> xercesc/dom/imple/DOMCasts.hpp, line 146
> static inline DOMNodeImpl *castToNodeImpl(const DOMNode *p)
> {
> DOMElementImpl *pE = (DOMElementImpl *)p;
> return &(pE->fNode);
> }
> p is pointing to the object allocated as DOMTextImpl, and it is casted into 
> DOMElementImpl. However, since DOMElementImpl is not a subobject of 
> DOMTextImpl, it is violating C++ standard rules 5.2.9/11 (down casting is 
> undefined if the object that the pointer to be casted points to is not a 
> suboject of down casting type) and causes undefined behaviors.
> There are similar type-confusion cases as below links. 
>  - (libstdc++) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60734
>  - (Firefox) https://bugzilla.mozilla.org/show_bug.cgi?id=1074280
> I attached a actual type confusion report and object relationship 
> information. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

-
To unsubscribe, e-mail: c-dev-unsubscr...@xerces.apache.org
For additional commands, e-mail: c-dev-h...@xerces.apache.org



[jira] [Commented] (XERCESC-2088) Bad casting from DOMTextImpl to DOMElementImpl

2018-11-08 Thread Scott Cantor (JIRA)


[ 
https://issues.apache.org/jira/browse/XERCESC-2088?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16680709#comment-16680709
 ] 

Scott Cantor commented on XERCESC-2088:
---

There's no real connection there, it's just that the site happens to be 
generated from files that are (unfortunately) a part of the distribution. If 
you regenerate the site and commit the changed files to the website it doesn't 
matter if there's a release that matches it.

> Bad casting from DOMTextImpl to DOMElementImpl
> --
>
> Key: XERCESC-2088
> URL: https://issues.apache.org/jira/browse/XERCESC-2088
> Project: Xerces-C++
>  Issue Type: Bug
>  Components: DOM
>Affects Versions: 3.1.1, 3.1.2, 3.1.3, 3.1.4
> Environment: ubuntu 16.04 LTS, Intel(R) Core(TM) i7-6700 CPU @ 
> 3.40GHz, 16GB
>Reporter: Yuseok Jeon
>Assignee: Scott Cantor
>Priority: Major
> Fix For: 3.2.0
>
> Attachments: Actual_result.txt, DOMNodeBase.hpp, casting.patch, 
> relationship_tree.jpeg
>
>
> Hi all, 
> Our recently developed type confusion detection tool reports a type_confusion 
> error in the "xercesc/dom/imple/DOMCasts.hpp" 
> xercesc/dom/imple/DOMCasts.hpp, line 146
> static inline DOMNodeImpl *castToNodeImpl(const DOMNode *p)
> {
> DOMElementImpl *pE = (DOMElementImpl *)p;
> return &(pE->fNode);
> }
> p is pointing to the object allocated as DOMTextImpl, and it is casted into 
> DOMElementImpl. However, since DOMElementImpl is not a subobject of 
> DOMTextImpl, it is violating C++ standard rules 5.2.9/11 (down casting is 
> undefined if the object that the pointer to be casted points to is not a 
> suboject of down casting type) and causes undefined behaviors.
> There are similar type-confusion cases as below links. 
>  - (libstdc++) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60734
>  - (Firefox) https://bugzilla.mozilla.org/show_bug.cgi?id=1074280
> I attached a actual type confusion report and object relationship 
> information. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

-
To unsubscribe, e-mail: c-dev-unsubscr...@xerces.apache.org
For additional commands, e-mail: c-dev-h...@xerces.apache.org



[jira] [Commented] (XERCESC-2088) Bad casting from DOMTextImpl to DOMElementImpl

2018-11-08 Thread Roger Leigh (JIRA)


[ 
https://issues.apache.org/jira/browse/XERCESC-2088?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16680450#comment-16680450
 ] 

Roger Leigh commented on XERCESC-2088:
--

I have removed the no-RTTI comments in r1846201.

[~canto...@osu.edu] What's the process for updating the website.  Does it 
require rolling a new release, or can this change be cherry-picked onto the 
website branch?

> Bad casting from DOMTextImpl to DOMElementImpl
> --
>
> Key: XERCESC-2088
> URL: https://issues.apache.org/jira/browse/XERCESC-2088
> Project: Xerces-C++
>  Issue Type: Bug
>  Components: DOM
>Affects Versions: 3.1.1, 3.1.2, 3.1.3, 3.1.4
> Environment: ubuntu 16.04 LTS, Intel(R) Core(TM) i7-6700 CPU @ 
> 3.40GHz, 16GB
>Reporter: Yuseok Jeon
>Assignee: Scott Cantor
>Priority: Major
> Fix For: 3.2.0
>
> Attachments: Actual_result.txt, DOMNodeBase.hpp, casting.patch, 
> relationship_tree.jpeg
>
>
> Hi all, 
> Our recently developed type confusion detection tool reports a type_confusion 
> error in the "xercesc/dom/imple/DOMCasts.hpp" 
> xercesc/dom/imple/DOMCasts.hpp, line 146
> static inline DOMNodeImpl *castToNodeImpl(const DOMNode *p)
> {
> DOMElementImpl *pE = (DOMElementImpl *)p;
> return &(pE->fNode);
> }
> p is pointing to the object allocated as DOMTextImpl, and it is casted into 
> DOMElementImpl. However, since DOMElementImpl is not a subobject of 
> DOMTextImpl, it is violating C++ standard rules 5.2.9/11 (down casting is 
> undefined if the object that the pointer to be casted points to is not a 
> suboject of down casting type) and causes undefined behaviors.
> There are similar type-confusion cases as below links. 
>  - (libstdc++) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60734
>  - (Firefox) https://bugzilla.mozilla.org/show_bug.cgi?id=1074280
> I attached a actual type confusion report and object relationship 
> information. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

-
To unsubscribe, e-mail: c-dev-unsubscr...@xerces.apache.org
For additional commands, e-mail: c-dev-h...@xerces.apache.org



[jira] [Commented] (XERCESC-2088) Bad casting from DOMTextImpl to DOMElementImpl

2018-11-06 Thread Philip Armstrong (JIRA)


[ 
https://issues.apache.org/jira/browse/XERCESC-2088?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16677164#comment-16677164
 ] 

Philip Armstrong commented on XERCESC-2088:
---

NB. This use of dynamic_cast means that Xerces now requires rtti - perhaps the 
homepage needs editing to reflect this!

> Bad casting from DOMTextImpl to DOMElementImpl
> --
>
> Key: XERCESC-2088
> URL: https://issues.apache.org/jira/browse/XERCESC-2088
> Project: Xerces-C++
>  Issue Type: Bug
>  Components: DOM
>Affects Versions: 3.1.1, 3.1.2, 3.1.3, 3.1.4
> Environment: ubuntu 16.04 LTS, Intel(R) Core(TM) i7-6700 CPU @ 
> 3.40GHz, 16GB
>Reporter: Yuseok Jeon
>Assignee: Scott Cantor
>Priority: Major
> Fix For: 3.2.0
>
> Attachments: Actual_result.txt, DOMNodeBase.hpp, casting.patch, 
> relationship_tree.jpeg
>
>
> Hi all, 
> Our recently developed type confusion detection tool reports a type_confusion 
> error in the "xercesc/dom/imple/DOMCasts.hpp" 
> xercesc/dom/imple/DOMCasts.hpp, line 146
> static inline DOMNodeImpl *castToNodeImpl(const DOMNode *p)
> {
> DOMElementImpl *pE = (DOMElementImpl *)p;
> return &(pE->fNode);
> }
> p is pointing to the object allocated as DOMTextImpl, and it is casted into 
> DOMElementImpl. However, since DOMElementImpl is not a subobject of 
> DOMTextImpl, it is violating C++ standard rules 5.2.9/11 (down casting is 
> undefined if the object that the pointer to be casted points to is not a 
> suboject of down casting type) and causes undefined behaviors.
> There are similar type-confusion cases as below links. 
>  - (libstdc++) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60734
>  - (Firefox) https://bugzilla.mozilla.org/show_bug.cgi?id=1074280
> I attached a actual type confusion report and object relationship 
> information. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

-
To unsubscribe, e-mail: c-dev-unsubscr...@xerces.apache.org
For additional commands, e-mail: c-dev-h...@xerces.apache.org



[jira] [Commented] (XERCESC-2088) Bad casting from DOMTextImpl to DOMElementImpl

2017-07-03 Thread Scott Cantor (JIRA)

[ 
https://issues.apache.org/jira/browse/XERCESC-2088?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16072817#comment-16072817
 ] 

Scott Cantor commented on XERCESC-2088:
---

At the extremes (files of sizes like 25+M and 80+M), parsing and signature 
verification are horrendous, but not any different from my results with 3.1.4. 
That suggests no real significant impact from the change, perhaps a bit of RAM 
increase.

Thanks for the independent testing.

My testing does not include Xalan, so that would be something to test if 
possible. I'm pretty confident in the aggregate this is a safe change, but 
every bit helps.

With the holiday I'll hold off but I'll probably commit it later this week.

> Bad casting from DOMTextImpl to DOMElementImpl
> --
>
> Key: XERCESC-2088
> URL: https://issues.apache.org/jira/browse/XERCESC-2088
> Project: Xerces-C++
>  Issue Type: Bug
>  Components: DOM
>Affects Versions: 3.1.1, 3.1.2, 3.1.3, 3.1.4
> Environment: ubuntu 16.04 LTS, Intel(R) Core(TM) i7-6700 CPU @ 
> 3.40GHz, 16GB
>Reporter: Yuseok Jeon
>Assignee: Scott Cantor
> Fix For: 3.2.0
>
> Attachments: Actual_result.txt, casting.patch, DOMNodeBase.hpp, 
> relationship_tree.jpeg
>
>
> Hi all, 
> Our recently developed type confusion detection tool reports a type_confusion 
> error in the "xercesc/dom/imple/DOMCasts.hpp" 
> xercesc/dom/imple/DOMCasts.hpp, line 146
> static inline DOMNodeImpl *castToNodeImpl(const DOMNode *p)
> {
> DOMElementImpl *pE = (DOMElementImpl *)p;
> return &(pE->fNode);
> }
> p is pointing to the object allocated as DOMTextImpl, and it is casted into 
> DOMElementImpl. However, since DOMElementImpl is not a subobject of 
> DOMTextImpl, it is violating C++ standard rules 5.2.9/11 (down casting is 
> undefined if the object that the pointer to be casted points to is not a 
> suboject of down casting type) and causes undefined behaviors.
> There are similar type-confusion cases as below links. 
>  - (libstdc++) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60734
>  - (Firefox) https://bugzilla.mozilla.org/show_bug.cgi?id=1074280
> I attached a actual type confusion report and object relationship 
> information. 



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

-
To unsubscribe, e-mail: c-dev-unsubscr...@xerces.apache.org
For additional commands, e-mail: c-dev-h...@xerces.apache.org



[jira] [Commented] (XERCESC-2088) Bad casting from DOMTextImpl to DOMElementImpl

2017-07-03 Thread Roger Leigh (JIRA)

[ 
https://issues.apache.org/jira/browse/XERCESC-2088?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16072780#comment-16072780
 ] 

Roger Leigh commented on XERCESC-2088:
--

Tested in [this 
branch|https://github.com/rleigh-codelibre/xerces-c/commits/casting-2088].  
Green in 
[travis|https://travis-ci.org/rleigh-codelibre/xerces-c/builds/249694130] 
[appveyor|https://ci.appveyor.com/project/rleigh-codelibre/xerces-c/build/1.0.104].

Looks good.  I was having odd segfaults with FreeBSD and xalan last year, and I 
would not be at all surprised if some of this was at fault.  Making it 
conforming should be a big improvement.

> Bad casting from DOMTextImpl to DOMElementImpl
> --
>
> Key: XERCESC-2088
> URL: https://issues.apache.org/jira/browse/XERCESC-2088
> Project: Xerces-C++
>  Issue Type: Bug
>  Components: DOM
>Affects Versions: 3.1.1, 3.1.2, 3.1.3, 3.1.4
> Environment: ubuntu 16.04 LTS, Intel(R) Core(TM) i7-6700 CPU @ 
> 3.40GHz, 16GB
>Reporter: Yuseok Jeon
>Assignee: Scott Cantor
> Fix For: 3.2.0
>
> Attachments: Actual_result.txt, casting.patch, DOMNodeBase.hpp, 
> relationship_tree.jpeg
>
>
> Hi all, 
> Our recently developed type confusion detection tool reports a type_confusion 
> error in the "xercesc/dom/imple/DOMCasts.hpp" 
> xercesc/dom/imple/DOMCasts.hpp, line 146
> static inline DOMNodeImpl *castToNodeImpl(const DOMNode *p)
> {
> DOMElementImpl *pE = (DOMElementImpl *)p;
> return &(pE->fNode);
> }
> p is pointing to the object allocated as DOMTextImpl, and it is casted into 
> DOMElementImpl. However, since DOMElementImpl is not a subobject of 
> DOMTextImpl, it is violating C++ standard rules 5.2.9/11 (down casting is 
> undefined if the object that the pointer to be casted points to is not a 
> suboject of down casting type) and causes undefined behaviors.
> There are similar type-confusion cases as below links. 
>  - (libstdc++) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60734
>  - (Firefox) https://bugzilla.mozilla.org/show_bug.cgi?id=1074280
> I attached a actual type confusion report and object relationship 
> information. 



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

-
To unsubscribe, e-mail: c-dev-unsubscr...@xerces.apache.org
For additional commands, e-mail: c-dev-h...@xerces.apache.org



[jira] [Commented] (XERCESC-2088) Bad casting from DOMTextImpl to DOMElementImpl

2017-07-03 Thread Scott Cantor (JIRA)

[ 
https://issues.apache.org/jira/browse/XERCESC-2088?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16072484#comment-16072484
 ] 

Scott Cantor commented on XERCESC-2088:
---

Yeah, I noticed myself. Will attach after a meeting I have to run to, thanks 
for trying it.

> Bad casting from DOMTextImpl to DOMElementImpl
> --
>
> Key: XERCESC-2088
> URL: https://issues.apache.org/jira/browse/XERCESC-2088
> Project: Xerces-C++
>  Issue Type: Bug
>  Components: DOM
>Affects Versions: 3.1.1, 3.1.2, 3.1.3, 3.1.4
> Environment: ubuntu 16.04 LTS, Intel(R) Core(TM) i7-6700 CPU @ 
> 3.40GHz, 16GB
>Reporter: Yuseok Jeon
>Assignee: Scott Cantor
> Fix For: 3.2.0
>
> Attachments: Actual_result.txt, casting.patch, relationship_tree.jpeg
>
>
> Hi all, 
> Our recently developed type confusion detection tool reports a type_confusion 
> error in the "xercesc/dom/imple/DOMCasts.hpp" 
> xercesc/dom/imple/DOMCasts.hpp, line 146
> static inline DOMNodeImpl *castToNodeImpl(const DOMNode *p)
> {
> DOMElementImpl *pE = (DOMElementImpl *)p;
> return &(pE->fNode);
> }
> p is pointing to the object allocated as DOMTextImpl, and it is casted into 
> DOMElementImpl. However, since DOMElementImpl is not a subobject of 
> DOMTextImpl, it is violating C++ standard rules 5.2.9/11 (down casting is 
> undefined if the object that the pointer to be casted points to is not a 
> suboject of down casting type) and causes undefined behaviors.
> There are similar type-confusion cases as below links. 
>  - (libstdc++) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60734
>  - (Firefox) https://bugzilla.mozilla.org/show_bug.cgi?id=1074280
> I attached a actual type confusion report and object relationship 
> information. 



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

-
To unsubscribe, e-mail: c-dev-unsubscr...@xerces.apache.org
For additional commands, e-mail: c-dev-h...@xerces.apache.org



[jira] [Commented] (XERCESC-2088) Bad casting from DOMTextImpl to DOMElementImpl

2017-07-03 Thread Roger Leigh (JIRA)

[ 
https://issues.apache.org/jira/browse/XERCESC-2088?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16072477#comment-16072477
 ] 

Roger Leigh commented on XERCESC-2088:
--

[~canto...@osu.edu] I tried out the patch, but 
{{xercesc/dom/impl/DOMNodeBase.hpp}} is missing from the patch contents.

> Bad casting from DOMTextImpl to DOMElementImpl
> --
>
> Key: XERCESC-2088
> URL: https://issues.apache.org/jira/browse/XERCESC-2088
> Project: Xerces-C++
>  Issue Type: Bug
>  Components: DOM
>Affects Versions: 3.1.1, 3.1.2, 3.1.3, 3.1.4
> Environment: ubuntu 16.04 LTS, Intel(R) Core(TM) i7-6700 CPU @ 
> 3.40GHz, 16GB
>Reporter: Yuseok Jeon
>Assignee: Scott Cantor
> Fix For: 3.2.0
>
> Attachments: Actual_result.txt, casting.patch, relationship_tree.jpeg
>
>
> Hi all, 
> Our recently developed type confusion detection tool reports a type_confusion 
> error in the "xercesc/dom/imple/DOMCasts.hpp" 
> xercesc/dom/imple/DOMCasts.hpp, line 146
> static inline DOMNodeImpl *castToNodeImpl(const DOMNode *p)
> {
> DOMElementImpl *pE = (DOMElementImpl *)p;
> return &(pE->fNode);
> }
> p is pointing to the object allocated as DOMTextImpl, and it is casted into 
> DOMElementImpl. However, since DOMElementImpl is not a subobject of 
> DOMTextImpl, it is violating C++ standard rules 5.2.9/11 (down casting is 
> undefined if the object that the pointer to be casted points to is not a 
> suboject of down casting type) and causes undefined behaviors.
> There are similar type-confusion cases as below links. 
>  - (libstdc++) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60734
>  - (Firefox) https://bugzilla.mozilla.org/show_bug.cgi?id=1074280
> I attached a actual type confusion report and object relationship 
> information. 



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

-
To unsubscribe, e-mail: c-dev-unsubscr...@xerces.apache.org
For additional commands, e-mail: c-dev-h...@xerces.apache.org



[jira] [Commented] (XERCESC-2088) Bad casting from DOMTextImpl to DOMElementImpl

2017-06-28 Thread Scott Cantor (JIRA)

[ 
https://issues.apache.org/jira/browse/XERCESC-2088?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16066561#comment-16066561
 ] 

Scott Cantor commented on XERCESC-2088:
---

My impression from a few tries at adding some additional type-safe methods is 
that this is unfixable without simply fixing the DOM classes to expose whatever 
fields these casts are trying to access.

I think we need a new virtual mixin base class with methods to expose 
implementation details, and then a dynamic_cast to the mixin in the DOMCast 
methods to get at them where needed.

I do not propose actually redesigning the DOM classes themselves to inherit 
common fields or anything like that, this is strictly suggesting we expose the 
private bits via an interface.

> Bad casting from DOMTextImpl to DOMElementImpl
> --
>
> Key: XERCESC-2088
> URL: https://issues.apache.org/jira/browse/XERCESC-2088
> Project: Xerces-C++
>  Issue Type: Bug
>  Components: DOM
>Affects Versions: 3.1.1, 3.1.2, 3.1.3, 3.1.4
> Environment: ubuntu 16.04 LTS, Intel(R) Core(TM) i7-6700 CPU @ 
> 3.40GHz, 16GB
>Reporter: Yuseok Jeon
> Fix For: 3.2.0
>
> Attachments: Actual_result.txt, relationship_tree.jpeg
>
>
> Hi all, 
> Our recently developed type confusion detection tool reports a type_confusion 
> error in the "xercesc/dom/imple/DOMCasts.hpp" 
> xercesc/dom/imple/DOMCasts.hpp, line 146
> static inline DOMNodeImpl *castToNodeImpl(const DOMNode *p)
> {
> DOMElementImpl *pE = (DOMElementImpl *)p;
> return &(pE->fNode);
> }
> p is pointing to the object allocated as DOMTextImpl, and it is casted into 
> DOMElementImpl. However, since DOMElementImpl is not a subobject of 
> DOMTextImpl, it is violating C++ standard rules 5.2.9/11 (down casting is 
> undefined if the object that the pointer to be casted points to is not a 
> suboject of down casting type) and causes undefined behaviors.
> There are similar type-confusion cases as below links. 
>  - (libstdc++) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60734
>  - (Firefox) https://bugzilla.mozilla.org/show_bug.cgi?id=1074280
> I attached a actual type confusion report and object relationship 
> information. 



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

-
To unsubscribe, e-mail: c-dev-unsubscr...@xerces.apache.org
For additional commands, e-mail: c-dev-h...@xerces.apache.org



[jira] [Commented] (XERCESC-2088) Bad casting from DOMTextImpl to DOMElementImpl

2017-05-01 Thread Alberto Massari (JIRA)

[ 
https://issues.apache.org/jira/browse/XERCESC-2088?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15991421#comment-15991421
 ] 

Alberto Massari commented on XERCESC-2088:
--

Let's say "we're depending", I am not the author of that code... 

> Bad casting from DOMTextImpl to DOMElementImpl
> --
>
> Key: XERCESC-2088
> URL: https://issues.apache.org/jira/browse/XERCESC-2088
> Project: Xerces-C++
>  Issue Type: Bug
>  Components: DOM
>Affects Versions: 3.1.1, 3.1.2, 3.1.3, 3.1.4
> Environment: ubuntu 16.04 LTS, Intel(R) Core(TM) i7-6700 CPU @ 
> 3.40GHz, 16GB
>Reporter: Yuseok Jeon
> Fix For: 3.2.0
>
> Attachments: Actual_result.txt, relationship_tree.jpeg
>
>
> Hi all, 
> Our recently developed type confusion detection tool reports a type_confusion 
> error in the "xercesc/dom/imple/DOMCasts.hpp" 
> xercesc/dom/imple/DOMCasts.hpp, line 146
> static inline DOMNodeImpl *castToNodeImpl(const DOMNode *p)
> {
> DOMElementImpl *pE = (DOMElementImpl *)p;
> return &(pE->fNode);
> }
> p is pointing to the object allocated as DOMTextImpl, and it is casted into 
> DOMElementImpl. However, since DOMElementImpl is not a subobject of 
> DOMTextImpl, it is violating C++ standard rules 5.2.9/11 (down casting is 
> undefined if the object that the pointer to be casted points to is not a 
> suboject of down casting type) and causes undefined behaviors.
> There are similar type-confusion cases as below links. 
>  - (libstdc++) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60734
>  - (Firefox) https://bugzilla.mozilla.org/show_bug.cgi?id=1074280
> I attached a actual type confusion report and object relationship 
> information. 



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

-
To unsubscribe, e-mail: c-dev-unsubscr...@xerces.apache.org
For additional commands, e-mail: c-dev-h...@xerces.apache.org



[jira] [Commented] (XERCESC-2088) Bad casting from DOMTextImpl to DOMElementImpl

2017-05-01 Thread Scott Cantor (JIRA)

[ 
https://issues.apache.org/jira/browse/XERCESC-2088?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15991359#comment-15991359
 ] 

Scott Cantor commented on XERCESC-2088:
---

Neither is safe. You're depending on the compiler's object layout behavior and 
while that was never "right", it is (to my understanding) now explicitly called 
out in the standard as unspecified behavior.

We're basically not on fire but we have to fix it, and we can't depend on the 
position of the member in the class.

> Bad casting from DOMTextImpl to DOMElementImpl
> --
>
> Key: XERCESC-2088
> URL: https://issues.apache.org/jira/browse/XERCESC-2088
> Project: Xerces-C++
>  Issue Type: Bug
>  Components: DOM
>Affects Versions: 3.1.1, 3.1.2, 3.1.3, 3.1.4
> Environment: ubuntu 16.04 LTS, Intel(R) Core(TM) i7-6700 CPU @ 
> 3.40GHz, 16GB
>Reporter: Yuseok Jeon
> Attachments: Actual_result.txt, relationship_tree.jpeg
>
>
> Hi all, 
> Our recently developed type confusion detection tool reports a type_confusion 
> error in the "xercesc/dom/imple/DOMCasts.hpp" 
> xercesc/dom/imple/DOMCasts.hpp, line 146
> static inline DOMNodeImpl *castToNodeImpl(const DOMNode *p)
> {
> DOMElementImpl *pE = (DOMElementImpl *)p;
> return &(pE->fNode);
> }
> p is pointing to the object allocated as DOMTextImpl, and it is casted into 
> DOMElementImpl. However, since DOMElementImpl is not a subobject of 
> DOMTextImpl, it is violating C++ standard rules 5.2.9/11 (down casting is 
> undefined if the object that the pointer to be casted points to is not a 
> suboject of down casting type) and causes undefined behaviors.
> There are similar type-confusion cases as below links. 
>  - (libstdc++) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60734
>  - (Firefox) https://bugzilla.mozilla.org/show_bug.cgi?id=1074280
> I attached a actual type confusion report and object relationship 
> information. 



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

-
To unsubscribe, e-mail: c-dev-unsubscr...@xerces.apache.org
For additional commands, e-mail: c-dev-h...@xerces.apache.org



[jira] [Commented] (XERCESC-2088) Bad casting from DOMTextImpl to DOMElementImpl

2017-05-01 Thread Alberto Massari (JIRA)

[ 
https://issues.apache.org/jira/browse/XERCESC-2088?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15991345#comment-15991345
 ] 

Alberto Massari commented on XERCESC-2088:
--

This is a cast required by the fact that each implementation class derives only 
from the interface class, and includes the implementation of the basic methods 
from DOMNode by embedding a DOMNodeImpl instance. This instance is always the 
first member of the implementation class, so actually it doesn't matter that 
the method does a cast to DOMElementImpl, as any other class would be just 
fine. If the compiler doesn't accept a C-style cast, maybe a 
reinterpret_cast could work

> Bad casting from DOMTextImpl to DOMElementImpl
> --
>
> Key: XERCESC-2088
> URL: https://issues.apache.org/jira/browse/XERCESC-2088
> Project: Xerces-C++
>  Issue Type: Bug
>  Components: DOM
>Affects Versions: 3.1.1, 3.1.2, 3.1.3, 3.1.4
> Environment: ubuntu 16.04 LTS, Intel(R) Core(TM) i7-6700 CPU @ 
> 3.40GHz, 16GB
>Reporter: Yuseok Jeon
> Attachments: Actual_result.txt, relationship_tree.jpeg
>
>
> Hi all, 
> Our recently developed type confusion detection tool reports a type_confusion 
> error in the "xercesc/dom/imple/DOMCasts.hpp" 
> xercesc/dom/imple/DOMCasts.hpp, line 146
> static inline DOMNodeImpl *castToNodeImpl(const DOMNode *p)
> {
> DOMElementImpl *pE = (DOMElementImpl *)p;
> return &(pE->fNode);
> }
> p is pointing to the object allocated as DOMTextImpl, and it is casted into 
> DOMElementImpl. However, since DOMElementImpl is not a subobject of 
> DOMTextImpl, it is violating C++ standard rules 5.2.9/11 (down casting is 
> undefined if the object that the pointer to be casted points to is not a 
> suboject of down casting type) and causes undefined behaviors.
> There are similar type-confusion cases as below links. 
>  - (libstdc++) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60734
>  - (Firefox) https://bugzilla.mozilla.org/show_bug.cgi?id=1074280
> I attached a actual type confusion report and object relationship 
> information. 



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

-
To unsubscribe, e-mail: c-dev-unsubscr...@xerces.apache.org
For additional commands, e-mail: c-dev-h...@xerces.apache.org