Skip to content

pow reverts with Panic(0x11) instead of a typed error for extreme exponents #276

Description

@thedavidmeister

testRoundTripFuzzPow failed on CI for #274 (run https://github.com/rainlanguage/rain.math.float/actions/runs/34196695194) with a Panic(0x11) from the first pow leg. It reproduces on main (b6eba33) with the counterexample, so it is independent of that PR.

Behaviour: LibDecimalFloat.pow(a, b, tables) reverts with a raw arithmetic overflow panic instead of one of the typed errors pow is designed to throw (ExponentOverflow / ExponentUnderflow / WithTargetExponentOverflow / MaximizeOverflow / MulDivOverflow / ZeroNegativePower / PowNegativeBase). The test's own contract is that a Panic is a failure, not a swallowed revert.

Repro (any LogTest subclass):

Float a = Float.wrap(0x5061727365206572726f7220286e656729000000000000000000000000000000);
// coefficient 10649868514120859750743193552471890618207833841010459988146104827904, exponent 1348563571
Float b = Float.wrap(0x00000003b58e88c75313ec9d329eaaa18fb92f75215b170fffffffffffffffff);
// coefficient -7839786668602559178668060348078522694548577690162289924414440996865, exponent 3
a.pow(b, logTables()); // reverts 0x4e487b71…11

log10(a) is about 1.35e9 and b about -7.8e69, so the intermediate b * log10(a) and the pow10 of it are far outside any representable exponent. Somewhere on that path a checked int operation overflows before the typed exponent checks run. Expected: ExponentUnderflow (or another typed error). Triage question: which operation, and whether the typed check should come first or the arithmetic should saturate.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    adversarialFound by adversarial testingauditbugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions