[Python-bugs-list] [ python-Bugs-442520 ] test_struct fails on SPARC
noreply@sourceforge.net
noreply@sourceforge.net
Thu, 19 Jul 2001 02:53:34 -0700
Bugs item #442520, was opened at 2001-07-18 11:39
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=442520&group_id=5470
Category: Extension Modules
Group: Platform-specific
>Status: Closed
Resolution: Fixed
Priority: 6
Submitted By: Martin v. Löwis (loewis)
Assigned to: Martin v. Löwis (loewis)
Summary: test_struct fails on SPARC
Initial Comment:
With structmodule.c 2.48, test_struct fails on SPARC
Solaris with a SIGSEGV. This is caused by the
assignment
* (LONG_LONG *)p = x;
in np_longlong, where p is 0x1ac684, i.e. this is an
unaligned access. The Python caller is
struct.pack("q", 5)
----------------------------------------------------------------------
>Comment By: Martin v. Löwis (loewis)
Date: 2001-07-19 02:53
Message:
Logged In: YES
user_id=21627
The test passes now successfully on Solaris.
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2001-07-18 13:48
Message:
Logged In: YES
user_id=31435
Please give current CVS a try. If it works, just close
this bug report, else assign it back to me.
Modules/structmodule.c, new revision 2.49.
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2001-07-18 12:30
Message:
Logged In: YES
user_id=31435
Good idea! Thank you. I'm going to take a nap now (I
obviously need one!).
----------------------------------------------------------------------
Comment By: Guido van Rossum (gvanrossum)
Date: 2001-07-18 12:15
Message:
Logged In: YES
user_id=6380
Why not use memcpy()? E.g. memcpy(p, (char *)&x, sizeof x).
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2001-07-18 12:11
Message:
Logged In: YES
user_id=31435
Yuck. I believe it. Boosted priority.
We ultimately get *p via the ob_sval member of a
PyStringObject, obtained by struct_pack via
PyString_FromStringAndSize. The malloc in the latter is
only going to guarantee to align the start of ob_sval to
what the preceding stringobject members force it to be.
I suppose struck_pack has to overallocate string space in
this case, and compute an appropriately aligned offset
*into* ob_sval at which to begin packing, and then shift
the string "left" in memory again after packing. Got a
better idea?
BTW, I'm sure struct.unpack is going to have an isomorphic
problem on this platform. Eww -- that sucks. Possibly
better to read/write a byte at a time, and out-think the
endianness problem ...
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=442520&group_id=5470