[ZCM] [ZC] 1267/ 6 Comment "Segfault on x86_64"

Collector: Zope Bugs, Features, and Patches ... zope-coders-admin at zope.org
Thu Aug 5 05:40:08 EDT 2004


Issue #1267 Update (Comment) "Segfault on x86_64"
 Status Pending, Zope/bug+solution medium
To followup, visit:
  http://collector.zope.org/Zope/1267

==============================================================
= Comment - Entry #6 by longsleep on Aug 5, 2004 5:40 am

i confirm that this patch works. I wonder a bit why it hasnt made its way in 2.7.1 or 2.7.2. 

With this patch applied initgroups works pretty well on both 32 and 64 bit linux systems.

There is a small typo in the original patch. "usigned int igid;" needs to become "unsigned int igid;"

Please consider to apply this patch to zopes cvs trunk  to have it fixed in further releases.

________________________________________
= Resubmit - Entry #5 by tseaver on Mar 22, 2004 1:38 pm

 Status: Resolved => Pending

OK, 1268 is the decoy, then.
________________________________________
= Resolve - Entry #4 by tseaver on Mar 22, 2004 12:02 pm

 Status: Pending => Resolved

Submitter followed up with a modified patch in #1268:

  http://zope.org/Collectors/Zope/1268/
________________________________________
= Comment - Entry #3 by nijel on Mar 22, 2004 11:58 am


Uploaded:  "Zope-2.7.0-gid2.patch"
 - http://collector.zope.org/Zope/1267/Zope-2.7.0-gid2.patch/view
I is not solution as int is 64-bit on x86_64. Anyway the original patch was bad, it has to be unsigned int to hold gid_t...

gid_t is currently on linux defined as u32. This works fine with int on 32-bit platforms, but not on 64-bit, where 32 bits around get replaced.
________________________________________
= Comment - Entry #2 by tim_one on Mar 22, 2004 11:45 am

Well, C doesn't define the size of any integer type.  Starting with Python 2.3 (which is required for Zope 2.7), you can use the "I" format code in PyArg_ParseTuple to get whatever the platform C compiler thinks an unsigned int is.  There's no guarantee that this is 32 bits, although it is on all Python platforms I know about except for some Cray machines.

The other insecurity here is your claim that gid_t is an unsigned 32-bit int.  I don't doubt that it is on your platform today, but it can't be that on all platforms (for example, the Crays mentioned above don't have any 32-bit integer type).

All that out of the way, your patch is definitely an improvement, and fixing it for all possible platforms is a real chore (e.g., get the group id as a Python object, and then do runtime case analysis on the type of the argument versus the size of the platform's gid_t).  The

    gid = igid;

line should really add an explicit cast for clarity:

    gid = (gid_t)igid;
________________________________________
= Request - Entry #1 by nijel on Mar 22, 2004 10:35 am


Uploaded:  "Zope-2.7.0-gid.patch"
 - http://collector.zope.org/Zope/1267/Zope-2.7.0-gid.patch/view
initgroups wants to get gid_t from tuple what leads to segfault on some platforms as gid_t is defined as unsigned 32-bit. Parsing as long is okay on ix86, but on x86_64 (AMD64) this leads to segfault as long is 64-bit. The additional conversion through might not be needed, but I don't see way how to specify unsigned 32-bit integer in PyArg_ParseTuple.
==============================================================



More information about the Zope-Collector-Monitor mailing list