[Python-bugs-list] [ python-Bugs-442520 ] test_struct fails on SPARC

noreply@sourceforge.net noreply@sourceforge.net
Wed, 18 Jul 2001 12:15:32 -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: None
Status: Open
Resolution: None
Priority: 6
Submitted By: Martin v. Löwis (loewis)
Assigned to: Tim Peters (tim_one)
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: 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