Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 794749

Summary: mksh is using a 32-bit register for signed integers
Product: Red Hat Enterprise Linux 6 Reporter: Jamie Duncan <jduncan>
Component: mkshAssignee: Michal Hlavinka <mhlavink>
Status: CLOSED NOTABUG QA Contact: qe-baseos-tools-bugs
Severity: medium Docs Contact:
Priority: medium    
Version: 6.2CC: jduncan, mfranc
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-03-01 09:15:10 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jamie Duncan 2012-02-17 14:23:00 UTC
Description of problem:

It Looks like mksh is using a 32-bit register for signed integers, so anything above 2^31 -1 rolls over to a negative value. (Note: 536870912 = 2^29)

[root@htest06 ~]# uname -r
2.6.32-220.el6.x86_64

[root@htest06 ~]# rpm -qa mksh
mksh-39-7.el6.x86_64

[root@htest06 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.2 (Santiago)

[root@htest06 ~]# alternatives --config ksh

There is 1 program that provides 'ksh'.

  Selection    Command
-----------------------------------------------
*+ 1           /bin/mksh

Enter to keep the current selection[+], or type selection number:


Version-Release number of selected component (if applicable):
RHEL 6.2

How reproducible:
Easy to reproduce

Steps to Reproduce:

$ echo "2^29 = $(( 1 * 536870912 ))"
2^29 = 536870912
$ echo "2^30 = $(( 2 * 536870912 ))"
2^30 = 1073741824
$ echo "2^31 = $(( 4 * 536870912 ))"
2^31 = -2147483648
$ echo "2^31 - 1 = $(( 4 * 536870912 - 1 ))"
2^31 - 1 = 2147483647
  
Actual results:

-2147483648

Expected results:

2147483648

Additional info:

Comment 1 Michal Hlavinka 2012-02-29 09:31:17 UTC
reproducible with mksh(rhel6), not reproducible with pdksh(rhel5)

Comment 2 Michal Hlavinka 2012-03-01 09:15:10 UTC
I talked with upstream and this is expected and documented behaviour:

$ man mksh

"""
Arithmetic expressions
...
 Expressions are calculated using signed arithmetic and the mksh_ari_t type (a 32-bit signed integer), unless they begin with a sole ‘#’ character, in which case they use mksh_uari_t (a 32-bit unsigned integer).
"""