fix: data race in remove accents #80
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix_data_race"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR fixes a data race associated with reuse of
removeAccentsTransformer- when IsProfane() or other methods are called from multiple goroutines (ex. in a HTTP Server handler), sanitization fails withslice bounds out of rangeerrors.The issue is fixed by using a new instance of
removeAccentsTransformerfor every call toremoveAccents.To reproduce, run the newly added
BenchmarkIsProfaneConcurrently_WithAccentswith(note - it will pass on the last commit of this branch that contains a fix).
Summary
Fix a data race in
removeAccents, makingProfanityDetectorsafe for use from multiple goroutines.Checklist
README.md, if applicable.Codecov Report
All modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.
@rafax Thank you for the contribution!