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

lib/regexutil: vendor syntax standard lib in Go 1.23 as a workaround #6934

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

func25
Copy link
Contributor

@func25 func25 commented Sep 4, 2024

Describe Your Changes

Fix #6911

While waiting for the changes to be updated in Go's mainstream, I vendored the syntax package in Go 1.23, changed the call to the local syntax package, and the only modification to the vendored syntax package is the new calcFlagsI() function.

  • Old version
case OpCharClass:
	// If literal is fold-sensitive, return 0, flagI - (?i) has been compiled out.
	// If literal is not fold-sensitive, return 0, 0.
	for i := 0; i < len(re.Rune); i += 2 {
		lo := max(minFold, re.Rune[i])
		hi := min(maxFold, re.Rune[i+1])
		for r := lo; r <= hi; r++ {
			for f := unicode.SimpleFold(r); f != r; f = unicode.SimpleFold(f) {
				if !(lo <= f && f <= hi) && !inCharClass(f, re.Rune) {
					return 0, flagI
				}
			}
		}
	}
	return 0, 0

New version:

func calcFlagsI(re *Regexp) (must, cant printFlags) { ... }

@func25 func25 changed the title vendor syntax standard lib in Go 1.23 as a workaround lib/regexutil: vendor syntax standard lib in Go 1.23 as a workaround Sep 4, 2024
@func25 func25 self-assigned this Sep 4, 2024
@func25 func25 requested a review from valyala September 5, 2024 01:30
@func25 func25 marked this pull request as ready for review September 5, 2024 01:30
Copy link
Collaborator

@valyala valyala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approach with vendoring of regexp/syntax package with the bugfix looks interesting as a temporary workaround for the issue in this package!

lib/regexutil/syntax/compile.go Show resolved Hide resolved
@valyala
Copy link
Collaborator

valyala commented Sep 5, 2024

Please refer the created issue at Go repository here.

@func25
Copy link
Contributor Author

func25 commented Sep 6, 2024

Go issue: #69303
Go CL: #611300

@hagen1778
Copy link
Collaborator

Let's put this PR on-hold. The change seems too intrusive, while the effect of the mentioned bug seems pretty low. Probably, we should wait for this to be fixed on Go side and the use newer Go version instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Possible regression when using metric_relabel_configs in versions > victoriametrics/vmagent:v1.99.0
3 participants