ws icon indicating copy to clipboard operation
ws copied to clipboard

wsutil: buffer grow leads to its reduce

Open maxjust opened this issue 4 years ago • 8 comments

Under using chromedp package wich use that lib as dependency got panic in some cases with the follow stack trace

panic: wsutil: buffer grow leads to its reduce                              
goroutine 42 [running]:                                                     
github.com/gobwas/ws/wsutil.(*Writer).Grow(0xc0004c22e8, 0x1b)              
        /home/max/go/pkg/mod/github.com/gobwas/[email protected]/wsutil/writer.
github.com/gobwas/ws/wsutil.(*Writer).Write(0xc0004c22e8, 0xc000ad4000, 0x8d
        /home/max/go/pkg/mod/github.com/gobwas/[email protected]/wsutil/writer.
net.(*Buffers).WriteTo(0xc0328f45c0, 0xee9ec0, 0xc0004c22e8, 0x1ffad, 0x1ffa
        /usr/local/go/src/net/net.go:675 +0xd9                              
github.com/mailru/easyjson/buffer.(*Buffer).DumpTo(0xc0004c2410, 0xee9ec0, 0
        /home/max/go/pkg/mod/github.com/mailru/[email protected]/buffer/pool.g
github.com/mailru/easyjson/jwriter.(*Writer).DumpTo(...)                    
        /home/max/go/pkg/mod/github.com/mailru/[email protected]/jwriter/write
github.com/chromedp/chromedp.(*Conn).Write(0xc0004c2240, 0xef56a0, 0xc000928
        /home/max/go/pkg/mod/github.com/chromedp/[email protected]/conn.go:137
github.com/chromedp/chromedp.(*Browser).run(0xc0006bb900, 0xef56a0, 0xc00092
        /home/max/go/pkg/mod/github.com/chromedp/[email protected]/browser.go:
created by github.com/chromedp/chromedp.NewBrowser                          
        /home/max/go/pkg/mod/github.com/chromedp/[email protected]/browser.go:
%# v &{info systemd 45 0xc0000c8820 0xc0000c8870 0xc0006bc760 0xc000495950}

I think it`s problem with call size in chromedp, but generally lib should detect grow size lower than current without panic.

maxjust avatar Jul 07 '21 11:07 maxjust

Related commit that was fixing this https://github.com/gobwas/ws/commit/4b75daf8999178c7bd9a0687cc5bb0613f084237 and PR with a prototype (or so) https://github.com/gobwas/ws/pull/134

cristaloleg avatar Jul 07 '21 13:07 cristaloleg

@maxjust does the commit mentioned by @cristaloleg (thanks!) works for you now? Can I close this?

gobwas avatar Jul 09 '21 15:07 gobwas

@gobwas I cant test it while it's not released, I use this lib as subdependency another lib. Owner of another lib (chromedp) wrote me this:

The issue has been fixed in github.com/gobwas/ws, but it's not released yet. I will update the dependency once github.com/gobwas/[email protected] is released.
Thanks!

So, while you release 1.0.5. I can't test and give the answer

maxjust avatar Jul 10 '21 09:07 maxjust

@maxjust there is the latest release candidate (v1.1.0-rc.6) which should contain the fix. If you want, you can test against it, or wait a bit -- I'm planning to release the v1.1.0 on Monday.

gobwas avatar Jul 10 '21 15:07 gobwas

@gobwas, thanks for your quick response, I will wait for the monday, and then will write to github.com/chromedp about request to update the lib wich I use.

maxjust avatar Jul 10 '21 17:07 maxjust

@maxjust done, v1.1.0 is out 🎉

gobwas avatar Jul 12 '21 09:07 gobwas

@maxjust can I close this, or isn't it clear yet? :)

gobwas avatar Jul 27 '21 09:07 gobwas

@maxjust I'm going to close it in a few days 👋🏻

gobwas avatar Sep 03 '21 18:09 gobwas

Closing (looks like it fixed).

cristaloleg avatar Apr 06 '23 19:04 cristaloleg