Bug 235320 - usr.bin/units: What does this error message really mean: units: memory overflow in unit reduction
Summary: usr.bin/units: What does this error message really mean: units: memory overfl...
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 11.2-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-30 13:41 UTC by Mateusz Piotrowski
Modified: 2019-01-30 13:41 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mateusz Piotrowski freebsd_committer 2019-01-30 13:41:59 UTC
I use the following one-liner to test:

> sh -c 'units "$(yes m | head -n "$1")" "$(yes cm | head -n "$1")"' sh $N

When N is at most 154 then units(1) handles the conversion as expected. For example, for N=154:

>         * 1e+308
>         / 1e-308

For N from 155 to 333 the output is as follows:

>         * inf
>         / 0

While for N from 334 to 500 the output seems a little bit broken. Here is the output of N=500:

> units: memory overflow in unit reduction
> conformability error
>         1 m^334
>         0 centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi m centi cm m^166

For N >= 501 the output is:

> units: memory overflow in unit reduction
> units: memory overflow in unit reduction
> units: memory overflow in unit reduction
> conformability error
>         1 m^500
>         1 centi cm^499

I'd like to document this behavior but I am not sure what really is expected to happen in those edge cases.