AdguardTeam / AdGuardHome

Network-wide ads & trackers blocking DNS server
https://adguard.com/adguard-home/overview.html
GNU General Public License v3.0
25.63k stars 1.84k forks source link

`panic: close of closed channel` when cleanup #7401

Open azureqaq opened 2 weeks ago

azureqaq commented 2 weeks ago

Prerequisites

Platform (OS and CPU architecture)

FreeBSD, AMD64 (aka x86_64)

Installation

GitHub releases or script from README

Setup

Other (please mention in the description)

AdGuard Home version

AdGuard Home, version v0.107.53

Action

  1. Install AdguardHome via script from README.
  2. Just RUN.
  3. AdguardHome works well.
  4. Press Crtl+C, get a stopped info, but freeze.
  5. Press Ctrl+C again, get a panic.
    
    xigmanas: AdGuardHome# ls
    AdGuardHome      AdGuardHome.yaml data             README.md
    AdGuardHome.sig  CHANGELOG.md     LICENSE.txt

xigmanas: AdGuardHome# ./AdGuardHome 2024/11/03 13:16:48.668458 [info] AdGuard Home, version v0.107.53 2024/11/03 13:16:48.669733 [info] tls: using default ciphers 2024/11/03 13:16:48.672171 [info] safesearch default: disabled 2024/11/03 13:16:49.282924 [info] Initializing auth module: /mnt/pool/downloads/opt/AdGuardHome/data/sessions.db ^C2024/11/03 13:16:51.625911 [info] Received signal "interrupt" 2024/11/03 13:16:51.625926 [info] stopping AdGuard Home 2024/11/03 13:16:51.625968 [info] stopped ^C2024/11/03 13:16:54.688728 [info] Received signal "interrupt" 2024/11/03 13:16:54.688749 [info] stopping AdGuard Home panic: close of closed channel

goroutine 33 [running]: github.com/AdguardTeam/AdGuardHome/internal/aghnet.(*HostsContainer).Close(0x86c31e000) github.com/AdguardTeam/AdGuardHome/internal/aghnet/hostscontainer.go:108 +0x128 github.com/AdguardTeam/AdGuardHome/internal/home.cleanup({0x1a5c010?, 0x26586e0?}) github.com/AdguardTeam/AdGuardHome/internal/home/home.go:862 +0x1bc github.com/AdguardTeam/AdGuardHome/internal/home.Main.func1() github.com/AdguardTeam/AdGuardHome/internal/home/home.go:126 +0x112 created by github.com/AdguardTeam/AdGuardHome/internal/home.Main in goroutine 1 github.com/AdguardTeam/AdGuardHome/internal/home/home.go:117 +0x298 xigmanas: AdGuardHome#

6. Run *AdguardHome* as service.
```sh
xigmanas: AdGuardHome# ./AdGuardHome -s start
2024/11/03 13:22:57 [info] AdGuard Home, version v0.107.53
2024/11/03 13:22:57 [info] service: control action: start
2024/11/03 13:22:57 [fatal] service: executing action "start": Failed to start AdGuard Home service: exit status 1

Expected result

no panic

Actual result

panic

Additional information and/or screenshots

Previously, running it as a service worked fine, but recently, after a power outage, I tried to manually restart AdguardHome and encountered these issues. Of course, it could be due to my lack of familiarity with FreeBSD, but the panic is undoubtedly a BUG.