After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 303670 - Schema timezone problem due to unsigned bit field on AIX
Schema timezone problem due to unsigned bit field on AIX
Status: VERIFIED FIXED
Product: libxml2
Classification: Platform
Component: general
git master
Other AIX
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2005-05-10 14:22 UTC by Steve Nairn
Modified: 2009-08-15 18:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
proposed patch to xmlschemastypes.c (510 bytes, patch)
2005-05-10 14:25 UTC, Steve Nairn
none Details | Review
Errors running "testSchemas date_0.xsd date_0.xml" (2.00 KB, text/plain)
2005-05-10 14:26 UTC, Steve Nairn
  Details

Description Steve Nairn 2005-05-10 14:22:48 UTC
Distribution/Version: 4.3

On AIX V4.3 using cc_r (AIX Compilers V3.1, level 4.4.0.0 - though I don't think
the version's important), configure and compile libxml2 and run the regressions
tests.

I used the configure options "--enable-shared=no --without-ftp --without-http
--without-python --without-modules" but I think the only important one is
"--with-schemas", which is on by default.

The problem is demonstrated in the Schemas regression tests (by date_0.xsd). The
individual test can be run with:
./testSchemas ./test/schemas/date_0.xsd ./test/schemas/date_0.xml
I've attached the error messages.

The cause of the problem is the use of an 'int' data type for the tzo member (a
bitfield) of the _xmlSchemaValDate struct in xmlschemastypes.c.

The C standard does not specify whether 'int' data types for bitfields are
signed or unsigned - the implementation is free to choose (section 6.7.2.1 of
the C standard, according to gcc's documentation). IBM's C compiler makes them
unsigned and (it seems that) just about everything else makes them signed.

Since tzo is unsigned on AIX the VALID_TZO macro nearly always evaluates to false.

The tzo member must be signed (since a time zone can be both positive and
negative) so it needs to be marked as signed. The comment in the code indicates
that the range of tzo is -1440 to +1440, for which 12 bits is required (not the
current 11). I've attached a patch to make both these changes.

Note that the same problem occurs in libxslt, in the _exsltDateValDate struct in
libexslt/date.c.

Also, is there any real reason to use bitfields in these structs? It doesn't
save any data space (because of alignment) but adds to the size of the generated
code. Wouldn't it be better to use unsigned chars and a short?
Comment 1 Steve Nairn 2005-05-10 14:25:09 UTC
Created attachment 46290 [details] [review]
proposed patch to xmlschemastypes.c

Changes the tzo field of _xmlSchemaValDate to signed and 12 bit
Comment 2 Steve Nairn 2005-05-10 14:26:49 UTC
Created attachment 46291 [details]
Errors running "testSchemas date_0.xsd date_0.xml"
Comment 3 kbuchcik 2005-05-12 12:04:11 UTC
According to [1], the timezone needs to hold values in the range -840 to +840,
since only 14 hours need to be expressed; so only 10 bits needed at least.

[1] http://www.w3.org/TR/xmlschema-2/#dateTime-timezones
Comment 4 kbuchcik 2005-05-12 13:12:32 UTC
OK, applied and commited: xmlschemastypes.c revision 1.90.

Thanks for the report!
Comment 5 kbuchcik 2005-05-12 13:18:22 UTC
Changed the VALID_TZO macro to restrict the value to be within the range of -840
to 840.
Comment 6 Daniel Veillard 2005-09-05 09:01:03 UTC
This should be closed by release of libxml2-2.6.21,

  thanks,

Daniel