v2ray / v2ray-core

A platform for building proxies to bypass network restrictions.
https://www.v2ray.com/
MIT License
45.28k stars 8.94k forks source link

panic: runtime error: slice bounds out of range #983

Closed sjx95 closed 6 years ago

sjx95 commented 6 years ago
  1. 可复现版本: v3.12,13和14可能也有这个问题。
    • 连续三日以上凌晨左右崩溃,但只有 v3.12 那次输出被重定向到了 nohup.log
    • docker 版本也出现了崩溃
    • Distribution: openSUSE Leap 42.2, with kernel 4.15.2
    • Memory 1GB - Swap 2GB
    • 正在尝试在 v3.14 上复现错误
  2. 配置方式:
    • inbound - VMess
    • outbound - freedom
    • routing - LAN to black hole
    • No Mux, no mKCP, no WS, no any other settings.
  3. 1 个用户, alterId = 100, level = 9 (但没有设置 Level 9) 内容
    • 用于将 DNS 请求转发至 UDP 8.8.8.8:53
  4. Crash Info
    • Nothing abnormal in error.log
    • Nothing abnormal in access.log
    • in nohup.log:
      
      V2Ray v3.12 (die Commanderin) 20180306
      An unified platform for anti-censorship.
      panic: runtime error: slice bounds out of range

goroutine 90998 [running]: v2ray.com/core/common/buf.(Buffer).Read(...) /v2ray/src/v2ray.com/core/common/buf/buffer.go:165 v2ray.com/core/common/buf.(MultiBuffer).Read(0xc42016ba40, 0xc420d7a004, 0x7fc, 0x7fc, 0x0, 0xc421080cf0, 0x410ad8) /v2ray/src/v2ray.com/core/common/buf/multi_buffer.go:86 +0x2d4 v2ray.com/core/common/buf.ReadFrom.func1(0xc420d7a004, 0x7fc, 0x7fc, 0x57220d, 0x9f7c60, 0xc42016ba60) /v2ray/src/v2ray.com/core/common/buf/io.go:31 +0x4d v2ray.com/core/common/buf.(Buffer).AppendSupplier(0xc422f02e40, 0xc42016ba60, 0xc42016ba60, 0xc421080d00) /v2ray/src/v2ray.com/core/common/buf/buffer.go:57 +0x68 v2ray.com/core/common/buf.(BufferedWriter).WriteMultiBuffer(0xc421129120, 0xc42003f490, 0x1, 0x2, 0x0, 0x0) /v2ray/src/v2ray.com/core/common/buf/writer.go:101 +0x11d v2ray.com/core/common/crypto.(AuthenticationWriter).writePacket(0xc422f02e80, 0x0, 0x0, 0x0, 0x0, 0x0) /v2ray/src/v2ray.com/core/common/crypto/auth.go:231 +0x1cc v2ray.com/core/common/crypto.(AuthenticationWriter).WriteMultiBuffer(0xc422f02e80, 0xc420f3dc00, 0x1, 0x80, 0x0, 0x0) /v2ray/src/v2ray.com/core/common/crypto/auth.go:239 +0x9b v2ray.com/core/proxy/vmess/inbound.transferResponse(0xb0d0a0, 0xc4211290a0, 0xc42017a360, 0xc420d88c30, 0xc42052af78, 0x7f2405c10718, 0xc4211d5b00, 0xb0cde0, 0xc421129120, 0x8ea196, ...) /v2ray/src/v2ray.com/core/proxy/vmess/inbound/inbound.go:191 +0x116 v2ray.com/core/proxy/vmess/inbound.(*Handler).Process.func2(0x0, 0x0) /v2ray/src/v2ray.com/core/proxy/vmess/inbound/inbound.go:293 +0x27a v2ray.com/core/common/signal.executeAndFulfill(0xc4201dc680, 0xc4211d5c80) /v2ray/src/v2ray.com/core/common/signal/exec.go:8 +0x27 created by v2ray.com/core/common/signal.ExecuteAsync /v2ray/src/v2ray.com/core/common/signal/exec.go:18 +0x67

sjx95 commented 6 years ago

经确认,V3.14也存在这一问题。

beyondkmp commented 6 years ago

具体配置能贴下不

sjx95 commented 6 years ago

Configure

Server Side:

Only using the 2nd vmess uuid.

