Skip to content

Allow skipping minimization when transition count > MAX_INT (was "NegativeArraySizeException in ValmariDFA") #1

Description

@pierreganty

Dear devs,

I was running Walnut with the following pc6 predicate and it crashed close to completion.
To reproduce you need time (i.e. couple of hours) and a lot of memory (I ran Walnut with -Xmx128G).

eval pc6 "?lsd_2 (0 <= v0 & 0 <= v1 & 0 <= v2 & 0 <= v3 & 0 <= v4 & 0 <= v5 & 2 * v1 + 2 * v2 + 2 * v3 + 2 * v4 + 2 * v5 <= 40 * v0 & 3 * v0 + 3 * v2 + 3 * v3 + 3 * v4 + 3 * v5 <= 39 * v1 & 5 * v0 + 5 * v1 + 5 * v3 + 5 * v4 + 5 * v5 <= 37 * v2 & 7 * v0 + 7 * v1 + 7 * v2 + 7 * v4 + 7 * v5 <= 35 * v3 & 11 * v0 + 11 * v1 + 11 * v2 + 11 * v3 + 11 * v5 <= 31 * v4 & 13 * v0 + 13 * v1 + 13 * v2 + 13 * v3 + 13 * v4 <= 29 * v5 & 1 <= v0 + v1 + v2 + v3 + v4 + v5)" ::

Walnut reached a stage where it completes an &-product thereby generating an automaton with a bit more than 58 millions states.
Then Walnut runs the minimization procedure for that large automaton, where it crashes almost immediately.
I suspect there is an integer overflow when computing the number of transitions in ValmariDFA.java:

             // Pre-size the arrays.
        for(int q = 0; q != dfaD.size();++q){
            numTransitions += dfaD.get(q).keySet().size();
        }

After the loop numTransitions contains a negative value, hence the exception when declaring T right after.

Below I pasted the output of the crash I obtained:

                        Minimizing: 58138358 states.
java.lang.NegativeArraySizeException: -574112384
        at Automata.FA.ValmariDFA.<init>(ValmariDFA.java:51)
        at Automata.FA.FA.justMinimize(FA.java:877)
        at Automata.FA.ProductStrategies.crossProductAndMinimize(ProductStrategies.java:211)
        at Automata.AutomatonLogicalOps.and(AutomatonLogicalOps.java:55)
        at Token.LogicalOperator.act(LogicalOperator.java:74)
        at Main.Computer.compute(Computer.java:77)
        at Main.Computer.<init>(Computer.java:49)
        at Main.Prover.eval_def_commands(Prover.java:584)
        at Main.Prover.processCommand(Prover.java:457)
        at Main.Prover.dispatch(Prover.java:391)
        at Main.Prover.readBuffer(Prover.java:314)
        at Main.Prover.run(Prover.java:280)
        at Main.Prover.main(Prover.java:261)
java.lang.RuntimeException: -574112384
        : char at 351
        at Main.Computer.compute(Computer.java:95)
        at Main.Computer.<init>(Computer.java:49)
        at Main.Prover.eval_def_commands(Prover.java:584)
        at Main.Prover.processCommand(Prover.java:457)
        at Main.Prover.dispatch(Prover.java:391)
        at Main.Prover.readBuffer(Prover.java:314)
        at Main.Prover.run(Prover.java:280)
        at Main.Prover.main(Prover.java:261)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions