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

Concurrency safety #160

Open
hiendaovinh opened this issue May 5, 2023 · 2 comments
Open

Concurrency safety #160

hiendaovinh opened this issue May 5, 2023 · 2 comments

Comments

@hiendaovinh
Copy link

Do you want to request a feature or report a bug?
BUG

What is the current behavior?
DATA RACE

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.
Running IsAllowed() in multiple goroutine results in WARNING: DATA RACE

Read at 0x00c000b4c6d0 by goroutine 174:
  github.com/ory/ladon.(*Ladon).matcher()
      /go/pkg/mod/github.com/ory/ladon@v1.2.0/ladon.go:36 +0x7d5
  github.com/ory/ladon.(*Ladon).DoPoliciesAllow()
      /go/pkg/mod/github.com/ory/ladon@v1.2.0/ladon.go:82 +0x85e
  github.com/ory/ladon.(*Ladon).IsAllowed()

Previous write at 0x00c000b4c6d0 by goroutine 176:
  github.com/ory/ladon.(*Ladon).matcher()
      /go/pkg/mod/github.com/ory/ladon@v1.2.0/ladon.go:37 +0x80c
  github.com/ory/ladon.(*Ladon).DoPoliciesAllow()
      /go/pkg/mod/github.com/ory/ladon@v1.2.0/ladon.go:82 +0x85e
  github.com/ory/ladon.(*Ladon).IsAllowed()

What is the expected behavior?
It's safe to run concurrently.

Which version of the software is affected?
ory/ladon@v1.2.0

@hiendaovinh
Copy link
Author

Guarding Ladon with a mutex lock could be a solution but it might affect the performance.

@aeneasr
Copy link
Member

aeneasr commented May 25, 2023

Nice find! A mutex sounds good

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

No branches or pull requests

2 participants