Chromedp: "fatal error: checkptr: unsafe pointer conversion" with Go 1.14 und race detector

Created on 27 Feb 2020  路  4Comments  路  Source: chromedp/chromedp

What versions are you running?

github.com/chromedp/chromedp v0.5.3
Google Chrome 80.0.3987.116

Issue is present on chromedp v0.5.0 too and unrelated to Chrome

What did you do? Include clear steps.

Run chromedp with Go 1.14 under the race detector:

$ go test -race
fatal error: checkptr: unsafe pointer conversion

goroutine 122 [running]:
runtime.throw(0x1f0854e, 0x23)
    /usr/local/go/src/runtime/panic.go:1112 +0x72 fp=0xc00062cdd0 sp=0xc00062cda0 pc=0x1073eb2
runtime.checkptrAlignment(0xc000448035, 0x1d8b100, 0x1)
    /usr/local/go/src/runtime/checkptr.go:13 +0xd0 fp=0xc00062ce00 sp=0xc00062cdd0 pc=0x1045ba0
github.com/gobwas/ws.btsEqualFold(0xc000448034, 0x9, 0xfcc, 0x2818c38, 0x9, 0x9, 0xc000448034)
    /Users/m0252720/go/pkg/mod/github.com/gobwas/[email protected]/util.go:233 +0x184 fp=0xc00062ce68 sp=0xc00062ce00 pc=0x1c42ee4
github.com/gobwas/ws.Dialer.Upgrade(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /Users/m0252720/go/pkg/mod/github.com/gobwas/[email protected]/dialer.go:374 +0xe72 fp=0xc00062d0f8 sp=0xc00062ce68 pc=0x1c3dfd2
github.com/gobwas/ws.Dialer.Dial(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /Users/m0252720/go/pkg/mod/github.com/gobwas/[email protected]/dialer.go:190 +0x444 fp=0xc00062d480 sp=0xc00062d0f8 pc=0x1c3c2e4
github.com/gobwas/ws.Dial(...)
    /Users/m0252720/go/pkg/mod/github.com/gobwas/[email protected]/dialer.go:47
github.com/chromedp/chromedp.DialContext(0x2109cc0, 0xc000220f00, 0xc000119450, 0x4a, 0xc00062d798, 0x1, 0x1, 0x1088523, 0xc0003d3a40, 0x2)
    /Users/m0252720/go/pkg/mod/github.com/chromedp/[email protected]/conn.go:59 +0xff fp=0xc00062d660 sp=0xc00062d480 pc=0x1c7794f
github.com/chromedp/chromedp.NewBrowser(0x2109d00, 0xc000356390, 0xc000119450, 0x4a, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /Users/m0252720/go/pkg/mod/github.com/chromedp/[email protected]/browser.go:104 +0x3c9 fp=0xc00062d7d0 sp=0xc00062d660 pc=0x1c72309
github.com/chromedp/chromedp.(*ExecAllocator).Allocate(0xc00019e370, 0x2109d00, 0xc000356390, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /Users/m0252720/go/pkg/mod/github.com/chromedp/[email protected]/allocate.go:240 +0x118f fp=0xc00062db50 sp=0xc00062d7d0 pc=0x1c7055f
github.com/chromedp/chromedp.Run(0x2109d00, 0xc000356390, 0xc00062dcb8, 0x1, 0x1, 0x0, 0x0)
    /Users/m0252720/go/pkg/mod/github.com/chromedp/[email protected]/chromedp.go:227 +0x311 fp=0xc00062dc40 sp=0xc00062db50 pc=0x1c7543

(We use chromedp to generate screenshots during testing and we run our tests under the race detector too during CI.)

What did you expect to see?

No failure

What did you see instead?

An error detected (see above) by the new checkptr compile time option which is new (and per default enabled when the race detector is enabled) and checks that unsafe.Pointer safety rules are followed. See https://golang.org/doc/go1.14#compiler for additional details.

Root cause

The problem is not _directly_ in chromedp's code but in the dependency github.com/gobwas/ws.
The issue is reported there too (https://github.com/gobwas/ws/issues/99). If the issue is not or cannot be fixed upstream in package ws it might be necessary to use a different websocket library in chromedp.

Most helpful comment

Thanks @cristaloleg!

All 4 comments

Thanks for filing the issue. It's weird noone has spotted this before; I regularly test chromedp with Go master, though I don't use the race detector all the time.

Let's give upstream a week to respond or issue a fix. More people are going to upgrade to 1.14 in the coming days, including them probably, so I figure they'll fix it sooner than later. In the meantime, noone is forced to upgrade to 1.14 today, so sticking to 1.13.x is an OK workaround for a few days.

Replacing the websocket library is possible, but it's work. We already switched to gobwas for performance reasons. Finding another library that's just as performant, and non-buggy, would be enough work on its own.

Thanks @cristaloleg!

@mvdan Any chance we tag a release with this fix soon?

You can use master easily, or just update to the latest gobwas/ws without updating chromedp. I don't think a release here is necessary right now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

iMaxopoly picture iMaxopoly  路  3Comments

t-blake picture t-blake  路  3Comments

youshy picture youshy  路  5Comments

shailendrayadav1 picture shailendrayadav1  路  4Comments

AmrAlfoly picture AmrAlfoly  路  3Comments