Skip to content

Random ArrayIndexOutOfBounds exceptions coming from ParserATNSimulator #804

@parrt

Description

@parrt

It looks like a transient problem, even in the environment where we saw the issue originally it hasn't been reproducible. Only happens in our automation environment (rehat 5.7 running on open stack running on I dunno what) and only occasionally.

It happens in here:

synchronized (from) {
    if ( from.edges==null ) { 
        from.edges = new DFAState[atn.maxTokenType+1+1];
    }   

    from.edges[t+1] = to; // connect
}   

so in some case atn.maxTokenType+1 > t must be true.

I checked and it looks like the field "edges" is always protected by its parent DFAState object except for in one suspicious place where it appears to be guarded by an instance of DFA in DFA.java's setPrecedenceDfa method. (all in 4.3)

It would seem on the face of it that you need to synchronize inside setPrecedenceDfa on the DFAState rather than the DFA (or perhaps in addition too?).

Maybe we should just add an assert there.

assert t +1 < from.edges.length : "array index out of bounds!, t = " + t + ", edges.length=" + from.edges.length;

And perhaps add something about which threads are active and their stacks if it fails?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions