[Python-bugs-list] [ python-Bugs-538361 ] packing double yields garbage

noreply@sourceforge.net noreply@sourceforge.net
Sun, 07 Apr 2002 15:19:49 -0700


Bugs item #538361, was opened at 2002-04-02 12:54
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=538361&group_id=5470

Category: Python Library
>Group: Platform-specific
Status: Open
Resolution: None
Priority: 5
Submitted By: Mike Carifio (carifio)
Assigned to: Nobody/Anonymous (nobody)
Summary: packing double yields garbage

Initial Comment:
On RH Linux 6.2/alpha (kernal 2.2.14-6.0), egcs-
2.91.66, python 2.2.1c2. I build python
from source and test_struct.py dies with
a floating point exception. I believe I've
found out why:


>>> import struct
>>> s = struct.pack("d", 3.14e20)
>>> struct.unpack("d", s)
(1.69270791053e-307,)


----------------------------------------------------------------------

>Comment By: Guido van Rossum (gvanrossum)
Date: 2002-04-07 18:19

Message:
Logged In: YES 
user_id=6380

- Does the same error occur in earlier versions (2.2,
2.1.2)?

- I'm relabeling this as platform-specific because it only
fails on alphas (not the world's most popular CPU
architecture).

----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2002-04-02 16:24

Message:
Logged In: YES 
user_id=31435

Can you show what's in s?  As is, it's impossible to guess 
whether the problem is in pack() or unpack().  Life would 
be simpler if you started with a simpler float too (like, 
say, 1.0).

Something random that might help:  recompile structmodule.c 
with optimization turned off.

One other:  is this Alpha configured to run in big-endian 
or little-endian mode?

----------------------------------------------------------------------

Comment By: Mike Carifio (carifio)
Date: 2002-04-02 13:59

Message:
Logged In: YES 
user_id=503643

EV6 I think. Can I run a command to find out?


----------------------------------------------------------------------

Comment By: Michael Hudson (mwh)
Date: 2002-04-02 13:51

Message:
Logged In: YES 
user_id=6656

Oh.  That means it might be our fault.  Damn.

Erm, clutching at straws: what flavour of alpha is this?  I'm 
guessing this is some kind of alignment problem.



----------------------------------------------------------------------

Comment By: Mike Carifio (carifio)
Date: 2002-04-02 13:48

Message:
Logged In: YES 
user_id=503643

I also tried this on RH7.*/alpha/2.4.something kernel
and gcc 2.95.something and got the same error. Actually,
it started with test_struct.py core dumping. I don't
actually need to pack doubles. I was just being a good
doobie.

----------------------------------------------------------------------

Comment By: Mike Carifio (carifio)
Date: 2002-04-02 13:47

Message:
Logged In: YES 
user_id=503643

I also tried this on RH7.*/alpha/2.4.something kernel
and gcc 2.95.something and got the same error. Actually,
it started with test_struct.py core dumping. I don't
actually need to pack doubles. I was just being a good
doobie.

----------------------------------------------------------------------

Comment By: Michael Hudson (mwh)
Date: 2002-04-02 13:33

Message:
Logged In: YES 
user_id=6656

Hmm, that looks broke.

However, I don't see this behaviour on sf's compile farm with 
221c1; I'm building 221c2 now, but I'd be amazed if it's 
different.

That machine has kernel 2.4.something and gcc 2.95.something, 
so is it possible that this is a now-fixed bug in one those 
(most likely the compiler)?


----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=538361&group_id=5470