Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test.cmath fails on OS/X with gcc-4.8 in non-debug build #62713

Closed
rhettinger opened this issue Jul 20, 2013 · 8 comments
Closed

test.cmath fails on OS/X with gcc-4.8 in non-debug build #62713

rhettinger opened this issue Jul 20, 2013 · 8 comments
Assignees
Labels
extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error

Comments

@rhettinger
Copy link
Contributor

BPO 18513
Nosy @rhettinger, @mdickinson

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/mdickinson'
closed_at = <Date 2013-07-20.17:01:07.196>
created_at = <Date 2013-07-20.08:22:09.245>
labels = ['extension-modules', 'type-bug']
title = 'test.cmath fails on OS/X with gcc-4.8 in non-debug build'
updated_at = <Date 2013-07-20.18:12:38.863>
user = 'https://github.com/rhettinger'

bugs.python.org fields:

activity = <Date 2013-07-20.18:12:38.863>
actor = 'mark.dickinson'
assignee = 'mark.dickinson'
closed = True
closed_date = <Date 2013-07-20.17:01:07.196>
closer = 'mark.dickinson'
components = ['Extension Modules']
creation = <Date 2013-07-20.08:22:09.245>
creator = 'rhettinger'
dependencies = []
files = []
hgrepos = []
issue_num = 18513
keywords = []
message_count = 8.0
messages = ['193402', '193410', '193412', '193413', '193414', '193418', '193419', '193420']
nosy_count = 3.0
nosy_names = ['rhettinger', 'mark.dickinson', 'python-dev']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue18513'
versions = ['Python 3.3', 'Python 3.4']

@rhettinger
Copy link
Contributor Author

======================================================================
FAIL: test_specific_values (main.CMathTests)
----------------------------------------------------------------------

Traceback (most recent call last):
  File "/Users/raymondhettinger/cpython/Lib/test/test_cmath.py", line 382, in test_specific_values
    msg=error_message)
  File "/Users/raymondhettinger/cpython/Lib/test/test_cmath.py", line 128, in rAssertAlmostEqual
    'got {!r}'.format(a, b))
AssertionError: rect1017: rect(complex(0.0, -0.0))
Expected: complex(0.0, -0.0)
Received: complex(0.0, 0.0)
Received value insufficiently close to expected value.

@rhettinger rhettinger added extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error labels Jul 20, 2013
@mdickinson
Copy link
Member

Hmm. Looks similar to issue bpo-15477, but that one was fixed (we added a local workaround and reported the OS bug to Apple). And it was with clang rather than gcc.

Raymond: from the title, can I assume that you don't see this failure on a debug build? That would tend to point to a compiler optimization bug.

@mdickinson
Copy link
Member

I can't reproduce this here on OS 10.6 (I don't have access to anything later), but I think I can guess what's happening: I suspect that gcc 4.8 is optimizing the pair of 'cos' and 'sin' calls into a single call to 'cexp'. And then the OS X library implementation of _cexp has buggy behaviour with respect to signs of zeros (this last part is something I've witnessed before, but I forget which version of OS X it was on).

It's easy to work around, by adding a special case for zeros in cmath_rect. It's a bit annoying to have to do so, though.

@python-dev
Copy link
Mannequin

python-dev mannequin commented Jul 20, 2013

New changeset ce771c2d0220 by Mark Dickinson in branch '3.3':
Issue bpo-18513: Add workaround for OS X 10.8 cexp bug that leads to wrong cmath.rect(0.0,-0.0) results.
http://hg.python.org/cpython/rev/ce771c2d0220

New changeset ae769deb45b2 by Mark Dickinson in branch 'default':
Issue bpo-18513: Add workaround for OS X 10.8 cexp bug that leads to wrong cmath.rect(0.0,-0.0) results.
http://hg.python.org/cpython/rev/ae769deb45b2

@mdickinson
Copy link
Member

Should be fixed now.

@python-dev
Copy link
Mannequin

python-dev mannequin commented Jul 20, 2013

New changeset 91374660355a by Raymond Hettinger in branch '2.7':
Issue bpo-18513: Add workaround for OS X 10.8 cexp bug that leads to wrong cmath.rect(0.0,-0.0) results.
http://hg.python.org/cpython/rev/91374660355a

@rhettinger
Copy link
Contributor Author

Thanks Mark. test_cmath passed now. I've also applied this to Python2.7.

@mdickinson
Copy link
Member

Thanks, Raymond.

Postscript: I had a feeling of deja vu about this, and I've just been searching through old emails. It turns out I filed an OS X bug (#6466807 ) for this exact issue back in 2008; cexp was broken in 10.5, fixed in 10.6, and clearly is now broken again in 10.8. I've added a note to that Apple bug report, for what it's worth.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants