You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Scott Cantor <ca...@osu.edu> on 2003/05/01 21:13:40 UTC
gcc bug involving XMLFormatter
I'm running into a problem using xml-security-c on top of Xerces 2.2 on Linux with gcc 3.2.2. I'm not sure if this behaves
differently on other gcc versions, but it might.
There's a call chain into the XMLFormatter code inside the inEscapeList() call, and it's crashing because the method is receiving a
bad value for the escStyle parameter, which comes from the enum list for XMLFormatter::EscapeFlags.
It should be set to zero if you follow all the default parameters around, but it ends up getting called with a large negative
number, and so the array lookup in that method crashes.
It's a compiler bug since the enum should be zero-based by default anyway, but when I edit XMLFormatter.hpp to assign the first
constant value to zero by hand and rebuild it all, that fixes the problem. I'd suggest patching that just to avoid the hassle if
people run into the compiler bug.
-- Scott
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
RE: gcc bug involving XMLFormatter
Posted by Scott Cantor <ca...@osu.edu>.
> thanks for the info. Is this a documented compiler bug? I ask
> because I always get worried when things like this happen. Are you sure
> that its not just overwriting memory somehow? Is there any chance of a
> small example that shows this behaviour.
I saw some bugs that sounded similar, relating to initialization of arrays using an enum as one of the bounds, but not exact. My
best evidence that it's a compiler issue are that:
a) so far it only appeared on one platform (Linux)
b) it disappeared when I modified the header file from Xerces to assign values to the enumeration constants and rebuilt
That doesn't sound like a memory overwrite issue to me, since changing the header shouldn't have any effect on what would get
overwritten. The bug was also consistent, and occurred identically with and without -g used to compile Xerces.
Finding a small example may be hard, and I don't have time immediately to try and reproduce the behavior in a smaller context. I
have code that definitely reproduces it easily, but it's a large set of interdependent libraries (http://www.opensaml.org/). If I
get a chance, I can try to reproduce something.
I could probably provide binaries that somebody could use to generate a core dump, though. Or someone can build OpenSAML/etc. from
source of course, but it takes a little bit of work.
The modified version of XMLFormatter.hpp that fixed the bug without any other changes is attached. I speculate that it's the
assigning of the first enum to zero that is sufficient to fix it (I don't think it's the Count enum constant that gets used to init
the escapes array, which is why I don't think it's the same gcc bug that I found in gnats).
-- Scott
Re: gcc bug involving XMLFormatter
Posted by Gareth Reakes <ga...@decisionsoft.com>.
Hi,
thanks for the info. Is this a documented compiler bug? I ask
because I always get worried when things like this happen. Are you sure
that its not just overwriting memory somehow? Is there any chance of a
small example that shows this behaviour.
cheers,
Gareth
On Thu, 1 May 2003, Scott Cantor wrote:
> I'm running into a problem using xml-security-c on top of Xerces 2.2 on Linux with gcc 3.2.2. I'm not sure if this behaves
> differently on other gcc versions, but it might.
>
> There's a call chain into the XMLFormatter code inside the inEscapeList() call, and it's crashing because the method is receiving a
> bad value for the escStyle parameter, which comes from the enum list for XMLFormatter::EscapeFlags.
>
> It should be set to zero if you follow all the default parameters around, but it ends up getting called with a large negative
> number, and so the array lookup in that method crashes.
>
> It's a compiler bug since the enum should be zero-based by default anyway, but when I edit XMLFormatter.hpp to assign the first
> constant value to zero by hand and rebuild it all, that fixes the problem. I'd suggest patching that just to avoid the hassle if
> people run into the compiler bug.
>
> -- Scott
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>
>
--
Gareth Reakes, Head of Product Development +44-1865-203192
DecisionSoft Limited http://www.decisionsoft.com
XML Development and Services
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org