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

fix: divide by zero fatal crash for reprovide rate check #10411

Merged
merged 2 commits into from May 6, 2024

Conversation

dbeal-eth
Copy link
Contributor

@dbeal-eth dbeal-eth commented Apr 25, 2024

While I was running kubo on my instance, I was encountering somewhat frequent crashes of the process with the following stack trace:

2024-04-25 20:41:17.361	
2024-04-25T11:41:17.331332+00:00 cannon-repo-snap-154780564-4013d1 systemd[1]: ipfs.service: Consumed 5min 27.300s CPU time.
2024-04-25 20:41:17.361	
2024-04-25T11:41:17.331245+00:00 cannon-repo-snap-154780564-4013d1 systemd[1]: ipfs.service: Failed with result 'exit-code'.
2024-04-25 20:41:17.361	
2024-04-25T11:41:17.330698+00:00 cannon-repo-snap-154780564-4013d1 systemd[1]: ipfs.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
2024-04-25 20:41:17.361	
2024-04-25T11:41:17.296960+00:00 cannon-repo-snap-154780564-4013d1 ipfs[23032]: #011github.com/ipfs/boxo@v0.13.1/provider/reprovider.go:227 +0x88
2024-04-25 20:41:17.361	
2024-04-25T11:41:17.296912+00:00 cannon-repo-snap-154780564-4013d1 ipfs[23032]: created by github.com/ipfs/boxo/provider.(*reprovider).run in goroutine 1
2024-04-25 20:41:17.361	
repo-sgp1                |                         | 2024-04-25T11:41:17.296775+00:00 cannon-repo-snap-154780564-4013d1 ipfs[23032]: #011github.com/ipfs/boxo@v0.13.1/provider/reprovider.go:373 +0x9f3

2024-04-25 20:41:17.361	
2024-04-25T11:41:17.296775+00:00 cannon-repo-snap-154780564-4013d1 ipfs[23032]: #011github.com/ipfs/boxo@v0.13.1/provider/reprovider.go:373 +0x9f3

2024-04-25 20:41:17.361	
2024-04-25T11:41:17.296741+00:00 cannon-repo-snap-154780564-4013d1 ipfs[23032]: github.com/ipfs/boxo/provider.(*reprovider).run.func1()
2024-04-25 20:41:17.361	
2024-04-25T11:41:17.296704+00:00 cannon-repo-snap-154780564-4013d1 ipfs[23032]: #011github.com/ipfs/kubo@v0.23.0/core/node/provider.go:86 +0x535
2024-04-25 20:41:17.361	
2024-04-25T11:41:17.296656+00:00 cannon-repo-snap-154780564-4013d1 ipfs[23032]: github.com/ipfs/kubo/core/node.ProviderSys.func1.1(0x0?, 0x0?, 0x80, 0x0?)
2024-04-25 20:41:17.361	
2024-04-25T11:41:17.296583+00:00 cannon-repo-snap-154780564-4013d1 ipfs[23032]: goroutine 677 [running]:
2024-04-25 20:41:17.361	
2024-04-25T11:41:17.295863+00:00 cannon-repo-snap-154780564-4013d1 ipfs[23032]: panic: runtime error: integer divide by zero

I followed the stack trace to find the area where divide by 0 occurs. The solution seemed simple enough, so I went ahead and opened this PR with a simple change. I'm guessing that having a 0 count for reprovide is pretty bad, but will deal with that separately.

BTW I am not a go dev. My apologies if my solution seems too simplistic or a better way exists.

BTW it wasnt clear to me how/where I should update the changelog for this minor change. Please lmk. Thanks!

@dbeal-eth dbeal-eth requested a review from a team as a code owner April 25, 2024 12:04
@dbeal-eth
Copy link
Contributor Author

@hacdias would be super happy if you or someone on your team could take a look at this soon, thanks!

@hacdias hacdias added the skip/changelog This change does NOT require a changelog entry label May 6, 2024
Copy link
Member

@hacdias hacdias left a comment

Choose a reason for hiding this comment

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

I think this is a reasonable change. I see why count could be 0, so it makes sense to me. I don't think a changelog entry is necessary for such fix.

@hacdias hacdias enabled auto-merge May 6, 2024 07:11
@hacdias hacdias merged commit 65ff619 into ipfs:master May 6, 2024
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip/changelog This change does NOT require a changelog entry
Projects
Status: 🎉 Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants