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

Inbuilt KORN Arithmetic & Test functions broken under Windows Subsystem for Linux #4244

Closed
foocrypt opened this issue Jun 29, 2019 · 4 comments

Comments

@foocrypt
Copy link

Hello

I seem to have come across an abnormality, with the Ubuntu ( DEBIAN ) KORN Shell package [
Version AJM 93u+ 2012-08-01 ] when it is running under the Windows Subsystem for Linux.

Basic inbuilt arithmetic and test functions appear to be broken for long lengths under WSL

Refer : https://bugs.launchpad.net/ubuntu/+source/ksh/+bug/1818596
for analyse and WSL version / confirmation of bug.

Refer : https://bugs.launchpad.net/ubuntu/+source/ksh/+bug/1818596
for analyse and WSL version / confirmation of bug.

Reproducible with WSL on Insider build 18917

<-- Beging Test Script -->

#!/bin/ksh

Y=1
Z=1
X=7680072911
C=1
until [ ${C} -eq 50 ]
do
typeset -i -l Y=$(( ${Y} + ${Y} + ${X} ))
typeset -i -l Z=$( echo "(${Z} + ${Z} + ${X})" | bc )
print "C=${C},Y=${Y},Z=${Z}, $( [ ${Y} -ne ${Z} ] && print Error || print Ok )"
C=$(( ${C} + 1 ))
done

<--- End Test Script ---->

The test script returns significantly different results on standard KORN Version AJM 93u+ 2012-08-01 running under Ubuntu, Darwin, etc as opposed to running under the WSL.

<-- Ubuntu, Darwin, -->

C=1,Y=7680072913,Z=7680072913, Ok
C=2,Y=23040218737,Z=23040218737, Ok
C=3,Y=53760510385,Z=53760510385, Ok
C=4,Y=115201093681,Z=115201093681, Ok
C=5,Y=238082260273,Z=238082260273, Ok
C=6,Y=483844593457,Z=483844593457, Ok
C=7,Y=975369259825,Z=975369259825, Ok
C=8,Y=1958418592561,Z=1958418592561, Ok
C=9,Y=3924517258033,Z=3924517258033, Ok
C=10,Y=7856714588977,Z=7856714588977, Ok
C=11,Y=15721109250865,Z=15721109250865, Ok
C=12,Y=31449898574641,Z=31449898574641, Ok
C=13,Y=62907477222193,Z=62907477222193, Ok
C=14,Y=125822634517297,Z=125822634517297, Ok
C=15,Y=251652949107505,Z=251652949107505, Ok
C=16,Y=503313578287921,Z=503313578287921, Ok
C=17,Y=1006634836648753,Z=1006634836648753, Ok
C=18,Y=2013277353370417,Z=2013277353370417, Ok
C=19,Y=4026562386813745,Z=4026562386813745, Ok
C=20,Y=8053132453700401,Z=8053132453700401, Ok
C=21,Y=16106272587473713,Z=16106272587473713, Ok
C=22,Y=32212552855020337,Z=32212552855020337, Ok
C=23,Y=64425113390113585,Z=64425113390113585, Ok
C=24,Y=128850234460300081,Z=128850234460300081, Ok
C=25,Y=257700476600673073,Z=257700476600673073, Ok
C=26,Y=515400960881419057,Z=515400960881419057, Ok
C=27,Y=1030801929442911025,Z=1030801929442911025, Ok
C=28,Y=2061603866565894961,Z=2061603866565894961, Ok
C=29,Y=4123207740811862833,Z=4123207740811862833, Ok
C=30,Y=8246415489303798577,Z=8246415489303798577, Ok
C=31,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=32,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=33,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=34,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=35,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=36,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=37,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=38,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=39,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=40,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=41,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=42,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=43,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=44,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=45,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=46,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=47,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=48,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=49,Y=-9223372036854775808,Z=-9223372036854775808, Ok

<<-- WSL with the Ubuntu 16.04 & 18.04 LTS & Debian GNU/Linux Packages -->

C=1,Y=7680072913,Z=7680072913, Ok
C=2,Y=23040218737,Z=23040218737, Ok
C=3,Y=53760510385,Z=53760510385, Ok
C=4,Y=115201093681,Z=115201093681, Ok
C=5,Y=238082260273,Z=238082260273, Ok
C=6,Y=483844593457,Z=483844593457, Ok
C=7,Y=975369259825,Z=975369259825, Ok
C=8,Y=1958418592561,Z=1958418592561, Ok
C=9,Y=3924517258033,Z=3924517258033, Ok
C=10,Y=7856714588977,Z=7856714588977, Ok
C=11,Y=15721109250865,Z=15721109250865, Ok
C=12,Y=31449898574641,Z=31449898574641, Ok
C=13,Y=62907477222193,Z=62907477222193, Ok
C=14,Y=125822634517297,Z=125822634517297, Ok
C=15,Y=251652949107505,Z=251652949107505, Ok
C=16,Y=503313578287921,Z=503313578287921, Ok
C=17,Y=1006634836648753,Z=1006634836648753, Ok
C=18,Y=2013277353370417,Z=2013277353370417, Ok
C=19,Y=4026562386813745,Z=4026562386813745, Ok
C=20,Y=8053132453700401,Z=8053132453700401, Ok
C=21,Y=16106272587473712,Z=16106272587473713, Ok
C=22,Y=32212552855020336,Z=32212552855020337, Ok
C=23,Y=64425113390113584,Z=64425113390113585, Ok
C=24,Y=128850234460300080,Z=128850234460300081, Ok
C=25,Y=257700476600673056,Z=257700476600673073, Error
C=26,Y=515400960881419008,Z=515400960881419057, Error
C=27,Y=1030801929442910976,Z=1030801929442911025, Ok
C=28,Y=2061603866565894912,Z=2061603866565894961, Ok
C=29,Y=4123207740811862528,Z=4123207740811862833, Error
C=30,Y=8246415489303797760,Z=8246415489303798577, Error
C=31,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=32,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=33,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=34,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=35,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=36,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=37,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=38,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=39,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=40,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=41,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=42,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=43,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=44,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=45,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=46,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=47,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=48,Y=-9223372036854775808,Z=-9223372036854775808, Ok
C=49,Y=-9223372036854775808,Z=-9223372036854775808, Ok

@therealkenc
Copy link
Collaborator

Reproducible with WSL on Insider build 18917

#830. Will be okay if you go WSL2.

@foocrypt
Copy link
Author

@therealkenc I think you are missing the underlying points.

The previous KORN issues are not related to long lengths.

Why have you flagged it as a duplicate ?

https://github.com/microsoft/WSL/issues?utf8=✓&q=korn+

@therealkenc
Copy link
Collaborator

therealkenc commented Jun 30, 2019

@therealkenc I think you are missing the underlying points.

I suppose that could happen in principle. But not in this case.

The previous KORN issues are not related to long lengths.

You're right, the previous KORN tickets are not related to long lengths. #830 is the duplicate ticket causing your long length issues with KORN.

Your remedies are (a) Use WSL2, (b) Stick a _FPU_SETCW(0x37f) in a local build of ksh to work around the #830 bug (let's say, here) or some variant thereof, or (c) Wait for duplicate issue #830 to flip status.

Me I'd go with (a).

But it is late on Saturday night and I'm still awake, so (b) for the time sink value.

image

Why have you flagged it as a duplicate ?

Because this issue is dupe #830.

@foocrypt
Copy link
Author

Easier to go with running Linux in a VM ignoring all the other bugs in WSL, WSL2, Windows10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants