This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: packing double yields garbage
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: nnorwitz Nosy List: carifio, gvanrossum, mwh, nnorwitz, tim.peters, tzot
Priority: normal Keywords:

Created on 2002-04-02 17:54 by carifio, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Messages (13)
msg10115 - (view) Author: Mike Carifio (carifio) Date: 2002-04-02 17:54
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,)
msg10116 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2002-04-02 18:33
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)?
msg10117 - (view) Author: Mike Carifio (carifio) Date: 2002-04-02 18:47
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.
msg10118 - (view) Author: Mike Carifio (carifio) Date: 2002-04-02 18:48
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.
msg10119 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2002-04-02 18:51
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.

msg10120 - (view) Author: Mike Carifio (carifio) Date: 2002-04-02 18:59
Logged In: YES 
user_id=503643

EV6 I think. Can I run a command to find out?
msg10121 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2002-04-02 21:24
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?
msg10122 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-04-07 22:19
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).
msg10123 - (view) Author: Χρήστος Γεωργίου (Christos Georgiou) (tzot) * Date: 2002-09-04 16:41
Logged In: YES 
user_id=539787

I think it is something that might have been solved by patch
601369.  carifio, can you try downloading the latest
Modules/structmodule.c and try again?
msg10124 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2003-01-08 01:23
Logged In: YES 
user_id=33168

This same problem exists in the snake farm (RedHat 6.2/alpha
egcs 2.91.66).  It turned out to be a compiler bug.  Turning
optimization off fixed the problem.  Unless I hear
otherwise, I will close this bug report.
msg10125 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2003-01-08 02:12
Logged In: YES 
user_id=31435

Is our evidence that it's a compiler bug solely that turning 
optimization off made the problem go away?  If so, that's a 
good clue but not definitive.  It could be that Python's C 
code is ill-defined in such a way that optimizing or not 
changes which kind of undefined behavior obtains.  To nail 
this really requires determining exactly which piece of the 
Python code changed behavior.  This may not be easy, and 
in some cases may even require digging into the generated 
machine code.
msg10126 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2003-01-08 02:22
Logged In: YES 
user_id=33168

> Is our evidence that it's a compiler bug solely that turning
> optimization off made the problem go away?

Yes.  The test is failing right now:

http://www.lysator.liu.se/xenofarm/python/files/2437_6/testlog.txt

I built the test normally and got the same failure.  I built
python with -O0 and the test passed.

Python's code may have had a problem.  On 9/3/2002, rev 2.57
to Module/structmodule.c changed to use memcpy "to avoid
alignment errors."  That was from patch 601369 which
appeared to be necessary for MIPS.

The same code does work on a different alpha, running a
different kernel, different glibc, and different compiler. 
(It works with optimization.)

http://www.lysator.liu.se/xenofarm/python/files/2479_31/testlog.txt

Suggestions?
msg10127 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2003-01-08 02:29
Logged In: YES 
user_id=31435

You have to be really interested to track one of these 
down.  I started asking leading questions in April, but 
didn't get a response.  If nobody who runs on Alphas is 
interested enough to help, the heck with it.
History
Date User Action Args
2022-04-10 16:05:10adminsetgithub: 36368
2002-04-02 17:54:12carifiocreate