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

Creating new files is not multi-goroutine safe #40

Open
sfc-gh-thardie opened this issue Dec 11, 2023 · 1 comment
Open

Creating new files is not multi-goroutine safe #40

sfc-gh-thardie opened this issue Dec 11, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@sfc-gh-thardie
Copy link
Contributor

If you call New() on the storage objects from multiple goroutines at the same time, go runtime may error with fatal error: concurrent map writes. This happens because the files map inside the storage struct has no concurrency protection around multiple access.

Other concurrency issues probably exist for accessing the children map inside the storage object.

@pjbgf
Copy link
Member

pjbgf commented Dec 11, 2023

@sfc-gh-thardie Yep, this is an issue that unfortunately ends up affecting go-git as well. I would support a new implementation keeping the current as-is. Then offer users a way to opt into the safer approach.

From an API perspective, we could do something similar to the approach on the recent osfs changes, in which we introduced sub-types with options. Is this something you would be keen to implement?

@pjbgf pjbgf added the enhancement New feature or request label Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants