gRPC lite panics on double Close: "flow control update exceeds maximum window size"

Aperta
#4,725 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
77/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go
Ambito
networking

Direzione di ricerca

Start with transport/v2raygrpclite/conn.go at GunConn.Close, then inspect the Close method in the v2rayhttp HTTP/2 connection implementation mentioned in the report. Trace how repeated closes reach the HTTP/2 response body and add unread bytes to the flow control window. Done means closing each connection safely more than once and verifying the reproduction no longer panics.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Operating system

macOS

System version

macOS 26.7.3 (25G342)

Installation type

sing-box for macOS Graphical Client

If you are using a graphical client, please provide the version of the client.

1.14.4 (10), standalone

Version
sing-box version 1.14.4

Environment: go1.26.10 darwin/arm64

Tags: with_gvisor,with_quic,with_dhcp,with_wireguard,with_utls,with_acme,with_clash_api,with_tailscale,with_ccm,with_ocm,with_cloudfared,with_naive_outbound,with_usbip,with_openvpn,with_o penconnect,badlinkname,tfogo_checklinkname0

Revision: c005f35300ce76427dc285481ec5695f5b179cd2

CGO: enabled
Description

The system extension crashes every 6 to 16 hours with a VLESS outbound on the gRPC transport (lite). It panics when streams close with unread data.

connectionCopy closes a GunConn 2 or 3 times. Each GunConn.Close closes the x/net HTTP/2 response body, which is not safe to close twice (golang/go#58456). Every extra close adds the stream's unread bytes to the connection window again, until inflow.add panics above 2^31-1.

A sync.Once in GunConn.Close should fix it. v2rayhttp.HTTP2Conn.Close has the same code.

Reproduction

server.json:

{
  "inbounds": [
    {
      "type": "vless",
      "listen": "127.0.0.1",
      "listen_port": 39101,
      "users": [{ "uuid": "bf000d23-0752-40b4-affe-68f7707a9661" }],
      "transport": { "type": "grpc" }
    }
  ]
}

client.json:

{
  "inbounds": [{ "type": "mixed", "listen": "127.0.0.1", "listen_port": 39102 }],
  "outbounds": [
    {
      "type": "vless",
      "server": "127.0.0.1",
      "server_port": 39101,
      "uuid": "bf000d23-0752-40b4-affe-68f7707a9661",
      "transport": { "type": "grpc" }
    }
  ]
}
  1. mkdir www && python3 -c 'open("www/big.bin", "wb").truncate(512 << 20)' && python3 -m http.server 39103 --bind 127.0.0.1 --directory www

  2. sing-box run -c server.json

  3. sing-box run -c client.json

  4. Slow downloads, aborted after 1 second, 16 at a time:

    for i in $(seq 1 20); do
      for j in $(seq 1 16); do
        curl -s -o /dev/null --limit-rate 200k --max-time 1 \
          -x socks5h://127.0.0.1:39102 http://127.0.0.1:39103/big.bin &
      done
      wait
    done
    

With sing-box 1.14.4, the client panics with the same stack in round 9.

Logs
panic: flow control update exceeds maximum window size

goroutine 185343 [running]:
golang.org/x/net/http2.(*inflow).add(...)
    golang.org/x/[email protected]/http2/flow.go:42
golang.org/x/net/http2.transportResponseBody.Close({0x59c67e585d98?})
    golang.org/x/[email protected]/http2/transport.go:2238 +0x31c
github.com/sagernet/sing/common.Close({0x59c67e585e08?, 0x2, 0x59c67c53a4a0?})
    github.com/sagernet/[email protected]/common/cond.go:361 +0x178
github.com/sagernet/sing-box/transport/v2raygrpclite.(*GunConn).Close(0x59c67cfdc1c0)
    github.com/sagernet/sing-box/transport/v2raygrpclite/conn.go:157 +0x94
github.com/sagernet/sing/common.Close({0x59c67e585f48?, 0x2, 0x109c60c48?})
    github.com/sagernet/[email protected]/common/cond.go:361 +0x178
github.com/sagernet/sing-box/route.(*ConnectionManager).connectionCopy(0x59c67cbda410, {0x10e3cce18, 0x59c67ff263c0}, {0x10e3e1218, 0x59c67d583008}, {0x10e3e4bd0, 0x59c67cfdc310}, 0x0, 0x59c67c9ae2e0, 0x59c6817263c0)
    github.com/sagernet/sing-box/route/conn.go:313 +0x1dc
created by github.com/sagernet/sing-box/route.(*ConnectionManager).NewConnection in goroutine 185340
    github.com/sagernet/sing-box/route/conn.go:160 +0x528
Supporter
Integrity requirements
  • I confirm that I have read the documentation, understand the meaning of all the configuration items I wrote, and did not pile up seemingly useful options or default values.
  • I confirm that I have provided the server and client configuration files and process that can be reproduced locally, instead of a complicated client configuration file that has been stripped of sensitive data.
  • I confirm that I have provided the simplest configuration that can be used to reproduce the error I reported, instead of depending on remote servers, TUN, graphical interface clients, or other closed-source software.
  • I confirm that I have provided the complete configuration files and logs, rather than just providing parts I think are useful out of confidence in my own intelligence.
Lingua principale
Go
Stelle
40.4k
Fork
5k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

  • Include un Dockerfile o un file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di SagerNet/sing-box

Tutte le issue di SagerNet/sing-box

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.