Skip to content

Malformed generic method comment freezes analyzer #25739

Closed
@munificent

Description

@munificent

Analyze this (incorrect) program with --strong:

void method(dynamic/*=T extends Uri*/ t) {}

Observe that the analyzer freezes until it eventually runs out of memory and crashes. Be sad.

I looked into it a little bit. When the generic method comment is inserted into the token stream, the original comment remains. So the first time the comment is handled, you end up with something like:

void method(dynamic T extends Uri /*=T extends Uri*/ t) {}

Then it fails to parse the extends.... At some point, it ends up retrying and hits the comment again:

void method(dynamic T extends Uri T extends Uri /*=T extends Uri*/ t) {}

Or something along those lines. I'm not sure why it keeps hitting the same code path again and again, but the result is an infinite expansion in the token stream.

cc @vsmenon @jmesserly @leafpetersen @bwilkerson

Metadata

Metadata

Assignees

Labels

P1A high priority bug; for example, a single project is unusable or has many test failureslegacy-area-analyzerUse area-devexp instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions