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

Revert "chore: Replace sync.Mutex with sync.Map" #1262

Merged
merged 1 commit into from
Dec 31, 2024

Conversation

fzipi
Copy link
Member

@fzipi fzipi commented Dec 30, 2024

Reverts #1197

@fzipi fzipi requested a review from a team as a code owner December 30, 2024 11:09
@fzipi
Copy link
Member Author

fzipi commented Dec 30, 2024

I'm getting index out of range now 🤔

❯ go test -bench=. ./internal/corazawaf
goos: darwin
goarch: amd64
pkg: github.com/corazawaf/coraza/v3/internal/corazawaf
cpu: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
BenchmarkAddTransformationUnique-16    	panic: runtime error: index out of range [72] with length 72

goroutine 398 [running]:
github.com/corazawaf/coraza/v3/internal/corazawaf.transformationID(0xc000305da8?, {0xc00020b290?, 0x2e?})
	/Users/fzipi/Workspace/OWASP/coraza/internal/corazawaf/rule.go:592 +0x22d
github.com/corazawaf/coraza/v3/internal/corazawaf.(*Rule).AddTransformation(0xc000305df8, {0xc00020b290?, 0x2e?}, 0x15ad7c4?)
	/Users/fzipi/Workspace/OWASP/coraza/internal/corazawaf/rule.go:611 +0xf9
github.com/corazawaf/coraza/v3/internal/corazawaf.BenchmarkAddTransformationUnique.func2(0xc00008a160)
	/Users/fzipi/Workspace/OWASP/coraza/internal/corazawaf/rule_test.go:396 +0x10a
testing.(*B).RunParallel.func1()
	/usr/local/Cellar/go/1.23.4/libexec/src/testing/benchmark.go:797 +0xb8
created by testing.(*B).RunParallel in goroutine 369
	/usr/local/Cellar/go/1.23.4/libexec/src/testing/benchmark.go:790 +0x116
panic: runtime error: index out of range [72] with length 72

goroutine 408 [running]:
github.com/corazawaf/coraza/v3/internal/corazawaf.transformationID(0xc000307da8?, {0xc000382ea0?, 0x2e?})
	/Users/fzipi/Workspace/OWASP/coraza/internal/corazawaf/rule.go:592 +0x22d
github.com/corazawaf/coraza/v3/internal/corazawaf.(*Rule).AddTransformation(0xc000307df8, {0xc000382ea0?, 0x2e?}, 0x15ad7c4?)
	/Users/fzipi/Workspace/OWASP/coraza/internal/corazawaf/rule.go:611 +0xf9
github.com/corazawaf/coraza/v3/internal/corazawaf.BenchmarkAddTransformationUnique.func2(0xc00021c000)
	/Users/fzipi/Workspace/OWASP/coraza/internal/corazawaf/rule_test.go:396 +0x10a
testing.(*B).RunParallel.func1()
	/usr/local/Cellar/go/1.23.4/libexec/src/testing/benchmark.go:797 +0xb8
created by testing.(*B).RunParallel in goroutine 369
	/usr/local/Cellar/go/1.23.4/libexec/src/testing/benchmark.go:790 +0x116
exit status 2
FAIL	github.com/corazawaf/coraza/v3/internal/corazawaf	0.727s
FAIL

@fzipi
Copy link
Member Author

fzipi commented Dec 30, 2024

@piyushroshan Do you know why this is happening? Or shall we revert?

@piyushroshan
Copy link
Contributor

Looking into it

Copy link

codecov bot commented Dec 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.69%. Comparing base (d5a0d6d) to head (a6b435f).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1262   +/-   ##
=======================================
  Coverage   81.69%   81.69%           
=======================================
  Files         169      169           
  Lines        9767     9770    +3     
=======================================
+ Hits         7979     7982    +3     
  Misses       1537     1537           
  Partials      251      251           
Flag Coverage Δ
coraza.rule.case_sensitive_args_keys 81.65% <100.00%> (+<0.01%) ⬆️
coraza.rule.multiphase_valuation 81.69% <100.00%> (+<0.01%) ⬆️
coraza.rule.no_regex_multiline 81.63% <100.00%> (+<0.01%) ⬆️
default 81.69% <100.00%> (+<0.01%) ⬆️
examples+ 16.54% <0.00%> (-0.01%) ⬇️
examples+coraza.rule.case_sensitive_args_keys 81.65% <100.00%> (+<0.01%) ⬆️
examples+coraza.rule.multiphase_valuation 81.53% <100.00%> (+<0.01%) ⬆️
examples+coraza.rule.no_regex_multiline 81.55% <100.00%> (+<0.01%) ⬆️
examples+memoize_builders 81.65% <100.00%> (+<0.01%) ⬆️
examples+no_fs_access 80.98% <100.00%> (+<0.01%) ⬆️
ftw 81.69% <100.00%> (+<0.01%) ⬆️
memoize_builders 81.79% <100.00%> (+<0.01%) ⬆️
no_fs_access 81.14% <100.00%> (+<0.01%) ⬆️
tinygo 81.66% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jcchavezs jcchavezs merged commit edad234 into main Dec 31, 2024
71 checks passed
@jcchavezs jcchavezs deleted the revert-1197-mutex_to_sync_map branch December 31, 2024 08:31
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.

3 participants