Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: excessive instrumentation for libFuzzer #53760

Open
randall77 opened this issue Jul 8, 2022 · 2 comments · May be fixed by #53786
Open

cmd/compile: excessive instrumentation for libFuzzer #53760

randall77 opened this issue Jul 8, 2022 · 2 comments · May be fixed by #53786
Labels
compiler/runtime fuzz NeedsInvestigation Performance
Milestone

Comments

@randall77
Copy link
Contributor

@randall77 randall77 commented Jul 8, 2022

func f() {
}

When compiled with

go tool compile -d=libfuzzer -S f.go

We get a call to runtime.libfuzzerTraceConstCmp1, which seems unnecessary.

This happens because we add (in the order pass):

if counter == 255 {
    counter = 1
} else {
    counter += 1
}

But then we add instrumentation to all integer comparisons (in the walk pass):

runtime.libfuzzerTraceConstCmp1(counter, 255)

I don't think we need to rewrite the internal libfuzzer counter overflow check to use the runtime comparison function. Only user comparisons should be so treated. I guess it technically doesn't hurt, but it will be slow.

@kyakdan

@randall77 randall77 added Performance fuzz labels Jul 8, 2022
@randall77 randall77 added this to the Go1.20 milestone Jul 8, 2022
@mknyszek mknyszek added the NeedsInvestigation label Jul 11, 2022
kyakdan added a commit to CodeIntelligenceTesting/go that referenced this issue Jul 11, 2022
Do not intercept integer compares that are used to increment libFuzzer's
8-bit counters. This is unnecessary and has a negative impact on the
fuzzing performance. This fixes golang#53760.
@gopherbot
Copy link

@gopherbot gopherbot commented Jul 11, 2022

Change https://go.dev/cl/416796 mentions this issue: cmd/compile: avoid excessive libfuzzer instrumentation of int compares

@kyakdan
Copy link
Contributor

@kyakdan kyakdan commented Jul 11, 2022

@randall77 Great catch! I've pushed a fix that avoids intercepting integer compares of libFuzzer's 8-bit counters.

@gopherbot gopherbot added the compiler/runtime label Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime fuzz NeedsInvestigation Performance
Projects
Status: Triage Backlog
Development

Successfully merging a pull request may close this issue.

4 participants