Bug 1767

Summary: expr in busybox can't handle math with big numbers
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Gary Thomas <gary>
Component: coreAssignee: Andrei Gherzan <andrei>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Low CC: andrei, lauri.hintsala, meta.mr.watcher, meta.watcher, richard.purdie
Version: 1.1   
Target Milestone: 1.2 M2   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: ---

Description Gary Thomas 2011-11-16 03:24:54 UTC
Using the 'expr' program from busybox returns incorrect values:
  # ln -s /bin/busybox /tmp/expr
  # /tmp/expr 111517272011 - 111517292011                                                               
  0

Large numbers are supported:
  # /tmp/expr 111517272011
  111517272011

Math works, but only for smaller values:
  # /tmp/expr 65536 - 4
  65532

The 'expr' from coreutils works correctly
  # expr.coreutils 111517272011 - 111517292011
  -20000

I get the same results on ARM and PowerPC

Tested using master fa81f8dfb7a342e355b608aa4204cf23ed2b251c
Comment 1 Andrei Gherzan 2012-01-08 15:05:42 UTC
I compiled busybox on my machine and this bug is still present. So i think that this is a busybox bug and not a yocto one. You can test this by downloading source tar ball from upstream and:

~/Desktop/busybox-1.19.3 $ ./expr 111517272011 - 111517292011 
0
~/Desktop/busybox-1.19.3 $ ./expr 111517272011
111517272011
~/Desktop/busybox-1.19.3 $ ./expr 65536 - 4
65532
Comment 2 Andrei Gherzan 2012-01-08 15:58:38 UTC
(In reply to comment #1)
> I compiled busybox on my machine and this bug is still present. So i think that
> this is a busybox bug and not a yocto one. You can test this by downloading
> source tar ball from upstream and:
> 
> ~/Desktop/busybox-1.19.3 $ ./expr 111517272011 - 111517292011 
> 0
> ~/Desktop/busybox-1.19.3 $ ./expr 111517272011
> 111517272011
> ~/Desktop/busybox-1.19.3 $ ./expr 65536 - 4
> 65532

So the problem was around a busybox config. I will commit this change in order to fix this bug.

Edwin, you can assign this bug to me if you didn't already fix this.
Comment 5 Lauri Hintsala 2012-01-13 01:53:47 UTC
(In reply to comment #4)
> Fix:
> http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=91367de75575e79a94b2f90b6b7aa8740a039fc5

Sorry. My fix was for yocto time set issue, which was caused by this bug. You can forget my comment.