{
    "log": {
        "access": "../log/v2ray/access.log",
        "error": "../log/v2ray/error.log",
        "loglevel": "debug"
    },
    "inbound": {
        "port": 5050,
        "protocol": "vmess",
        "settings": {
            "clients": [
                {
                    "id": "a-b-c-d-e",
                    "alterId": 64,
                    "email": "a@b.c"
                },
                {
                    "id": "a-b-c-d-e",
                    "alterId": 128,
                    "level": 9,
                    "email": ""
                },
                {
                    "id": "a-b-c-d-e",
                    "email": ""
                },
                {
                    "id": "a-b-c-d-e",
                    "email": ""
                },
                {
                    "id": "a-b-c-d-e",
                    "email": "unknown4"
                }
            ],
            "default": {
                "level": 1,
                "alterId": 64
            },
            "disableInsecureEncryption": true
        }
    },
    "outbound": {
        "protocol": "freedom",
        "settings": {}
    },
    "inboundDetour": [],
    "outboundDetour": [
        {
            "protocol": "blackhole",
            "settings": {},
            "tag": "blocked"
        }
    ],
    "routing": {
        "strategy": "rules",
        "settings": {
            "rules": [
                {
                    "type": "field",
                    "ip": [
                        "0.0.0.0/8",
                        "10.0.0.0/8",
                        "100.64.0.0/10",
                        "127.0.0.0/8",
                        "169.254.0.0/16",
                        "172.16.0.0/12",
                        "192.0.0.0/24",
                        "192.0.2.0/24",
                        "192.168.0.0/16",
                        "198.18.0.0/15",
                        "198.51.100.0/24",
                        "203.0.113.0/24",
                        "::1/128",
                        "fc00::/7",
                        "fe80::/10"
                    ],
                    "outboundTag": "blocked"
                }
            ]
        }
    }
}

Client Side

{
  "log": {
    "loglevel": "warning"
  },
  "inbound": {
    "port": 5353,
    "listen": "0.0.0.0",
    "protocol": "dokodemo-door",
    "settings": {
        "address": "8.8.8.8",
        "port": 53,
        "network": "tcp,udp",
        "timeout": 60,
        "userLevel": 9
    }
  },
  "outbound": {
    "protocol": "vmess",
    "settings": {
        "vnext": [
            {
                "address": "x.y.z",
                "port": 5050,
                "users": [
                    {
                        "id": "a-b-c-d-e",
                        "alterId": 128,
                        "security": "auto",
                        "level": 9
                    }
                ]
            }
        ]
    }
  }
}
sjx95 commented 6 years ago

There are many warnings in client's nohup.out like this:

2018/03/23 23:38:23 [Warning] [1313892744] App|Proxyman|Outbound: failed to process outbo
und traffic > Proxy|VMess|Outbound: failed to find an available destination > Retry: [dia
l tcp ${SERVER_IP}:5050: connect: connection refused] > Retry: all retry attempts failed

And at last, I got this on server's nohup.out:

V2Ray v3.14 (die Commanderin) 20180316
An unified platform for anti-censorship.
panic: runtime error: slice bounds out of range

goroutine 96180 [running]:
v2ray.com/core/common/buf.(*Buffer).Read(...)
        /v2ray/src/v2ray.com/core/common/buf/buffer.go:161
v2ray.com/core/common/buf.(*MultiBuffer).Read(0xc4212249a0, 0xc42055c004, 0x7fc, 0x7fc, 0x0, 0xc420d18cf0, 0x410ad8)
        /v2ray/src/v2ray.com/core/common/buf/multi_buffer.go:86 +0x2da
v2ray.com/core/common/buf.ReadFrom.func1(0xc42055c004, 0x7fc, 0x7fc, 0x5723ad, 0x9f7a80, 0xc4212249c0)
        /v2ray/src/v2ray.com/core/common/buf/io.go:31 +0x4d
v2ray.com/core/common/buf.(*Buffer).AppendSupplier(0xc421224440, 0xc4212249c0, 0xc4212249c0, 0xc420d18d00)
        /v2ray/src/v2ray.com/core/common/buf/buffer.go:53 +0x68
v2ray.com/core/common/buf.(*BufferedWriter).WriteMultiBuffer(0xc421224460, 0xc42006d680, 0x1, 0x2, 0x0, 0x0)
        /v2ray/src/v2ray.com/core/common/buf/writer.go:101 +0x11d
v2ray.com/core/common/crypto.(*AuthenticationWriter).writePacket(0xc42006fa40, 0x0, 0x0, 0x0, 0x0, 0x0)
        /v2ray/src/v2ray.com/core/common/crypto/auth.go:226 +0x1cc
v2ray.com/core/common/crypto.(*AuthenticationWriter).WriteMultiBuffer(0xc42006fa40, 0xc4217dbc00, 0x1, 0x80, 0x0, 0x0)
        /v2ray/src/v2ray.com/core/common/crypto/auth.go:234 +0x9b
v2ray.com/core/proxy/vmess/inbound.transferResponse(0xb0cf40, 0xc4212243e0, 0xc4217efcb0, 0xc420eb1710, 0xc421c69778, 0x7f32e1698d98, 0xc4218c3da0, 0xb0cc80, 0xc421224460, 0x1, ...)
        /v2ray/src/v2ray.com/core/proxy/vmess/inbound/inbound.go:191 +0x116
v2ray.com/core/proxy/vmess/inbound.(*Handler).Process.func2(0x0, 0x0)
        /v2ray/src/v2ray.com/core/proxy/vmess/inbound/inbound.go:293 +0x27a
