Skip to content

Cache file causes crashes when adding rulesets #1030

@kapsh

Description

@kapsh

Describe the bug
Enabled cache file causes crashes when trying to add rulesets.

To Reproduce
Steps to reproduce the behavior:

  1. On Rules tab add some ruleset and save.
    I used remote https://raw.githubusercontent.com/runetfreedom/russia-v2ray-rules-dat/release/sing-box/rule-set-geosite/geosite-category-ads-all.srs
  2. On Experimental tab enable cache file and save.
    Alternatively, enable cache and start adding rulesets, backtrace is similar.
  3. See error
./s-ui/sui
2026/02/24 18:17:39 s-ui 1.3.10
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x128 pc=0xdd212e]

goroutine 42 [running]:
internal/sync.(*Mutex).Lock(...)
        /opt/hostedtoolcache/go/1.25.7/x64/src/internal/sync/mutex.go:63
sync.(*Mutex).Lock(...)
        /opt/hostedtoolcache/go/1.25.7/x64/src/sync/mutex.go:46
github.com/sagernet/bbolt.(*DB).beginTx(0x0)
        /home/runner/go/pkg/mod/github.com/sagernet/bbolt@v0.0.0-20231014093535-ea5cb2fe9f0a/db.go:707 +0x2e
github.com/sagernet/bbolt.(*DB).Begin(0xc000451520?, 0x5?)
        /home/runner/go/pkg/mod/github.com/sagernet/bbolt@v0.0.0-20231014093535-ea5cb2fe9f0a/db.go:700 +0x25
github.com/sagernet/bbolt.(*DB).View(0xc000451598?, 0xc0000b9d68)
        /home/runner/go/pkg/mod/github.com/sagernet/bbolt@v0.0.0-20231014093535-ea5cb2fe9f0a/db.go:864 +0x30
github.com/sagernet/sing-box/experimental/cachefile.(*CacheFile).LoadRuleSet(0xc0005e8630, {0xc00061b5d0, 0x6})
        /home/runner/go/pkg/mod/github.com/sagernet/sing-box@v1.12.21/experimental/cachefile/cache.go:289 +0x85
github.com/sagernet/sing-box/route/rule.(*RemoteRuleSet).StartContext(0xc0001796c0, {0x30b3a20, 0xc0005d6b90}, 0xc0002255e0)
        /home/runner/go/pkg/mod/github.com/sagernet/sing-box@v1.12.21/route/rule/rule_set_remote.go:98 +0x21e
github.com/sagernet/sing-box/route.(*Router).Start.func1({0x30b3a20?, 0xc0005d6b90?})
        /home/runner/go/pkg/mod/github.com/sagernet/sing-box@v1.12.21/route/router.go:98 +0x49
github.com/sagernet/sing/common/task.(*Group).Run.func1()
        /home/runner/go/pkg/mod/github.com/sagernet/sing@v0.7.18/common/task/task.go:83 +0x107
created by github.com/sagernet/sing/common/task.(*Group).Run in goroutine 69
        /home/runner/go/pkg/mod/github.com/sagernet/sing@v0.7.18/common/task/task.go:67 +0x125

Expected behavior
Expected that cache file works: plain sing-box (same version as bundled 1.12.21) supports rulesets and cache at the same time (though only after restart).

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS] Linux amd64
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22] 1.3.10

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions