AdGuardHome icon indicating copy to clipboard operation
AdGuardHome copied to clipboard

Fix crash due to concurrent r&w

Open tomitheninja opened this issue 3 years ago • 2 comments

I use AdGuardHomeExporter, which fetches the latest metrics via https every 10 seconds. I noticed that AGH crashes frequently (four times today), due to a concurrent map iteration and map write. This happens when I try to fetch the metrics, while it is getting updated. I noticed the statsCtx has a mutex, that is not being used.

Fixes #4342 #4374

tomitheninja avatar Jun 02 '22 00:06 tomitheninja

Thanks for the contribution, but that will probably not be enough to truly fix the issue. For example, there may still be a race between that call of loadUnits and the one in GetTopClientsIP. Also, this looks like it could cause a deadlock in ongoing, which loadUnits calls.

I plan on fixing all these races as well as some other stats-related bugs in the next release, but feel free to investigate as well.

ainar-g avatar Jun 03 '22 11:06 ainar-g

@tomitheninja, we've improve the concurrency logic in the stats module as per 4293cf5945a9331fd8ce1eb33a88865c6b8713cc. The latest build in the edge channel already contains the fix. Could you please install it (or build AGH from master branch) and tell if the concurrency issues are still occuring?

EugeneOne1 avatar Aug 04 '22 16:08 EugeneOne1

We'll close this PR for now. Please feel free to file new issues or reopen this PR if you find other bugs.

ainar-g avatar Aug 25 '22 16:08 ainar-g