v2ray.com/core/common/signal.executeAndFulfill(0xc4210ded00, 0xc4218c3ec0)
        /v2ray/src/v2ray.com/core/common/signal/exec.go:8 +0x27
created by v2ray.com/core/common/signal.ExecuteAsync
        /v2ray/src/v2ray.com/core/common/signal/exec.go:18 +0x67
beyondkmp commented 6 years ago

复现很容易吗?还要在等好久?

sjx95 commented 6 years ago

需要大概12个小时,在我的应用场景下。

DarienRaymond commented 6 years ago

修了一个问题,但没有十足的把握和这个issue相关。 fa63beceb6863c7fedc88525910ebc90a2a6442d

如果明天没有更多的发现的话,会先发了个release出来看看。

sjx95 commented 6 years ago

Thanks. I saw the docker image v2ray/dev updated, I'll test it.

BTW isn't the docker file so weired? Too many fs layers were built. https://hub.docker.com/r/v2ray/dev/~/dockerfile/

FROM golang:latest

MAINTAINER admin@v2ray.com

RUN mkdir /usr/bin/v2ray/
RUN mkdir /etc/v2ray/
RUN mkdir /var/log/v2ray/
RUN go get -u v2ray.com/core/...
RUN go get -u v2ray.com/ext/...
RUN go install v2ray.com/ext/tools/build/vbuild
RUN vbuild -dir /usr/bin/v2ray

ENV PATH /usr/bin/v2ray/:$PATH

EXPOSE 8000
COPY config.json /etc/v2ray/config.json

CMD ["v2ray", "-config=/etc/v2ray/config.json"]
sjx95 commented 6 years ago

This still crashed when using latest v2ray/dev docker image, and v3.14 as client.

Here is the log:

sakura:~ # docker logs v2ray_dev
V2Ray 3.15 (die Commanderin) Custom
An unified platform for anti-censorship.
panic: runtime error: slice bounds out of range

goroutine 25853 [running]:
v2ray.com/core/common/buf.(*Buffer).Read(...)
        /go/src/v2ray.com/core/common/buf/buffer.go:161
v2ray.com/core/common/buf.(*MultiBuffer).Read(0xc420584a60, 0xc421841004, 0x7fc, 0x7fc, 0x0, 0xc420d8cd08, 0x410ad8)
        /go/src/v2ray.com/core/common/buf/multi_buffer.go:86 +0x2da
v2ray.com/core/common/buf.ReadFrom.func1(0xc421841004, 0x7fc, 0x7fc, 0x5723ad, 0x9f8b00, 0xc420584a80)
        /go/src/v2ray.com/core/common/buf/io.go:31 +0x4d
v2ray.com/core/common/buf.(*Buffer).AppendSupplier(0xc42064c5a0, 0xc420584a80, 0xc420584a80, 0xc420d8cd00)
        /go/src/v2ray.com/core/common/buf/buffer.go:53 +0x68
v2ray.com/core/common/buf.(*BufferedWriter).WriteMultiBuffer(0xc42064c620, 0xc420242220, 0x1, 0x2, 0x0, 0x0)
        /go/src/v2ray.com/core/common/buf/writer.go:101 +0x11d
v2ray.com/core/common/crypto.(*AuthenticationWriter).writePacket(0xc4200700c0, 0x0, 0x0, 0x0, 0x0, 0x0)
        /go/src/v2ray.com/core/common/crypto/auth.go:226 +0x1cc
v2ray.com/core/common/crypto.(*AuthenticationWriter).WriteMultiBuffer(0xc4200700c0, 0xc4219ad800, 0x1, 0x80, 0x0, 0x0)
        /go/src/v2ray.com/core/common/crypto/auth.go:234 +0x9b
v2ray.com/core/proxy/vmess/inbound.transferResponse(0xb0e1e0, 0xc42064c520, 0xc4205d5290, 0xc420247110, 0xc420eb5778, 0x7f8c649ba7d0, 0xc420cb2060, 0xb0df20, 0xc42064c620, 0xc420eb57a0, ...)
        /go/src/v2ray.com/core/proxy/vmess/inbound/inbound.go:192 +0xe6
v2ray.com/core/proxy/vmess/inbound.(*Handler).Process.func2(0x0, 0x0)
        /go/src/v2ray.com/core/proxy/vmess/inbound/inbound.go:294 +0x27a
v2ray.com/core/common/signal.executeAndFulfill(0xc420430c80, 0xc420cb22a0)
        /go/src/v2ray.com/core/common/signal/exec.go:8 +0x27
created by v2ray.com/core/common/signal.ExecuteAsync
        /go/src/v2ray.com/core/common/signal/exec.go:18 +0x67
DarienRaymond commented 6 years ago

又修了一些问题,发了3.15。

sjx95 commented 6 years ago

Cool v2ray/official V3.15 已正常运行超过 12 小时,持续观察中。

DarienRaymond commented 6 years ago

Assuming fixed. Please reopen if it still occurs.

sjx95 commented 6 years ago

No more crash since then, so I think it's fixed, too. Thank you.