Git Product home page Git Product logo

Comments (3)

kalbasit avatar kalbasit commented on July 2, 2024

not sure if it's related to how early is the connection at all, it seems to crash as soon as it gets a connection.

I applied #30 but it didn't work

diff --git a/vendor/github.com/soheilhy/cmux/patricia.go b/vendor/github.com/soheilhy/cmux/patricia.go
index 0099e38..a38cae0 100644
--- a/vendor/github.com/soheilhy/cmux/patricia.go
+++ b/vendor/github.com/soheilhy/cmux/patricia.go
@@ -22,8 +22,8 @@ import (
 // patriciaTree is a simple patricia tree that handles []byte instead of string
 // and cannot be changed after instantiation.
 type patriciaTree struct {
-       root *ptNode
-       buf  []byte // preallocated buffer to read data while matching
+       root     *ptNode
+       maxDepth int // max depth of the tree.
 }

 func newPatriciaTree(bs ...[]byte) *patriciaTree {
@@ -34,8 +34,8 @@ func newPatriciaTree(bs ...[]byte) *patriciaTree {
                }
        }
        return &patriciaTree{
-               root: newNode(bs),
-               buf:  make([]byte, max+1),
+               root:     newNode(bs),
+               maxDepth: max + 1,
        }
 }

@@ -48,13 +48,15 @@ func newPatriciaTreeString(strs ...string) *patriciaTree {
 }

 func (t *patriciaTree) matchPrefix(r io.Reader) bool {
-       n, _ := io.ReadFull(r, t.buf)
-       return t.root.match(t.buf[:n], true)
+       buf := make([]byte, t.maxDepth)
+       n, _ := io.ReadFull(r, buf)
+       return t.root.match(buf[:n], true)
 }

 func (t *patriciaTree) match(r io.Reader) bool {
-       n, _ := io.ReadFull(r, t.buf)
-       return t.root.match(t.buf[:n], false)
+       buf := make([]byte, t.maxDepth)
+       n, _ := io.ReadFull(r, buf)
+       return t.root.match(buf[:n], false)
 }

 type ptNode struct {
2016/07/15 07:06:58 starting the HTTP/HTTPS/gRPC server bound to ":8091"
panic: runtime error: index out of range

goroutine 87 [running]:
panic(0xf203a0, 0xc820014010)
        /usr/local/go/src/runtime/panic.go:481 +0x3e6
github.com/publica-project/grpc-logger/vendor/github.com/soheilhy/cmux.(*ptNode).match(0xc82051d950, 0xc82054d388, 0x0, 0x8, 0x1, 0x0)
        /go/src/github.com/publica-project/grpc-logger/vendor/github.com/soheilhy/cmux/patricia.go:164 +0x1f0
github.com/publica-project/grpc-logger/vendor/github.com/soheilhy/cmux.(*patriciaTree).matchPrefix(0xc8205596f0, 0x7fa00d2bcc28, 0xc8202766d0, 0x40cfca)
        /go/src/github.com/publica-project/grpc-logger/vendor/github.com/soheilhy/cmux/patricia.go:53 +0xd7
github.com/publica-project/grpc-logger/vendor/github.com/soheilhy/cmux.(*patriciaTree).(github.com/publica-project/grpc-logger/vendor/github.com/soheilhy/cmux.matchPrefix)-fm(0x7fa00d2bcc28, 0xc8202766d0, 0x7fa00d2a85b0)
        /go/src/github.com/publica-project/grpc-logger/vendor/github.com/soheilhy/cmux/matchers.go:37 +0x34
github.com/publica-project/grpc-logger/vendor/github.com/soheilhy/cmux.matchersToMatchWriters.func1(0x7fa00d2a85b0, 0xc820022518, 0x7fa00d2bcc28, 0xc8202766d0, 0xc820022518)
        /go/src/github.com/publica-project/grpc-logger/vendor/github.com/soheilhy/cmux/cmux.go:112 +0x32
github.com/publica-project/grpc-logger/vendor/github.com/soheilhy/cmux.(*cMux).serve(0xc8202a5000, 0x7fa00d2a7e90, 0xc820022518, 0xc82029b200, 0xc820559730)
        /go/src/github.com/publica-project/grpc-logger/vendor/github.com/soheilhy/cmux/cmux.go:168 +0x33e
created by github.com/publica-project/grpc-logger/vendor/github.com/soheilhy/cmux.(*cMux).Serve
        /go/src/github.com/publica-project/grpc-logger/vendor/github.com/soheilhy/cmux/cmux.go:158 +0x188

from cmux.

soheilhy avatar soheilhy commented on July 2, 2024

Thanks for the bug report! Can you please check if #33 fixes the issue for you?

from cmux.

kalbasit avatar kalbasit commented on July 2, 2024

#33 fixed the issue.

from cmux.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.