Bug 873385 - Random module fails on Doubles because of odd minBound behaviour
Random module fails on Doubles because of odd minBound behaviour
Status: CLOSED EOL
Product: Fedora
Classification: Fedora
Component: hugs98 (Show other bugs)
21
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Jens Petersen
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-11-05 12:31 EST by Ian Collier
Modified: 2015-12-02 11:03 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-12-01 21:41:01 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Ian Collier 2012-11-05 12:31:23 EST
I'm not sure how live this project is any more, but here goes...

$ rpm -q hugs98
hugs98-2006.09-11.fc17.x86_64

$ hugs
Type :? for help
Hugs> :load Random 
Random> randomR (1::Double,10) (mkStdGen 3)
(
Program error: arithmetic overflow

The equivalent answer in ghci is:
(1.928919588914141,2109513658 1655838864)

This seems to happen because:

Random> minBound::Int
-2147483648
Random> toInteger (minBound::Int)
-18446744071562067968
Random> toInteger (maxBound::Int)
2147483647

The implementation of Random on Doubles uses the construction
"toInteger (minBound::Int)" to get an integer random number, but
the implementation of Random on integers falls over on values
greater than 2^32-1.
Comment 1 Jens Petersen 2012-11-06 01:29:25 EST
Ah I see.  I wonder if it is a 64 bit issue?

Unfortunately hugs is pretty much dead^Wunmaintained now AFAIK.

Anyway I will try to have a look at the code later and
maybe compare with the current random package and see
if I can come up with a patch... of course there could
be other 64bit problems lurking.
Comment 2 Fedora End Of Life 2013-07-03 22:30:48 EDT
This message is a reminder that Fedora 17 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 17. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '17'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 17's end of life.

Bug Reporter:  Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 17 is end of life. If you 
would still like  to see this bug fixed and are able to reproduce it 
against a later version  of Fedora, you are encouraged  change the 
'version' to a later Fedora version prior to Fedora 17's end of life.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.
Comment 3 Jens Petersen 2013-07-11 06:15:17 EDT
Still happening with F19
Comment 4 Jens Petersen 2015-01-06 22:10:34 EST
And still for F21 of course.

hugs98.i686 seems okay: so installed that by hand would be a workaround perhaps.

I tested on Ubuntu amd64 and got the same error
(I guess the Debian package also has this problem).
Comment 5 Jens Petersen 2015-01-07 01:55:17 EST
(FWIW 64bit ghci gives:

Prelude> toInteger (minBound :: Int)
-9223372036854775808
)

Hugs seems to be assuming Int32, but something is indeed going
wildly wrong with "toInteger (minBound::Int)".

I looked at:

src/bignums.c:326:primFun(primIntToInteger) {		/* Conversion :: Int -> Integer	   */

but I am not familiar with hugs' internals and things
seems to get into deep water quickly.


BTW "toInteger (minBound + 1:: Int) -1"
and "toInteger (minBound -1:: Int) +1"
seem to give the expected answer.

I almost wonder if it would be better to drop 64bit arch build for hugs.
Comment 6 Fedora End Of Life 2015-11-04 10:46:26 EST
This message is a reminder that Fedora 21 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 21. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '21'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 21 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.
Comment 7 Fedora End Of Life 2015-12-01 21:41:04 EST
Fedora 21 changed to end-of-life (EOL) status on 2015-12-01. Fedora 21 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Note You need to log in before you can comment on or make changes to this bug.