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

Avoid copying a lock by value, which is invalid. #59

Merged
merged 2 commits into from
Feb 27, 2020
Merged

Avoid copying a lock by value, which is invalid. #59

merged 2 commits into from
Feb 27, 2020

Conversation

flimzy
Copy link
Contributor

@flimzy flimzy commented Dec 8, 2019

It is not valid to copy a sync.Mutex value. From the docs:

A Mutex must not be copied after first use.

Doing so can lead to undefined results.

This PR fixes that, by passing a pointer to the value, rather than dereferencing the value before passing it.

@sonatypecla
Copy link

sonatypecla bot commented Dec 8, 2019

Thanks for the contribution! Before we can merge this, we need @flimzy to sign the Sonatype Contributor License Agreement.

Copy link
Contributor

@zendern zendern left a comment

Choose a reason for hiding this comment

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

👍 Thanks for the contribution looks good to me. @DarthHater @bhamail any thoughts??

@flimzy
Copy link
Contributor Author

flimzy commented Dec 9, 2019

Incidentally, I discovered this while debugging #58, thanks to running golangci-lint in my editor. I notice there are several other linter failures in this repo, some of which may represent real bugs. If you'd find it valuable, I'd be happy to submit fixes for all of them. It might be worth adding golangci-lint to your Travis-CI script as well.

@fitzoh
Copy link
Contributor

fitzoh commented Dec 9, 2019

looks like go vet catches it as well:

$ go vet
# github.com/sonatype-nexus-community/nancy
./main.go:102:56: call of packages.ExtractPurlsUsingDep copies lock value: github.com/golang/dep.Project contains sync.Once contains sync.Mutex

@flimzy
Copy link
Contributor Author

flimzy commented Dec 9, 2019

looks like go vet catches it as well:

golangci-lint calls go vet (and many other linters), so that's probably what I was running, too :)

@zendern
Copy link
Contributor

zendern commented Dec 9, 2019

Well we are doing neither in CI and probably makes sense to do something there.

@flimzy what if we open an issue, get a little feedback and see about adding at least go vet if not golangci-lint to the project.

@flimzy are you just running the default setup for golangci-lint or do you have other linters/checks enabled??

^^^I think the biggest thing with introducing that one is we just have to come to a little agreement what we do and don't want enabled. And really once we do it here it's probably going to get copied to other golang projects here like ahab.

@flimzy
Copy link
Contributor Author

flimzy commented Dec 9, 2019

@flimzy what if we open an issue, get a little feedback and see about adding at least go vet if not golangci-lint to the project.

Makes sense to discuss in an issue, rather than here :)

@flimzy are you just running the default setup for golangci-lint or do you have other linters/checks enabled??

I was using the default configuration. Although in most projects, I do use a custom config to enable a few non-default linters.

@DarthHater
Copy link
Member

@zendern @flimzy this is technically an API change (although I doubt it's going to really hurt anyone), should we bump to 0.1.0 for Nancy?

@zendern
Copy link
Contributor

zendern commented Dec 11, 2019

@zendern @flimzy this is technically an API change (although I doubt it's going to really hurt anyone), should we bump to 0.1.0 for Nancy?

Yeah i think that is reasonable to do.

@DarthHater
Copy link
Member

I'll try and get this merged tomorrow, I think it'll be Nancy 0.1.0 FTR! cc @zendern @flimzy

zendern added a commit to zendern/nancy that referenced this pull request Jan 21, 2020
We already fixed the 3 outstanding issues in sonatype-nexus-community#59 so once we merge that
we can rebase this and get those all fixed up
This was referenced Jan 21, 2020
@cah-nathan-zender cah-nathan-zender mentioned this pull request Feb 26, 2020
@DarthHater DarthHater merged commit 225700a into sonatype-nexus-community:master Feb 27, 2020
zendern added a commit to zendern/nancy that referenced this pull request Mar 1, 2020
We already fixed the 3 outstanding issues in sonatype-nexus-community#59 so once we merge that
we can rebase this and get those all fixed up
zendern added a commit to zendern/nancy that referenced this pull request Mar 1, 2020
We already fixed the 3 outstanding issues in sonatype-nexus-community#59 so once we merge that
we can rebase this and get those all fixed up
zendern added a commit to zendern/nancy that referenced this pull request Mar 21, 2020
We already fixed the 3 outstanding issues in sonatype-nexus-community#59 so once we merge that
we can rebase this and get those all fixed up
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants