This is an archive of the discontinued LLVM Phabricator instance.

[Support/GlobPattern] - Treat multiple stars('*') as single.
AbandonedPublic

Authored by grimar on Aug 4 2017, 5:02 AM.

Details

Reviewers
ruiu
rafael
Summary

Found that when fuzzed LLD's linkerscripts.
Next one takes long time to run for me (several seconds), causing
fuzzer to treat test as 'hang':

SECTIONS {    .foo : { *(********************************************boo) }   }

That happens because complexity grows too fast when there are multiple
stars in pattern, though I believe we can just convert all ** to *`.

Testcase is provided. With patch it runs instantly, without - takes huge time,

Diff Detail

Event Timeline

grimar created this revision.Aug 4 2017, 5:02 AM
ruiu edited edge metadata.Aug 4 2017, 5:15 AM

You don't want to "fix" this because there are a lot of other pathetic patterns that can hangs up the matcher. There is no reason to handle this specially.

ruiu added a comment.Aug 4 2017, 8:42 PM

I mean, I believe you can still hang this up by passing the following inputs (or something like that, I didn't test this):

Pattern: a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*z
Input: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

This is a fundamental limitation of the current algorithm because it's based on backtracking, which is exponential in the worst case. There are better algorithms, but I don't think we need that complexity here. In this test case, you are intentionally trying to break the linker, and it breaks as you wish. You simply shouldn't do that. I don't think we need to "fix" this.

grimar abandoned this revision.Aug 7 2017, 3:30 AM
In D36307#832783, @ruiu wrote:

I mean, I believe you can still hang this up by passing the following inputs (or something like that, I didn't test this):

Pattern: a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*z
Input: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

This is a fundamental limitation of the current algorithm because it's based on backtracking, which is exponential in the worst case. There are better algorithms, but I don't think we need that complexity here. In this test case, you are intentionally trying to break the linker, and it breaks as you wish. You simply shouldn't do that. I don't think we need to "fix" this.

I see. Closing it. Thanks for looking at this one.