-
Notifications
You must be signed in to change notification settings - Fork 1.4k
syz-cluster: use base-commit hint from patch series for triage #6557
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,12 +25,13 @@ type Thread struct { | |
|
|
||
| // Series represents a single patch series sent over email. | ||
| type Series struct { | ||
| Subject string | ||
| MessageID string | ||
| Version int | ||
| Corrupted string // If non-empty, contains a reason why the series better be ignored. | ||
| Tags []string | ||
| Patches []Patch | ||
| Subject string | ||
| MessageID string | ||
| Version int | ||
| Corrupted string // If non-empty, contains a reason why the series better be ignored. | ||
| Tags []string | ||
| Patches []Patch | ||
| BaseCommitHint string | ||
| } | ||
|
|
||
| type Patch struct { | ||
|
|
@@ -88,6 +89,13 @@ func PatchSeries(emails []*Email) []*Series { | |
| if !ok { | ||
| continue | ||
| } | ||
| if series.BaseCommitHint == "" { // Usually base-commit is in patch 0 or 1. Check them all to be safe. | ||
| regex := regexp.MustCompile(`(?m)^base-commit:\s*([0-9a-fA-F]{40})$`) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We shouldn't compile the regexp for each message. Ideally it should be done once outside of the function, see the majority of other
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd also move this extraction to |
||
| matches := regex.FindStringSubmatch(email.Body) | ||
| if len(matches) >= 2 { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can just check for
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wanted to avoid an unnecessary crash if the author wrote the tag and forgot the hash. But I just realized it wouldn't match in that case! Will update. |
||
| series.BaseCommitHint = matches[1] | ||
| } | ||
| } | ||
| seq := patch.Seq.ValueOr(1) | ||
| if seq == 0 { | ||
| // The cover email is not of interest. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -127,16 +127,17 @@ type NewFinding struct { | |
| } | ||
|
|
||
| type Series struct { | ||
| ID string `json:"id"` // Only included in the reply. | ||
| ExtID string `json:"ext_id"` | ||
| Title string `json:"title"` | ||
| AuthorEmail string `json:"author_email"` | ||
| Cc []string `json:"cc"` | ||
| Version int `json:"version"` | ||
| Link string `json:"link"` | ||
| SubjectTags []string `json:"subject_tags"` | ||
| PublishedAt time.Time `json:"published_at"` | ||
| Patches []SeriesPatch `json:"patches"` | ||
| ID string `json:"id"` // Only included in the reply. | ||
| ExtID string `json:"ext_id"` | ||
| Title string `json:"title"` | ||
| AuthorEmail string `json:"author_email"` | ||
| Cc []string `json:"cc"` | ||
| Version int `json:"version"` | ||
| Link string `json:"link"` | ||
| SubjectTags []string `json:"subject_tags"` | ||
| PublishedAt time.Time `json:"published_at"` | ||
| Patches []SeriesPatch `json:"patches"` | ||
| BaseCommitHint string `json:"base_commit"` | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: let's keep json name similar to the field name. |
||
| } | ||
|
|
||
| func (s *Series) PatchBodies() [][]byte { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ALTER TABLE Series DROP COLUMN BaseCommitHint; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ALTER TABLE Series ADD COLUMN BaseCommitHint STRING(256); |
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please rebase it on top of the current |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -113,6 +113,24 @@ func (triager *seriesTriager) GetVerdict(ctx context.Context, sessionID string) | |
| func (triager *seriesTriager) prepareFuzzingTask(ctx context.Context, series *api.Series, trees []*api.Tree, | ||
| target *triage.MergedFuzzConfig) (*api.FuzzTask, error) { | ||
| var skipErr error | ||
| selector := triage.NewCommitSelector(triager.ops, triager.DebugTracer) | ||
|
|
||
| // First try to use hints from the series description. | ||
| if series.BaseCommitHint != "" { | ||
| for _, tree := range trees { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that we should be able to determine the tree from the commit:
You can use #6553 as reference here. |
||
| triager.Log("considering tree %q with a hint", tree.Name) | ||
| result, err := selector.TrySelectWithHint(series) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to run TrySelectWithHint for %q: %w", tree.Name, err) | ||
| } | ||
| if result.Commit != "" { | ||
| triager.Log("selected base commit with hint: %s", result.Commit) | ||
| return buildFuzzTask(series, tree, target, result.Commit), nil | ||
| } | ||
| triager.Log("failed to find a base commit with hint for %q: %s", tree.Name, result.Reason) | ||
| } | ||
| } | ||
|
|
||
| for _, tree := range trees { | ||
| triager.Log("considering tree %q", tree.Name) | ||
| arch := "amd64" | ||
|
|
@@ -127,7 +145,6 @@ func (triager *seriesTriager) prepareFuzzingTask(ctx context.Context, series *ap | |
| return nil, fmt.Errorf("failed to query the last build for %q: %w", tree.Name, err) | ||
| } | ||
| triager.Log("%q's last build: %q", tree.Name, lastBuild) | ||
| selector := triage.NewCommitSelector(triager.ops, triager.DebugTracer) | ||
| result, err := selector.Select(series, tree, lastBuild) | ||
| if err != nil { | ||
| // TODO: the workflow step must be retried. | ||
|
|
@@ -141,24 +158,29 @@ func (triager *seriesTriager) prepareFuzzingTask(ctx context.Context, series *ap | |
| continue | ||
| } | ||
| triager.Log("selected base commit: %s", result.Commit) | ||
| base := api.BuildRequest{ | ||
| TreeName: tree.Name, | ||
| TreeURL: tree.URL, | ||
| ConfigName: target.KernelConfig, | ||
| CommitHash: result.Commit, | ||
| Arch: arch, | ||
| } | ||
| fuzz := &api.FuzzTask{ | ||
| Base: base, | ||
| Patched: base, | ||
| FuzzConfig: *target.FuzzConfig, | ||
| } | ||
| fuzz.Patched.SeriesID = series.ID | ||
| return fuzz, nil | ||
| return buildFuzzTask(series, tree, target, result.Commit), nil | ||
| } | ||
| return nil, skipErr | ||
| } | ||
|
|
||
| func buildFuzzTask(series *api.Series, tree *api.Tree, target *triage.MergedFuzzConfig, commit string) *api.FuzzTask { | ||
| arch := "amd64" | ||
| base := api.BuildRequest{ | ||
| TreeName: tree.Name, | ||
| TreeURL: tree.URL, | ||
| ConfigName: target.KernelConfig, | ||
| CommitHash: commit, | ||
| Arch: arch, | ||
| } | ||
| fuzz := &api.FuzzTask{ | ||
| Base: base, | ||
| Patched: base, | ||
| FuzzConfig: *target.FuzzConfig, | ||
| } | ||
| fuzz.Patched.SeriesID = series.ID | ||
| return fuzz | ||
| } | ||
|
|
||
| type SkipTriageError struct { | ||
| Reason error | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be tested.